Line | Branch | Exec | Source |
---|---|---|---|
1 | /* | ||
2 | * H.261 encoder | ||
3 | * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> | ||
4 | * Copyright (c) 2004 Maarten Daniels | ||
5 | * | ||
6 | * This file is part of FFmpeg. | ||
7 | * | ||
8 | * FFmpeg is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU Lesser General Public | ||
10 | * License as published by the Free Software Foundation; either | ||
11 | * version 2.1 of the License, or (at your option) any later version. | ||
12 | * | ||
13 | * FFmpeg is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * Lesser General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU Lesser General Public | ||
19 | * License along with FFmpeg; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | */ | ||
22 | |||
23 | /** | ||
24 | * @file | ||
25 | * H.261 encoder. | ||
26 | */ | ||
27 | |||
28 | #include "libavutil/attributes.h" | ||
29 | #include "libavutil/avassert.h" | ||
30 | #include "libavutil/thread.h" | ||
31 | #include "avcodec.h" | ||
32 | #include "codec_internal.h" | ||
33 | #include "mpegutils.h" | ||
34 | #include "mpegvideo.h" | ||
35 | #include "h261.h" | ||
36 | #include "h261enc.h" | ||
37 | #include "mpegvideoenc.h" | ||
38 | #include "put_bits.h" | ||
39 | |||
40 | #define H261_MAX_RUN 26 | ||
41 | #define H261_MAX_LEVEL 15 | ||
42 | #define H261_ESC_LEN (6 + 6 + 8) | ||
43 | #define MV_TAB_OFFSET 32 | ||
44 | |||
45 | static struct VLCLUT { | ||
46 | uint8_t len; | ||
47 | uint16_t code; | ||
48 | } vlc_lut[H261_MAX_RUN + 1][32 /* 0..2 * H261_MAX_LEN are used */]; | ||
49 | |||
50 | // Not const despite never being initialized because doing so would | ||
51 | // put it into .rodata instead of .bss and bloat the binary. | ||
52 | // mv_penalty exists so that the motion estimation code can avoid branches. | ||
53 | static uint8_t mv_penalty[MAX_FCODE + 1][MAX_DMV * 2 + 1]; | ||
54 | static uint8_t uni_h261_rl_len [64 * 128]; | ||
55 | static uint8_t uni_h261_rl_len_last[64 * 128]; | ||
56 | static uint8_t h261_mv_codes[64][2]; | ||
57 | |||
58 | typedef struct H261EncContext { | ||
59 | MPVMainEncContext s; | ||
60 | |||
61 | H261Context common; | ||
62 | |||
63 | int gob_number; | ||
64 | enum { | ||
65 | H261_QCIF = 0, | ||
66 | H261_CIF = 1, | ||
67 | } format; | ||
68 | } H261EncContext; | ||
69 | |||
70 | 300 | static int h261_encode_picture_header(MPVMainEncContext *const m) | |
71 | { | ||
72 | 300 | H261EncContext *const h = (H261EncContext *)m; | |
73 | 300 | MPVEncContext *const s = &h->s.s; | |
74 | int temp_ref; | ||
75 | |||
76 | 300 | put_bits_assume_flushed(&s->pb); | |
77 | |||
78 | 300 | put_bits(&s->pb, 20, 0x10); /* PSC */ | |
79 | |||
80 | 300 | temp_ref = s->c.picture_number * 30000LL * s->c.avctx->time_base.num / | |
81 | 300 | (1001LL * s->c.avctx->time_base.den); // FIXME maybe this should use a timestamp | |
82 | 300 | put_sbits(&s->pb, 5, temp_ref); /* TemporalReference */ | |
83 | |||
84 | 300 | put_bits(&s->pb, 1, 0); /* split screen off */ | |
85 | 300 | put_bits(&s->pb, 1, 0); /* camera off */ | |
86 | 300 | put_bits(&s->pb, 1, s->c.pict_type == AV_PICTURE_TYPE_I); /* freeze picture release on/off */ | |
87 | |||
88 | 300 | put_bits(&s->pb, 1, h->format); /* 0 == QCIF, 1 == CIF */ | |
89 | |||
90 | 300 | put_bits(&s->pb, 1, 1); /* still image mode */ | |
91 | 300 | put_bits(&s->pb, 1, 1); /* reserved */ | |
92 | |||
93 | 300 | put_bits(&s->pb, 1, 0); /* no PEI */ | |
94 | 300 | h->gob_number = h->format - 1; | |
95 | 300 | s->c.mb_skip_run = 0; | |
96 | |||
97 | 300 | return 0; | |
98 | } | ||
99 | |||
100 | /** | ||
101 | * Encode a group of blocks header. | ||
102 | */ | ||
103 | 3600 | static void h261_encode_gob_header(MPVEncContext *const s, int mb_line) | |
104 | { | ||
105 | 3600 | H261EncContext *const h = (H261EncContext *)s; | |
106 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3600 times.
|
3600 | if (h->format == H261_QCIF) { |
107 | ✗ | h->gob_number += 2; // QCIF | |
108 | } else { | ||
109 | 3600 | h->gob_number++; // CIF | |
110 | } | ||
111 | 3600 | put_bits(&s->pb, 16, 1); /* GBSC */ | |
112 | 3600 | put_bits(&s->pb, 4, h->gob_number); /* GN */ | |
113 | 3600 | put_bits(&s->pb, 5, s->c.qscale); /* GQUANT */ | |
114 | 3600 | put_bits(&s->pb, 1, 0); /* no GEI */ | |
115 | 3600 | s->c.mb_skip_run = 0; | |
116 | 3600 | s->c.last_mv[0][0][0] = 0; | |
117 | 3600 | s->c.last_mv[0][0][1] = 0; | |
118 | 3600 | } | |
119 | |||
120 | 118800 | void ff_h261_reorder_mb_index(MPVEncContext *const s) | |
121 | { | ||
122 | 118800 | const H261EncContext *const h = (H261EncContext*)s; | |
123 | 118800 | int index = s->c.mb_x + s->c.mb_y * s->c.mb_width; | |
124 | |||
125 |
2/2✓ Branch 0 taken 10800 times.
✓ Branch 1 taken 108000 times.
|
118800 | if (index % 11 == 0) { |
126 |
2/2✓ Branch 0 taken 3600 times.
✓ Branch 1 taken 7200 times.
|
10800 | if (index % 33 == 0) |
127 | 3600 | h261_encode_gob_header(s, 0); | |
128 | 10800 | s->c.last_mv[0][0][0] = 0; | |
129 | 10800 | s->c.last_mv[0][0][1] = 0; | |
130 | } | ||
131 | |||
132 | /* for CIF the GOB's are fragmented in the middle of a scanline | ||
133 | * that's why we need to adjust the x and y index of the macroblocks */ | ||
134 |
1/2✓ Branch 0 taken 118800 times.
✗ Branch 1 not taken.
|
118800 | if (h->format == H261_CIF) { |
135 | 118800 | s->c.mb_x = index % 11; | |
136 | 118800 | index /= 11; | |
137 | 118800 | s->c.mb_y = index % 3; | |
138 | 118800 | index /= 3; | |
139 | 118800 | s->c.mb_x += 11 * (index % 2); | |
140 | 118800 | index /= 2; | |
141 | 118800 | s->c.mb_y += 3 * index; | |
142 | |||
143 | 118800 | ff_init_block_index(&s->c); | |
144 | 118800 | ff_update_block_index(&s->c, 8, 0, 1); | |
145 | } | ||
146 | 118800 | } | |
147 | |||
148 | 205596 | static void h261_encode_motion(PutBitContext *pb, int val) | |
149 | { | ||
150 | 205596 | put_bits(pb, h261_mv_codes[MV_TAB_OFFSET + val][1], | |
151 | 205596 | h261_mv_codes[MV_TAB_OFFSET + val][0]); | |
152 | 205596 | } | |
153 | |||
154 | 105360 | static inline int get_cbp(const int block_last_index[6]) | |
155 | { | ||
156 | int i, cbp; | ||
157 | 105360 | cbp = 0; | |
158 |
2/2✓ Branch 0 taken 632160 times.
✓ Branch 1 taken 105360 times.
|
737520 | for (i = 0; i < 6; i++) |
159 |
2/2✓ Branch 0 taken 276433 times.
✓ Branch 1 taken 355727 times.
|
632160 | if (block_last_index[i] >= 0) |
160 | 276433 | cbp |= 1 << (5 - i); | |
161 | 105360 | return cbp; | |
162 | } | ||
163 | |||
164 | /** | ||
165 | * Encode an 8x8 block. | ||
166 | * @param block the 8x8 block | ||
167 | * @param n block index (0-3 are luma, 4-5 are chroma) | ||
168 | */ | ||
169 | 796986 | static void h261_encode_block(H261EncContext *h, int16_t *block, int n) | |
170 | { | ||
171 | 796986 | MPVEncContext *const s = &h->s.s; | |
172 | int level, run, i, j, last_index, last_non_zero; | ||
173 | |||
174 |
2/2✓ Branch 0 taken 169980 times.
✓ Branch 1 taken 627006 times.
|
796986 | if (s->c.mb_intra) { |
175 | /* DC coef */ | ||
176 | 169980 | level = block[0]; | |
177 | /* 255 cannot be represented, so we clamp */ | ||
178 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 169980 times.
|
169980 | if (level > 254) { |
179 | ✗ | level = 254; | |
180 | ✗ | block[0] = 254; | |
181 | } | ||
182 | /* 0 cannot be represented also */ | ||
183 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 169980 times.
|
169980 | else if (level < 1) { |
184 | ✗ | level = 1; | |
185 | ✗ | block[0] = 1; | |
186 | } | ||
187 |
2/2✓ Branch 0 taken 2035 times.
✓ Branch 1 taken 167945 times.
|
169980 | if (level == 128) |
188 | 2035 | put_bits(&s->pb, 8, 0xff); | |
189 | else | ||
190 | 167945 | put_bits(&s->pb, 8, level); | |
191 | 169980 | i = 1; | |
192 |
4/4✓ Branch 0 taken 562894 times.
✓ Branch 1 taken 64112 times.
✓ Branch 2 taken 67071 times.
✓ Branch 3 taken 495823 times.
|
627006 | } else if ((block[0] == 1 || block[0] == -1) && |
193 |
2/2✓ Branch 0 taken 92217 times.
✓ Branch 1 taken 38966 times.
|
131183 | (s->c.block_last_index[n] > -1)) { |
194 | // special case | ||
195 |
2/2✓ Branch 0 taken 44668 times.
✓ Branch 1 taken 47549 times.
|
92217 | put_bits(&s->pb, 2, block[0] > 0 ? 2 : 3); |
196 | 92217 | i = 1; | |
197 | } else { | ||
198 | 534789 | i = 0; | |
199 | } | ||
200 | |||
201 | /* AC coefs */ | ||
202 | 796986 | last_index = s->c.block_last_index[n]; | |
203 | 796986 | last_non_zero = i - 1; | |
204 |
2/2✓ Branch 0 taken 8994951 times.
✓ Branch 1 taken 796986 times.
|
9791937 | for (; i <= last_index; i++) { |
205 | 8994951 | j = s->c.intra_scantable.permutated[i]; | |
206 | 8994951 | level = block[j]; | |
207 |
2/2✓ Branch 0 taken 2936627 times.
✓ Branch 1 taken 6058324 times.
|
8994951 | if (level) { |
208 | 2936627 | run = i - last_non_zero - 1; | |
209 | |||
210 |
2/2✓ Branch 0 taken 2928932 times.
✓ Branch 1 taken 7695 times.
|
2936627 | if (run <= H261_MAX_RUN && |
211 |
2/2✓ Branch 0 taken 2925517 times.
✓ Branch 1 taken 3415 times.
|
2928932 | (unsigned)(level + H261_MAX_LEVEL) <= 2 * H261_MAX_LEVEL && |
212 |
2/2✓ Branch 0 taken 2894680 times.
✓ Branch 1 taken 30837 times.
|
2925517 | vlc_lut[run][level + H261_MAX_LEVEL].len) { |
213 | 2894680 | put_bits(&s->pb, vlc_lut[run][level + H261_MAX_LEVEL].len, | |
214 | 2894680 | vlc_lut[run][level + H261_MAX_LEVEL].code); | |
215 | } else { | ||
216 | /* Escape */ | ||
217 | 41947 | put_bits(&s->pb, 6 + 6, (1 << 6) | run); | |
218 | av_assert1(level != 0); | ||
219 | av_assert1(FFABS(level) <= 127); | ||
220 | 41947 | put_sbits(&s->pb, 8, level); | |
221 | } | ||
222 | 2936627 | last_non_zero = i; | |
223 | } | ||
224 | } | ||
225 |
2/2✓ Branch 0 taken 446413 times.
✓ Branch 1 taken 350573 times.
|
796986 | if (last_index > -1) |
226 | 446413 | put_bits(&s->pb, 2, 0x2); // EOB | |
227 | 796986 | } | |
228 | |||
229 | 133690 | static void h261_encode_mb(MPVEncContext *const s, int16_t block[6][64], | |
230 | int motion_x, int motion_y) | ||
231 | { | ||
232 | /* The following is only allowed because this encoder | ||
233 | * does not use slice threading. */ | ||
234 | 133690 | H261EncContext *const h = (H261EncContext *)s; | |
235 | 133690 | H261Context *const com = &h->common; | |
236 | int mvd, mv_diff_x, mv_diff_y, i, cbp; | ||
237 | 133690 | cbp = 63; // avoid warning | |
238 | 133690 | mvd = 0; | |
239 | |||
240 | 133690 | com->mtype = 0; | |
241 | |||
242 |
2/2✓ Branch 0 taken 105360 times.
✓ Branch 1 taken 28330 times.
|
133690 | if (!s->c.mb_intra) { |
243 | /* compute cbp */ | ||
244 | 105360 | cbp = get_cbp(s->c.block_last_index); | |
245 | |||
246 | /* mvd indicates if this block is motion compensated */ | ||
247 | 105360 | mvd = motion_x | motion_y; | |
248 | |||
249 |
2/2✓ Branch 0 taken 859 times.
✓ Branch 1 taken 104501 times.
|
105360 | if ((cbp | mvd) == 0) { |
250 | /* skip macroblock */ | ||
251 | 859 | s->c.mb_skip_run++; | |
252 | 859 | s->c.last_mv[0][0][0] = 0; | |
253 | 859 | s->c.last_mv[0][0][1] = 0; | |
254 | 859 | s->c.qscale -= s->dquant; | |
255 | 859 | return; | |
256 | } | ||
257 | } | ||
258 | |||
259 | /* MB is not skipped, encode MBA */ | ||
260 | 132831 | put_bits(&s->pb, | |
261 | 132831 | ff_h261_mba_bits[s->c.mb_skip_run], | |
262 | 132831 | ff_h261_mba_code[s->c.mb_skip_run]); | |
263 | 132831 | s->c.mb_skip_run = 0; | |
264 | |||
265 | /* calculate MTYPE */ | ||
266 |
2/2✓ Branch 0 taken 104501 times.
✓ Branch 1 taken 28330 times.
|
132831 | if (!s->c.mb_intra) { |
267 | 104501 | com->mtype++; | |
268 | |||
269 |
4/4✓ Branch 0 taken 3516 times.
✓ Branch 1 taken 100985 times.
✓ Branch 2 taken 1813 times.
✓ Branch 3 taken 1703 times.
|
104501 | if (mvd || s->c.loop_filter) |
270 | 102798 | com->mtype += 3; | |
271 |
2/2✓ Branch 0 taken 51663 times.
✓ Branch 1 taken 52838 times.
|
104501 | if (s->c.loop_filter) |
272 | 51663 | com->mtype += 3; | |
273 |
2/2✓ Branch 0 taken 85004 times.
✓ Branch 1 taken 19497 times.
|
104501 | if (cbp) |
274 | 85004 | com->mtype++; | |
275 | av_assert1(com->mtype > 1); | ||
276 | } | ||
277 | |||
278 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 132831 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
132831 | if (s->dquant && cbp) { |
279 | ✗ | com->mtype++; | |
280 | } else | ||
281 | 132831 | s->c.qscale -= s->dquant; | |
282 | |||
283 | 132831 | put_bits(&s->pb, | |
284 | 132831 | ff_h261_mtype_bits[com->mtype], | |
285 | 132831 | ff_h261_mtype_code[com->mtype]); | |
286 | |||
287 | 132831 | com->mtype = ff_h261_mtype_map[com->mtype]; | |
288 | |||
289 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 132831 times.
|
132831 | if (IS_QUANT(com->mtype)) { |
290 | ✗ | ff_set_qscale(&s->c, s->c.qscale + s->dquant); | |
291 | ✗ | put_bits(&s->pb, 5, s->c.qscale); | |
292 | } | ||
293 | |||
294 |
2/2✓ Branch 0 taken 102798 times.
✓ Branch 1 taken 30033 times.
|
132831 | if (IS_16X16(com->mtype)) { |
295 | 102798 | mv_diff_x = (motion_x >> 1) - s->c.last_mv[0][0][0]; | |
296 | 102798 | mv_diff_y = (motion_y >> 1) - s->c.last_mv[0][0][1]; | |
297 | 102798 | s->c.last_mv[0][0][0] = (motion_x >> 1); | |
298 | 102798 | s->c.last_mv[0][0][1] = (motion_y >> 1); | |
299 | 102798 | h261_encode_motion(&s->pb, mv_diff_x); | |
300 | 102798 | h261_encode_motion(&s->pb, mv_diff_y); | |
301 | } | ||
302 | |||
303 |
2/2✓ Branch 0 taken 85004 times.
✓ Branch 1 taken 47827 times.
|
132831 | if (HAS_CBP(com->mtype)) { |
304 | av_assert1(cbp > 0); | ||
305 | 85004 | put_bits(&s->pb, | |
306 | 85004 | ff_h261_cbp_tab[cbp - 1][1], | |
307 | 85004 | ff_h261_cbp_tab[cbp - 1][0]); | |
308 | } | ||
309 |
2/2✓ Branch 0 taken 796986 times.
✓ Branch 1 taken 132831 times.
|
929817 | for (i = 0; i < 6; i++) |
310 | /* encode each block */ | ||
311 | 796986 | h261_encode_block(h, block[i], i); | |
312 | |||
313 |
2/2✓ Branch 0 taken 30033 times.
✓ Branch 1 taken 102798 times.
|
132831 | if (!IS_16X16(com->mtype)) { |
314 | 30033 | s->c.last_mv[0][0][0] = 0; | |
315 | 30033 | s->c.last_mv[0][0][1] = 0; | |
316 | } | ||
317 | } | ||
318 | |||
319 | 6 | static av_cold void h261_encode_init_static(void) | |
320 | { | ||
321 | 6 | uint8_t (*const mv_codes)[2] = h261_mv_codes + MV_TAB_OFFSET; | |
322 | 6 | memset(uni_h261_rl_len, H261_ESC_LEN, sizeof(uni_h261_rl_len)); | |
323 | 6 | memset(uni_h261_rl_len_last, H261_ESC_LEN + 2 /* EOB */, sizeof(uni_h261_rl_len_last)); | |
324 | |||
325 | // The following loop is over the ordinary elements, not EOB or escape. | ||
326 |
2/2✓ Branch 0 taken 378 times.
✓ Branch 1 taken 6 times.
|
384 | for (size_t i = 1; i < FF_ARRAY_ELEMS(ff_h261_tcoeff_vlc) - 1; i++) { |
327 | 378 | unsigned run = ff_h261_tcoeff_run[i]; | |
328 | 378 | unsigned level = ff_h261_tcoeff_level[i]; | |
329 | 378 | unsigned len = ff_h261_tcoeff_vlc[i][1] + 1 /* sign */; | |
330 | 378 | unsigned code = ff_h261_tcoeff_vlc[i][0]; | |
331 | |||
332 | 378 | vlc_lut[run][H261_MAX_LEVEL + level] = (struct VLCLUT){ len, code << 1 }; | |
333 | 378 | vlc_lut[run][H261_MAX_LEVEL - level] = (struct VLCLUT){ len, (code << 1) | 1 }; | |
334 | |||
335 | 378 | uni_h261_rl_len [UNI_AC_ENC_INDEX(run, 64 + level)] = len; | |
336 | 378 | uni_h261_rl_len [UNI_AC_ENC_INDEX(run, 64 - level)] = len; | |
337 | 378 | uni_h261_rl_len_last[UNI_AC_ENC_INDEX(run, 64 + level)] = len + 2; | |
338 | 378 | uni_h261_rl_len_last[UNI_AC_ENC_INDEX(run, 64 - level)] = len + 2; | |
339 | } | ||
340 | |||
341 | 6 | for (ptrdiff_t i = 1;; i++) { | |
342 | // sign-one MV codes; diff -16..-1, 16..31 | ||
343 | 96 | mv_codes[32 - i][0] = mv_codes[-i][0] = (ff_h261_mv_tab[i][0] << 1) | 1 /* sign */; | |
344 | 96 | mv_codes[32 - i][1] = mv_codes[-i][1] = ff_h261_mv_tab[i][1] + 1; | |
345 |
2/2✓ Branch 0 taken 6 times.
✓ Branch 1 taken 90 times.
|
96 | if (i == 16) |
346 | 6 | break; | |
347 | // sign-zero MV codes: diff -31..-17, 1..15 | ||
348 | 90 | mv_codes[i][0] = mv_codes[i - 32][0] = ff_h261_mv_tab[i][0] << 1; | |
349 | 90 | mv_codes[i][1] = mv_codes[i - 32][1] = ff_h261_mv_tab[i][1] + 1; | |
350 | } | ||
351 | // MV code for difference zero; has no sign | ||
352 | 6 | mv_codes[0][0] = 1; | |
353 | 6 | mv_codes[0][1] = 1; | |
354 | 6 | } | |
355 | |||
356 | 6 | static av_cold int h261_encode_init(AVCodecContext *avctx) | |
357 | { | ||
358 | static AVOnce init_static_once = AV_ONCE_INIT; | ||
359 | 6 | H261EncContext *const h = avctx->priv_data; | |
360 | 6 | MPVEncContext *const s = &h->s.s; | |
361 | |||
362 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
6 | if (avctx->width == 176 && avctx->height == 144) { |
363 | ✗ | h->format = H261_QCIF; | |
364 |
2/4✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
|
6 | } else if (avctx->width == 352 && avctx->height == 288) { |
365 | 6 | h->format = H261_CIF; | |
366 | } else { | ||
367 | ✗ | av_log(avctx, AV_LOG_ERROR, | |
368 | "The specified picture size of %dx%d is not valid for the " | ||
369 | "H.261 codec.\nValid sizes are 176x144, 352x288\n", | ||
370 | avctx->width, avctx->height); | ||
371 | ✗ | return AVERROR(EINVAL); | |
372 | } | ||
373 | 6 | s->c.private_ctx = &h->common; | |
374 | 6 | h->s.encode_picture_header = h261_encode_picture_header; | |
375 | 6 | s->encode_mb = h261_encode_mb; | |
376 | |||
377 | 6 | s->min_qcoeff = -127; | |
378 | 6 | s->max_qcoeff = 127; | |
379 | 6 | s->ac_esc_length = H261_ESC_LEN; | |
380 | |||
381 | 6 | s->me.mv_penalty = mv_penalty; | |
382 | |||
383 | 6 | s->intra_ac_vlc_length = s->inter_ac_vlc_length = uni_h261_rl_len; | |
384 | 6 | s->intra_ac_vlc_last_length = s->inter_ac_vlc_last_length = uni_h261_rl_len_last; | |
385 | 6 | ff_thread_once(&init_static_once, h261_encode_init_static); | |
386 | |||
387 | 6 | return ff_mpv_encode_init(avctx); | |
388 | } | ||
389 | |||
390 | const FFCodec ff_h261_encoder = { | ||
391 | .p.name = "h261", | ||
392 | CODEC_LONG_NAME("H.261"), | ||
393 | .p.type = AVMEDIA_TYPE_VIDEO, | ||
394 | .p.id = AV_CODEC_ID_H261, | ||
395 | .p.priv_class = &ff_mpv_enc_class, | ||
396 | .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, | ||
397 | .priv_data_size = sizeof(H261EncContext), | ||
398 | .init = h261_encode_init, | ||
399 | FF_CODEC_ENCODE_CB(ff_mpv_encode_picture), | ||
400 | .close = ff_mpv_encode_end, | ||
401 | .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, | ||
402 | CODEC_PIXFMTS(AV_PIX_FMT_YUV420P), | ||
403 | .color_ranges = AVCOL_RANGE_MPEG, | ||
404 | }; | ||
405 |