FFmpeg
mpegutils.h
Go to the documentation of this file.
1 /*
2  * Mpeg video formats-related defines and utility functions
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef AVCODEC_MPEGUTILS_H
22 #define AVCODEC_MPEGUTILS_H
23 
24 #include <stdint.h>
25 
26 #include "libavutil/frame.h"
27 
28 #include "avcodec.h"
29 
30 /**
31  * Return value for header parsers if frame is not coded.
32  * */
33 #define FRAME_SKIPPED 100
34 
35 /* picture type */
36 #define PICT_TOP_FIELD 1
37 #define PICT_BOTTOM_FIELD 2
38 #define PICT_FRAME 3
39 
40 #define MAX_MB_BYTES (30 * 16 * 16 * 3 / 8 + 120)
41 #define MAX_FCODE 7
42 
43 /* MB types */
44 #define MB_TYPE_INTRA4x4 (1 << 0)
45 #define MB_TYPE_INTRA16x16 (1 << 1) // FIXME H.264-specific
46 #define MB_TYPE_INTRA_PCM (1 << 2) // FIXME H.264-specific
47 #define MB_TYPE_16x16 (1 << 3)
48 #define MB_TYPE_16x8 (1 << 4)
49 #define MB_TYPE_8x16 (1 << 5)
50 #define MB_TYPE_8x8 (1 << 6)
51 #define MB_TYPE_INTERLACED (1 << 7)
52 #define MB_TYPE_DIRECT2 (1 << 8) // FIXME
53 #define MB_TYPE_ACPRED (1 << 9)
54 #define MB_TYPE_GMC (1 << 10)
55 #define MB_TYPE_SKIP (1 << 11)
56 #define MB_TYPE_P0L0 (1 << 12)
57 #define MB_TYPE_P1L0 (1 << 13)
58 #define MB_TYPE_P0L1 (1 << 14)
59 #define MB_TYPE_P1L1 (1 << 15)
60 #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
61 #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
62 #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
63 #define MB_TYPE_QUANT (1 << 16)
64 #define MB_TYPE_CBP (1 << 17)
65 
66 #define MB_TYPE_INTRA MB_TYPE_INTRA4x4 // default mb_type if there is just one type
67 
68 #define IS_INTRA4x4(a) ((a) & MB_TYPE_INTRA4x4)
69 #define IS_INTRA16x16(a) ((a) & MB_TYPE_INTRA16x16)
70 #define IS_PCM(a) ((a) & MB_TYPE_INTRA_PCM)
71 #define IS_INTRA(a) ((a) & 7)
72 #define IS_INTER(a) ((a) & (MB_TYPE_16x16 | MB_TYPE_16x8 | \
73  MB_TYPE_8x16 | MB_TYPE_8x8))
74 #define IS_SKIP(a) ((a) & MB_TYPE_SKIP)
75 #define IS_INTRA_PCM(a) ((a) & MB_TYPE_INTRA_PCM)
76 #define IS_INTERLACED(a) ((a) & MB_TYPE_INTERLACED)
77 #define IS_DIRECT(a) ((a) & MB_TYPE_DIRECT2)
78 #define IS_GMC(a) ((a) & MB_TYPE_GMC)
79 #define IS_16X16(a) ((a) & MB_TYPE_16x16)
80 #define IS_16X8(a) ((a) & MB_TYPE_16x8)
81 #define IS_8X16(a) ((a) & MB_TYPE_8x16)
82 #define IS_8X8(a) ((a) & MB_TYPE_8x8)
83 #define IS_SUB_8X8(a) ((a) & MB_TYPE_16x16) // note reused
84 #define IS_SUB_8X4(a) ((a) & MB_TYPE_16x8) // note reused
85 #define IS_SUB_4X8(a) ((a) & MB_TYPE_8x16) // note reused
86 #define IS_SUB_4X4(a) ((a) & MB_TYPE_8x8) // note reused
87 #define IS_ACPRED(a) ((a) & MB_TYPE_ACPRED)
88 #define IS_QUANT(a) ((a) & MB_TYPE_QUANT)
89 #define IS_DIR(a, part, list) ((a) & (MB_TYPE_P0L0 << ((part) + 2 * (list))))
90 
91 // does this mb use listX, note does not work if subMBs
92 #define USES_LIST(a, list) ((a) & ((MB_TYPE_P0L0 | MB_TYPE_P1L0) << (2 * (list))))
93 
94 #define HAS_CBP(a) ((a) & MB_TYPE_CBP)
95 
96 /* MB types for encoding */
97 #define CANDIDATE_MB_TYPE_INTRA (1 << 0)
98 #define CANDIDATE_MB_TYPE_INTER (1 << 1)
99 #define CANDIDATE_MB_TYPE_INTER4V (1 << 2)
100 #define CANDIDATE_MB_TYPE_SKIPPED (1 << 3)
101 
102 #define CANDIDATE_MB_TYPE_DIRECT (1 << 4)
103 #define CANDIDATE_MB_TYPE_FORWARD (1 << 5)
104 #define CANDIDATE_MB_TYPE_BACKWARD (1 << 6)
105 #define CANDIDATE_MB_TYPE_BIDIR (1 << 7)
106 
107 #define CANDIDATE_MB_TYPE_INTER_I (1 << 8)
108 #define CANDIDATE_MB_TYPE_FORWARD_I (1 << 9)
109 #define CANDIDATE_MB_TYPE_BACKWARD_I (1 << 10)
110 #define CANDIDATE_MB_TYPE_BIDIR_I (1 << 11)
111 
112 #define CANDIDATE_MB_TYPE_DIRECT0 (1 << 12)
113 
114 #define INPLACE_OFFSET 16
115 
122 };
123 
124 
125 /**
126  * Draw a horizontal band if supported.
127  *
128  * @param h is the normal height, this will be reduced automatically if needed
129  */
130 void ff_draw_horiz_band(AVCodecContext *avctx, const AVFrame *cur, const AVFrame *last,
131  int y, int h, int picture_structure, int first_field,
132  int low_delay);
133 
134 /**
135  * Print debugging info for the given picture.
136  */
137 void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict,
138  const uint8_t *mbskip_table, const uint32_t *mbtype_table,
139  const int8_t *qscale_table, int16_t (*const motion_val[2])[2],
140  int mb_width, int mb_height, int mb_stride, int quarter_sample);
141 
142 #endif /* AVCODEC_MPEGUTILS_H */
FMT_MPEG1
@ FMT_MPEG1
Definition: mpegutils.h:117
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:330
OutputFormat
OutputFormat
Definition: mpegutils.h:116
FMT_H261
@ FMT_H261
Definition: mpegutils.h:118
ff_draw_horiz_band
void ff_draw_horiz_band(AVCodecContext *avctx, const AVFrame *cur, const AVFrame *last, int y, int h, int picture_structure, int first_field, int low_delay)
Draw a horizontal band if supported.
Definition: mpegutils.c:51
FMT_MJPEG
@ FMT_MJPEG
Definition: mpegutils.h:120
FMT_SPEEDHQ
@ FMT_SPEEDHQ
Definition: mpegutils.h:121
frame.h
FMT_H263
@ FMT_H263
Definition: mpegutils.h:119
avcodec.h
AVCodecContext
main external API structure.
Definition: avcodec.h:426
ff_print_debug_info2
void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, const uint8_t *mbskip_table, const uint32_t *mbtype_table, const int8_t *qscale_table, int16_t(*const motion_val[2])[2], int mb_width, int mb_height, int mb_stride, int quarter_sample)
Print debugging info for the given picture.
Definition: mpegutils.c:157
h
h
Definition: vp9dsp_template.c:2038
first_field
static int first_field(const struct video_data *s)
Definition: v4l2.c:246