FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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 #include "version.h"
30 
31 /**
32  * Return value for header parsers if frame is not coded.
33  * */
34 #define FRAME_SKIPPED 100
35 
36 /* picture type */
37 #define PICT_TOP_FIELD 1
38 #define PICT_BOTTOM_FIELD 2
39 #define PICT_FRAME 3
40 
41 /**
42  * Value of Picture.reference when Picture is not a reference picture, but
43  * is held for delayed output.
44  */
45 #define DELAYED_PIC_REF 4
46 
47 #define MAX_MB_BYTES (30 * 16 * 16 * 3 / 8 + 120)
48 #define MAX_FCODE 7
49 
50 /* MB types */
51 #define MB_TYPE_INTRA4x4 (1 << 0)
52 #define MB_TYPE_INTRA16x16 (1 << 1) // FIXME H.264-specific
53 #define MB_TYPE_INTRA_PCM (1 << 2) // FIXME H.264-specific
54 #define MB_TYPE_16x16 (1 << 3)
55 #define MB_TYPE_16x8 (1 << 4)
56 #define MB_TYPE_8x16 (1 << 5)
57 #define MB_TYPE_8x8 (1 << 6)
58 #define MB_TYPE_INTERLACED (1 << 7)
59 #define MB_TYPE_DIRECT2 (1 << 8) // FIXME
60 #define MB_TYPE_ACPRED (1 << 9)
61 #define MB_TYPE_GMC (1 << 10)
62 #define MB_TYPE_SKIP (1 << 11)
63 #define MB_TYPE_P0L0 (1 << 12)
64 #define MB_TYPE_P1L0 (1 << 13)
65 #define MB_TYPE_P0L1 (1 << 14)
66 #define MB_TYPE_P1L1 (1 << 15)
67 #define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0)
68 #define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1)
69 #define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1)
70 #define MB_TYPE_QUANT (1 << 16)
71 #define MB_TYPE_CBP (1 << 17)
72 
73 #define MB_TYPE_INTRA MB_TYPE_INTRA4x4 // default mb_type if there is just one type
74 
75 #define IS_INTRA4x4(a) ((a) & MB_TYPE_INTRA4x4)
76 #define IS_INTRA16x16(a) ((a) & MB_TYPE_INTRA16x16)
77 #define IS_PCM(a) ((a) & MB_TYPE_INTRA_PCM)
78 #define IS_INTRA(a) ((a) & 7)
79 #define IS_INTER(a) ((a) & (MB_TYPE_16x16 | MB_TYPE_16x8 | \
80  MB_TYPE_8x16 | MB_TYPE_8x8))
81 #define IS_SKIP(a) ((a) & MB_TYPE_SKIP)
82 #define IS_INTRA_PCM(a) ((a) & MB_TYPE_INTRA_PCM)
83 #define IS_INTERLACED(a) ((a) & MB_TYPE_INTERLACED)
84 #define IS_DIRECT(a) ((a) & MB_TYPE_DIRECT2)
85 #define IS_GMC(a) ((a) & MB_TYPE_GMC)
86 #define IS_16X16(a) ((a) & MB_TYPE_16x16)
87 #define IS_16X8(a) ((a) & MB_TYPE_16x8)
88 #define IS_8X16(a) ((a) & MB_TYPE_8x16)
89 #define IS_8X8(a) ((a) & MB_TYPE_8x8)
90 #define IS_SUB_8X8(a) ((a) & MB_TYPE_16x16) // note reused
91 #define IS_SUB_8X4(a) ((a) & MB_TYPE_16x8) // note reused
92 #define IS_SUB_4X8(a) ((a) & MB_TYPE_8x16) // note reused
93 #define IS_SUB_4X4(a) ((a) & MB_TYPE_8x8) // note reused
94 #define IS_ACPRED(a) ((a) & MB_TYPE_ACPRED)
95 #define IS_QUANT(a) ((a) & MB_TYPE_QUANT)
96 #define IS_DIR(a, part, list) ((a) & (MB_TYPE_P0L0 << ((part) + 2 * (list))))
97 
98 // does this mb use listX, note does not work if subMBs
99 #define USES_LIST(a, list) ((a) & ((MB_TYPE_P0L0 | MB_TYPE_P1L0) << (2 * (list))))
100 
101 #define HAS_CBP(a) ((a) & MB_TYPE_CBP)
102 
103 /* MB types for encoding */
104 #define CANDIDATE_MB_TYPE_INTRA (1 << 0)
105 #define CANDIDATE_MB_TYPE_INTER (1 << 1)
106 #define CANDIDATE_MB_TYPE_INTER4V (1 << 2)
107 #define CANDIDATE_MB_TYPE_SKIPPED (1 << 3)
108 
109 #define CANDIDATE_MB_TYPE_DIRECT (1 << 4)
110 #define CANDIDATE_MB_TYPE_FORWARD (1 << 5)
111 #define CANDIDATE_MB_TYPE_BACKWARD (1 << 6)
112 #define CANDIDATE_MB_TYPE_BIDIR (1 << 7)
113 
114 #define CANDIDATE_MB_TYPE_INTER_I (1 << 8)
115 #define CANDIDATE_MB_TYPE_FORWARD_I (1 << 9)
116 #define CANDIDATE_MB_TYPE_BACKWARD_I (1 << 10)
117 #define CANDIDATE_MB_TYPE_BIDIR_I (1 << 11)
118 
119 #define CANDIDATE_MB_TYPE_DIRECT0 (1 << 12)
120 
121 #define INPLACE_OFFSET 16
122 
128 };
129 
130 
131 /**
132  * Draw a horizontal band if supported.
133  *
134  * @param h is the normal height, this will be reduced automatically if needed
135  */
136 void ff_draw_horiz_band(AVCodecContext *avctx, AVFrame *cur, AVFrame *last,
137  int y, int h, int picture_structure, int first_field,
138  int low_delay);
139 
140 /**
141  * Print debugging info for the given picture.
142  */
143 void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_table,
144  uint32_t *mbtype_table, int8_t *qscale_table, int16_t (*motion_val[2])[2],
145  int *low_delay,
146  int mb_width, int mb_height, int mb_stride, int quarter_sample);
147 
148 #endif /* AVCODEC_MPEGUTILS_H */
This structure describes decoded (raw) audio or video data.
Definition: frame.h:218
attribute_deprecated int8_t * qscale_table
QP table.
Definition: frame.h:539
OutputFormat
Definition: mpegutils.h:123
uint8_t
static int first_field(const struct video_data *s)
Definition: v4l2.c:230
Libavcodec version macros.
reference-counted frame API
Libavcodec external API header.
main external API structure.
Definition: avcodec.h:1518
void ff_draw_horiz_band(AVCodecContext *avctx, AVFrame *cur, 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
void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_table, uint32_t *mbtype_table, int8_t *qscale_table, int16_t(*motion_val[2])[2], int *low_delay, int mb_width, int mb_height, int mb_stride, int quarter_sample)
Print debugging info for the given picture.
Definition: mpegutils.c:103