29 | 30 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,111 @@ |
0 |
+/* |
|
1 |
+ * Mpeg video formats-related defines and utility functions |
|
2 |
+ * |
|
3 |
+ * This file is part of Libav. |
|
4 |
+ * |
|
5 |
+ * Libav is free software; you can redistribute it and/or |
|
6 |
+ * modify it under the terms of the GNU Lesser General Public |
|
7 |
+ * License as published by the Free Software Foundation; either |
|
8 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
9 |
+ * |
|
10 |
+ * Libav is distributed in the hope that it will be useful, |
|
11 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 |
+ * Lesser General Public License for more details. |
|
14 |
+ * |
|
15 |
+ * You should have received a copy of the GNU Lesser General Public |
|
16 |
+ * License along with Libav; if not, write to the Free Software |
|
17 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
18 |
+ */ |
|
19 |
+ |
|
20 |
+#ifndef AVCODEC_MPEGUTILS_H |
|
21 |
+#define AVCODEC_MPEGUTILS_H |
|
22 |
+ |
|
23 |
+#include "version.h" |
|
24 |
+ |
|
25 |
+/* picture type */ |
|
26 |
+#define PICT_TOP_FIELD 1 |
|
27 |
+#define PICT_BOTTOM_FIELD 2 |
|
28 |
+#define PICT_FRAME 3 |
|
29 |
+ |
|
30 |
+/** |
|
31 |
+ * Value of Picture.reference when Picture is not a reference picture, but |
|
32 |
+ * is held for delayed output. |
|
33 |
+ */ |
|
34 |
+#define DELAYED_PIC_REF 4 |
|
35 |
+ |
|
36 |
+ |
|
37 |
+/* MB types */ |
|
38 |
+#if !FF_API_MB_TYPE |
|
39 |
+#define MB_TYPE_INTRA4x4 (1 << 0) |
|
40 |
+#define MB_TYPE_INTRA16x16 (1 << 1) // FIXME H.264-specific |
|
41 |
+#define MB_TYPE_INTRA_PCM (1 << 2) // FIXME H.264-specific |
|
42 |
+#define MB_TYPE_16x16 (1 << 3) |
|
43 |
+#define MB_TYPE_16x8 (1 << 4) |
|
44 |
+#define MB_TYPE_8x16 (1 << 5) |
|
45 |
+#define MB_TYPE_8x8 (1 << 6) |
|
46 |
+#define MB_TYPE_INTERLACED (1 << 7) |
|
47 |
+#define MB_TYPE_DIRECT2 (1 << 8) // FIXME |
|
48 |
+#define MB_TYPE_ACPRED (1 << 9) |
|
49 |
+#define MB_TYPE_GMC (1 << 10) |
|
50 |
+#define MB_TYPE_SKIP (1 << 11) |
|
51 |
+#define MB_TYPE_P0L0 (1 << 12) |
|
52 |
+#define MB_TYPE_P1L0 (1 << 13) |
|
53 |
+#define MB_TYPE_P0L1 (1 << 14) |
|
54 |
+#define MB_TYPE_P1L1 (1 << 15) |
|
55 |
+#define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0) |
|
56 |
+#define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1) |
|
57 |
+#define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1) |
|
58 |
+#define MB_TYPE_QUANT (1 << 16) |
|
59 |
+#define MB_TYPE_CBP (1 << 17) |
|
60 |
+#endif |
|
61 |
+ |
|
62 |
+#define MB_TYPE_INTRA MB_TYPE_INTRA4x4 // default mb_type if there is just one type |
|
63 |
+ |
|
64 |
+#define IS_INTRA4x4(a) ((a) & MB_TYPE_INTRA4x4) |
|
65 |
+#define IS_INTRA16x16(a) ((a) & MB_TYPE_INTRA16x16) |
|
66 |
+#define IS_PCM(a) ((a) & MB_TYPE_INTRA_PCM) |
|
67 |
+#define IS_INTRA(a) ((a) & 7) |
|
68 |
+#define IS_INTER(a) ((a) & (MB_TYPE_16x16 | MB_TYPE_16x8 | \ |
|
69 |
+ MB_TYPE_8x16 | MB_TYPE_8x8)) |
|
70 |
+#define IS_SKIP(a) ((a) & MB_TYPE_SKIP) |
|
71 |
+#define IS_INTRA_PCM(a) ((a) & MB_TYPE_INTRA_PCM) |
|
72 |
+#define IS_INTERLACED(a) ((a) & MB_TYPE_INTERLACED) |
|
73 |
+#define IS_DIRECT(a) ((a) & MB_TYPE_DIRECT2) |
|
74 |
+#define IS_GMC(a) ((a) & MB_TYPE_GMC) |
|
75 |
+#define IS_16X16(a) ((a) & MB_TYPE_16x16) |
|
76 |
+#define IS_16X8(a) ((a) & MB_TYPE_16x8) |
|
77 |
+#define IS_8X16(a) ((a) & MB_TYPE_8x16) |
|
78 |
+#define IS_8X8(a) ((a) & MB_TYPE_8x8) |
|
79 |
+#define IS_SUB_8X8(a) ((a) & MB_TYPE_16x16) // note reused |
|
80 |
+#define IS_SUB_8X4(a) ((a) & MB_TYPE_16x8) // note reused |
|
81 |
+#define IS_SUB_4X8(a) ((a) & MB_TYPE_8x16) // note reused |
|
82 |
+#define IS_SUB_4X4(a) ((a) & MB_TYPE_8x8) // note reused |
|
83 |
+#define IS_ACPRED(a) ((a) & MB_TYPE_ACPRED) |
|
84 |
+#define IS_QUANT(a) ((a) & MB_TYPE_QUANT) |
|
85 |
+#define IS_DIR(a, part, list) ((a) & (MB_TYPE_P0L0 << ((part) + 2 * (list)))) |
|
86 |
+ |
|
87 |
+// does this mb use listX, note does not work if subMBs |
|
88 |
+#define USES_LIST(a, list) ((a) & ((MB_TYPE_P0L0 | MB_TYPE_P1L0) << (2 * (list)))) |
|
89 |
+ |
|
90 |
+#define HAS_CBP(a) ((a) & MB_TYPE_CBP) |
|
91 |
+ |
|
92 |
+/* MB types for encoding */ |
|
93 |
+#define CANDIDATE_MB_TYPE_INTRA (1 << 0) |
|
94 |
+#define CANDIDATE_MB_TYPE_INTER (1 << 1) |
|
95 |
+#define CANDIDATE_MB_TYPE_INTER4V (1 << 2) |
|
96 |
+#define CANDIDATE_MB_TYPE_SKIPPED (1 << 3) |
|
97 |
+ |
|
98 |
+#define CANDIDATE_MB_TYPE_DIRECT (1 << 4) |
|
99 |
+#define CANDIDATE_MB_TYPE_FORWARD (1 << 5) |
|
100 |
+#define CANDIDATE_MB_TYPE_BACKWARD (1 << 6) |
|
101 |
+#define CANDIDATE_MB_TYPE_BIDIR (1 << 7) |
|
102 |
+ |
|
103 |
+#define CANDIDATE_MB_TYPE_INTER_I (1 << 8) |
|
104 |
+#define CANDIDATE_MB_TYPE_FORWARD_I (1 << 9) |
|
105 |
+#define CANDIDATE_MB_TYPE_BACKWARD_I (1 << 10) |
|
106 |
+#define CANDIDATE_MB_TYPE_BIDIR_I (1 << 11) |
|
107 |
+ |
|
108 |
+#define CANDIDATE_MB_TYPE_DIRECT0 (1 << 12) |
|
109 |
+ |
|
110 |
+#endif /* AVCODEC_PICTTYPE_H */ |
... | ... |
@@ -85,12 +85,6 @@ enum OutputFormat { |
85 | 85 |
#define EXT_START_CODE 0x000001b5 |
86 | 86 |
#define USER_START_CODE 0x000001b2 |
87 | 87 |
|
88 |
-/** |
|
89 |
- * Value of Picture.reference when Picture is not a reference picture, but |
|
90 |
- * is held for delayed output. |
|
91 |
- */ |
|
92 |
-#define DELAYED_PIC_REF 4 |
|
93 |
- |
|
94 | 88 |
struct MpegEncContext; |
95 | 89 |
|
96 | 90 |
/** |
... | ... |
@@ -107,31 +101,7 @@ typedef struct Picture{ |
107 | 107 |
int16_t (*motion_val[2])[2]; |
108 | 108 |
|
109 | 109 |
AVBufferRef *mb_type_buf; |
110 |
- uint32_t *mb_type; |
|
111 |
- |
|
112 |
-#if !FF_API_MB_TYPE |
|
113 |
-#define MB_TYPE_INTRA4x4 0x0001 |
|
114 |
-#define MB_TYPE_INTRA16x16 0x0002 //FIXME H.264-specific |
|
115 |
-#define MB_TYPE_INTRA_PCM 0x0004 //FIXME H.264-specific |
|
116 |
-#define MB_TYPE_16x16 0x0008 |
|
117 |
-#define MB_TYPE_16x8 0x0010 |
|
118 |
-#define MB_TYPE_8x16 0x0020 |
|
119 |
-#define MB_TYPE_8x8 0x0040 |
|
120 |
-#define MB_TYPE_INTERLACED 0x0080 |
|
121 |
-#define MB_TYPE_DIRECT2 0x0100 //FIXME |
|
122 |
-#define MB_TYPE_ACPRED 0x0200 |
|
123 |
-#define MB_TYPE_GMC 0x0400 |
|
124 |
-#define MB_TYPE_SKIP 0x0800 |
|
125 |
-#define MB_TYPE_P0L0 0x1000 |
|
126 |
-#define MB_TYPE_P1L0 0x2000 |
|
127 |
-#define MB_TYPE_P0L1 0x4000 |
|
128 |
-#define MB_TYPE_P1L1 0x8000 |
|
129 |
-#define MB_TYPE_L0 (MB_TYPE_P0L0 | MB_TYPE_P1L0) |
|
130 |
-#define MB_TYPE_L1 (MB_TYPE_P0L1 | MB_TYPE_P1L1) |
|
131 |
-#define MB_TYPE_L0L1 (MB_TYPE_L0 | MB_TYPE_L1) |
|
132 |
-#define MB_TYPE_QUANT 0x00010000 |
|
133 |
-#define MB_TYPE_CBP 0x00020000 |
|
134 |
-#endif |
|
110 |
+ uint32_t *mb_type; ///< types and macros are defined in mpegutils.h |
|
135 | 111 |
|
136 | 112 |
AVBufferRef *mbskip_table_buf; |
137 | 113 |
uint8_t *mbskip_table; |
... | ... |
@@ -154,31 +124,6 @@ typedef struct Picture{ |
154 | 154 |
*/ |
155 | 155 |
void *hwaccel_picture_private; |
156 | 156 |
|
157 |
-#define MB_TYPE_INTRA MB_TYPE_INTRA4x4 //default mb_type if there is just one type |
|
158 |
-#define IS_INTRA4x4(a) ((a)&MB_TYPE_INTRA4x4) |
|
159 |
-#define IS_INTRA16x16(a) ((a)&MB_TYPE_INTRA16x16) |
|
160 |
-#define IS_PCM(a) ((a)&MB_TYPE_INTRA_PCM) |
|
161 |
-#define IS_INTRA(a) ((a)&7) |
|
162 |
-#define IS_INTER(a) ((a)&(MB_TYPE_16x16|MB_TYPE_16x8|MB_TYPE_8x16|MB_TYPE_8x8)) |
|
163 |
-#define IS_SKIP(a) ((a)&MB_TYPE_SKIP) |
|
164 |
-#define IS_INTRA_PCM(a) ((a)&MB_TYPE_INTRA_PCM) |
|
165 |
-#define IS_INTERLACED(a) ((a)&MB_TYPE_INTERLACED) |
|
166 |
-#define IS_DIRECT(a) ((a)&MB_TYPE_DIRECT2) |
|
167 |
-#define IS_GMC(a) ((a)&MB_TYPE_GMC) |
|
168 |
-#define IS_16X16(a) ((a)&MB_TYPE_16x16) |
|
169 |
-#define IS_16X8(a) ((a)&MB_TYPE_16x8) |
|
170 |
-#define IS_8X16(a) ((a)&MB_TYPE_8x16) |
|
171 |
-#define IS_8X8(a) ((a)&MB_TYPE_8x8) |
|
172 |
-#define IS_SUB_8X8(a) ((a)&MB_TYPE_16x16) //note reused |
|
173 |
-#define IS_SUB_8X4(a) ((a)&MB_TYPE_16x8) //note reused |
|
174 |
-#define IS_SUB_4X8(a) ((a)&MB_TYPE_8x16) //note reused |
|
175 |
-#define IS_SUB_4X4(a) ((a)&MB_TYPE_8x8) //note reused |
|
176 |
-#define IS_ACPRED(a) ((a)&MB_TYPE_ACPRED) |
|
177 |
-#define IS_QUANT(a) ((a)&MB_TYPE_QUANT) |
|
178 |
-#define IS_DIR(a, part, list) ((a) & (MB_TYPE_P0L0<<((part)+2*(list)))) |
|
179 |
-#define USES_LIST(a, list) ((a) & ((MB_TYPE_P0L0|MB_TYPE_P1L0)<<(2*(list)))) ///< does this mb use listX, note does not work if subMBs |
|
180 |
-#define HAS_CBP(a) ((a)&MB_TYPE_CBP) |
|
181 |
- |
|
182 | 157 |
int field_poc[2]; ///< h264 top/bottom POC |
183 | 158 |
int poc; ///< h264 frame POC |
184 | 159 |
int frame_num; ///< h264 frame_num (raw frame_num from slice header) |
... | ... |
@@ -463,24 +408,7 @@ typedef struct MpegEncContext { |
463 | 463 |
int mb_x, mb_y; |
464 | 464 |
int mb_skip_run; |
465 | 465 |
int mb_intra; |
466 |
- uint16_t *mb_type; ///< Table for candidate MB types for encoding |
|
467 |
-#define CANDIDATE_MB_TYPE_INTRA 0x01 |
|
468 |
-#define CANDIDATE_MB_TYPE_INTER 0x02 |
|
469 |
-#define CANDIDATE_MB_TYPE_INTER4V 0x04 |
|
470 |
-#define CANDIDATE_MB_TYPE_SKIPPED 0x08 |
|
471 |
-//#define MB_TYPE_GMC 0x10 |
|
472 |
- |
|
473 |
-#define CANDIDATE_MB_TYPE_DIRECT 0x10 |
|
474 |
-#define CANDIDATE_MB_TYPE_FORWARD 0x20 |
|
475 |
-#define CANDIDATE_MB_TYPE_BACKWARD 0x40 |
|
476 |
-#define CANDIDATE_MB_TYPE_BIDIR 0x80 |
|
477 |
- |
|
478 |
-#define CANDIDATE_MB_TYPE_INTER_I 0x100 |
|
479 |
-#define CANDIDATE_MB_TYPE_FORWARD_I 0x200 |
|
480 |
-#define CANDIDATE_MB_TYPE_BACKWARD_I 0x400 |
|
481 |
-#define CANDIDATE_MB_TYPE_BIDIR_I 0x800 |
|
482 |
- |
|
483 |
-#define CANDIDATE_MB_TYPE_DIRECT0 0x1000 |
|
466 |
+ uint16_t *mb_type; ///< Table for candidate MB types for encoding (defines in mpegutils.h) |
|
484 | 467 |
|
485 | 468 |
int block_index[6]; ///< index to current MB in block based arrays with edges |
486 | 469 |
int block_wrap[6]; |
... | ... |
@@ -639,11 +567,9 @@ typedef struct MpegEncContext { |
639 | 639 |
/* MPEG-2-specific - I wished not to have to support this mess. */ |
640 | 640 |
int progressive_sequence; |
641 | 641 |
int mpeg_f_code[2][2]; |
642 |
+ |
|
643 |
+ // picture structure defines are loaded from mpegutils.h |
|
642 | 644 |
int picture_structure; |
643 |
-/* picture type */ |
|
644 |
-#define PICT_TOP_FIELD 1 |
|
645 |
-#define PICT_BOTTOM_FIELD 2 |
|
646 |
-#define PICT_FRAME 3 |
|
647 | 645 |
|
648 | 646 |
int intra_dc_precision; |
649 | 647 |
int frame_pred_frame_dct; |