FFmpeg
Loading...
Searching...
No Matches
h261dec.c
Go to the documentation of this file.
1/*
2 * H.261 decoder
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 decoder.
26 */
27
29#include "libavutil/thread.h"
30#include "avcodec.h"
31#include "codec_internal.h"
32#include "decode.h"
33#include "get_bits.h"
34#include "mpeg_er.h"
35#include "mpegutils.h"
36#include "mpegvideo.h"
37#include "mpegvideodec.h"
38#include "h261.h"
39
40#define SLICE_OK 0
41#define SLICE_ERROR -1
42#define SLICE_END -2 ///<end marker found
43
44#define H261_MBA_VLC_BITS 8
45#define H261_MTYPE_VLC_BITS 6
46#define H261_MV_VLC_BITS 7
47#define H261_CBP_VLC_BITS 9
48#define TCOEFF_VLC_BITS 9
49#define MBA_STUFFING 33
50#define MBA_STARTCODE 34
51
54static VLCElem h261_mv_vlc[144];
56
57typedef struct H261DecContext {
59
61
67 int gob_start_code_skipped; // 1 if gob start code is already read before gob header is read
68
69 DECLARE_ALIGNED_32(int16_t, block)[6][64];
71
89
91{
92 static AVOnce init_static_once = AV_ONCE_INIT;
93 H261DecContext *const h = avctx->priv_data;
94 MpegEncContext *const s = &h->s;
95 int ret;
96
97 avctx->framerate = (AVRational) { 30000, 1001 };
98
99 /* The H.261 analog of intra/key frames is setting the freeze picture release flag,
100 * but this does not guarantee that the frame uses intra-only encoding,
101 * so we still need to allocate dummy frames. So set pict_type to P here
102 * for all frames and override it after having decoded the frame. */
103 s->pict_type = AV_PICTURE_TYPE_P;
104
105 // set defaults
106 ret = ff_mpv_decode_init(s, avctx);
107 if (ret < 0)
108 return ret;
109
110 s->out_format = FMT_H261;
111 s->low_delay = 1;
113
114 ff_thread_once(&init_static_once, h261_decode_init_static);
115
116 return 0;
117}
118
119static inline void h261_init_dest(MpegEncContext *s)
120{
121 const unsigned block_size = 8 >> s->avctx->lowres;
123 s->dest[0] += 2 * block_size;
124 s->dest[1] += block_size;
125 s->dest[2] += block_size;
126}
127
128/**
129 * Decode the group of blocks header or slice header.
130 * @return <0 if an error occurred
131 */
133{
134 unsigned int val;
135 MpegEncContext *const s = &h->s;
136
137 if (!h->gob_start_code_skipped) {
138 /* Check for GOB Start Code */
139 val = show_bits(&h->gb, 15);
140 if (val)
141 return -1;
142
143 /* We have a GBSC */
144 skip_bits(&h->gb, 16);
145 }
146
147 h->gob_start_code_skipped = 0;
148
149 h->gob_number = get_bits(&h->gb, 4); /* GN */
150 s->qscale = get_bits(&h->gb, 5); /* GQUANT */
151
152 /* Check if gob_number is valid */
153 if (s->mb_height == 18) { // CIF
154 if ((h->gob_number <= 0) || (h->gob_number > 12))
155 return -1;
156 } else { // QCIF
157 if ((h->gob_number != 1) && (h->gob_number != 3) &&
158 (h->gob_number != 5))
159 return -1;
160 }
161
162 /* GEI */
163 if (skip_1stop_8data_bits(&h->gb) < 0)
164 return AVERROR_INVALIDDATA;
165
166 if (s->qscale == 0) {
167 av_log(s->avctx, AV_LOG_ERROR, "qscale has forbidden 0 value\n");
168 if (s->avctx->err_recognition & (AV_EF_BITSTREAM | AV_EF_COMPLIANT))
169 return -1;
170 s->qscale = 1;
171 }
172
173 /* For the first transmitted macroblock in a GOB, MBA is the absolute
174 * address. For subsequent macroblocks, MBA is the difference between
175 * the absolute addresses of the macroblock and the last transmitted
176 * macroblock. */
177 h->current_mba = 0;
178 h->mba_diff = 0;
179
180 return 0;
181}
182
183/**
184 * Decode skipped macroblocks.
185 */
186static void h261_decode_mb_skipped(H261DecContext *h, int mba1, int mba2)
187{
188 MpegEncContext *const s = &h->s;
189 int i;
190
191 s->mb_intra = 0;
192
193 for (i = mba1; i < mba2; i++) {
194 int j, xy;
195
196 s->mb_x = ((h->gob_number - 1) % 2) * 11 + i % 11;
197 s->mb_y = ((h->gob_number - 1) / 2) * 3 + i / 11;
198 xy = s->mb_x + s->mb_y * s->mb_stride;
200
201 for (j = 0; j < 6; j++)
202 s->block_last_index[j] = -1;
203
204 s->mv_dir = MV_DIR_FORWARD;
205 s->mv_type = MV_TYPE_16X16;
206 s->cur_pic.mb_type[xy] = MB_TYPE_SKIP | MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
207 s->mv[0][0][0] = 0;
208 s->mv[0][0][1] = 0;
209 s->mb_skipped = 1;
210 s->mtype &= ~MB_TYPE_H261_FIL;
211
212 if (s->cur_pic.motion_val[0]) {
213 int b_stride = 2*s->mb_width + 1;
214 int b_xy = 2 * s->mb_x + (2 * s->mb_y) * b_stride;
215 s->cur_pic.motion_val[0][b_xy][0] = s->mv[0][0][0];
216 s->cur_pic.motion_val[0][b_xy][1] = s->mv[0][0][1];
217 }
218
219 ff_mpv_reconstruct_mb(s, h->block);
220 }
221}
222
223static int decode_mv_component(GetBitContext *gb, int v)
224{
225 int mv_diff = get_vlc2(gb, h261_mv_vlc, H261_MV_VLC_BITS, 2);
226
227 /* check if mv_diff is valid */
228 if (mv_diff < 0)
229 return v;
230
231 if (mv_diff && get_bits1(gb))
232 mv_diff = -mv_diff;
233
234 v += mv_diff;
235 if (v <= -16)
236 v += 32;
237 else if (v >= 16)
238 v -= 32;
239
240 return v;
241}
242
243/**
244 * Decode a macroblock.
245 * @return <0 if an error occurred
246 */
247static int h261_decode_block(H261DecContext *h, int16_t *block, int n, int coded)
248{
249 MpegEncContext *const s = &h->s;
250 int level, i, j, run;
251 const RLTable *rl = &ff_h261_rl_tcoeff;
252 const uint8_t *scan_table;
253 const int qmul = s->qscale << 1, qadd = (s->qscale - 1) | 1;
254
255 /* For the variable length encoding there are two code tables, one being
256 * used for the first transmitted LEVEL in INTER, INTER + MC and
257 * INTER + MC + FIL blocks, the second for all other LEVELs except the
258 * first one in INTRA blocks which is fixed length coded with 8 bits.
259 * NOTE: The two code tables only differ in one VLC so we handle that
260 * manually. */
261 scan_table = s->intra_scantable.permutated;
262 if (s->mb_intra) {
263 /* DC coef */
264 level = get_bits(&h->gb, 8);
265 // 0 (00000000b) and -128 (10000000b) are FORBIDDEN
266 if ((level & 0x7F) == 0) {
267 av_log(s->avctx, AV_LOG_ERROR, "illegal dc %d at %d %d\n",
268 level, s->mb_x, s->mb_y);
269 return -1;
270 }
271 /* The code 1000 0000 is not used, the reconstruction level of 1024
272 * being coded as 1111 1111. */
273 if (level == 255)
274 level = 128;
275 block[0] = level * 8;
276 i = 1;
277 } else if (coded) {
278 // Run Level Code
279 // EOB Not possible for first level when cbp is available (that's why the table is different)
280 // 0 1 1s
281 // * * 0*
282 int check = show_bits(&h->gb, 2);
283 i = 0;
284 if (check & 0x2) {
285 skip_bits(&h->gb, 2);
286 block[0] = qmul + qadd;
287 block[0] *= (check & 0x1) ? -1 : 1;
288 i = 1;
289 }
290 } else {
291 i = 0;
292 }
293 if (!coded) {
294 s->block_last_index[n] = i - 1;
295 return 0;
296 }
297 {
298 OPEN_READER(re, &h->gb);
299 i--; // offset by -1 to allow direct indexing of scan_table
300 for (;;) {
301 UPDATE_CACHE(re, &h->gb);
302 GET_RL_VLC(level, run, re, &h->gb, rl->rl_vlc[0], TCOEFF_VLC_BITS, 2, 0);
303 if (run == 66) {
304 if (level) {
305 CLOSE_READER(re, &h->gb);
306 av_log(s->avctx, AV_LOG_ERROR, "illegal ac vlc code at %dx%d\n",
307 s->mb_x, s->mb_y);
308 return -1;
309 }
310 /* escape */
311 /* The remaining combinations of (run, level) are encoded with a
312 * 20-bit word consisting of 6 bits escape, 6 bits run and 8 bits
313 * level. */
314 run = SHOW_UBITS(re, &h->gb, 6) + 1;
315 SKIP_CACHE(re, &h->gb, 6);
316 level = SHOW_SBITS(re, &h->gb, 8);
317 if (level > 0)
318 level = level * qmul + qadd;
319 else if (level < 0)
320 level = level * qmul - qadd;
321 SKIP_COUNTER(re, &h->gb, 6 + 8);
322 } else if (level == 0) {
323 break;
324 } else {
325 level = level * qmul + qadd;
326 if (SHOW_UBITS(re, &h->gb, 1))
327 level = -level;
328 SKIP_COUNTER(re, &h->gb, 1);
329 }
330 i += run;
331 if (i >= 64) {
332 CLOSE_READER(re, &h->gb);
333 av_log(s->avctx, AV_LOG_ERROR, "run overflow at %dx%d\n",
334 s->mb_x, s->mb_y);
335 return -1;
336 }
337 j = scan_table[i];
338 block[j] = level;
339 }
340 CLOSE_READER(re, &h->gb);
341 }
342 s->block_last_index[n] = i;
343 return 0;
344}
345
347{
348 MpegEncContext *const s = &h->s;
349 int i, cbp, xy;
350
351 cbp = 63;
352 // Read mba
353 do {
354 h->mba_diff = get_vlc2(&h->gb, h261_mba_vlc,
356
357 /* Check for slice end */
358 /* NOTE: GOB can be empty (no MB data) or exist only of MBA_stuffing */
359 if (h->mba_diff == MBA_STARTCODE) { // start code
360 h->gob_start_code_skipped = 1;
361 return SLICE_END;
362 }
363 } while (h->mba_diff == MBA_STUFFING); // stuffing
364
365 if (h->mba_diff < 0) {
366 if (get_bits_left(&h->gb) <= 7)
367 return SLICE_END;
368
369 av_log(s->avctx, AV_LOG_ERROR, "illegal mba at %d %d\n", s->mb_x, s->mb_y);
370 return SLICE_ERROR;
371 }
372
373 h->mba_diff += 1;
374 h->current_mba += h->mba_diff;
375
376 if (h->current_mba > MBA_STUFFING)
377 return SLICE_ERROR;
378
379 s->mb_x = ((h->gob_number - 1) % 2) * 11 + ((h->current_mba - 1) % 11);
380 s->mb_y = ((h->gob_number - 1) / 2) * 3 + ((h->current_mba - 1) / 11);
381 xy = s->mb_x + s->mb_y * s->mb_stride;
383
384 // Read mtype
385 s->mtype = get_vlc2(&h->gb, h261_mtype_vlc, H261_MTYPE_VLC_BITS, 2);
386 if (s->mtype < 0) {
387 av_log(s->avctx, AV_LOG_ERROR, "Invalid mtype index\n");
388 return SLICE_ERROR;
389 }
390
391 // Read mquant
392 if (IS_QUANT(s->mtype)) {
393 s->qscale = get_bits(&h->gb, 5);
394 if (!s->qscale)
395 s->qscale = 1;
396 }
397
398 s->mb_intra = IS_INTRA4x4(s->mtype);
399
400 // Read mv
401 if (IS_16X16(s->mtype)) {
402 /* Motion vector data is included for all MC macroblocks. MVD is
403 * obtained from the macroblock vector by subtracting the vector
404 * of the preceding macroblock. For this calculation the vector
405 * of the preceding macroblock is regarded as zero in the
406 * following three situations:
407 * 1) evaluating MVD for macroblocks 1, 12 and 23;
408 * 2) evaluating MVD for macroblocks in which MBA does not represent a difference of 1;
409 * 3) MTYPE of the previous macroblock was not MC. */
410 if ((h->current_mba == 1) || (h->current_mba == 12) ||
411 (h->current_mba == 23) || (h->mba_diff != 1)) {
412 h->current_mv_x = 0;
413 h->current_mv_y = 0;
414 }
415
416 h->current_mv_x = decode_mv_component(&h->gb, h->current_mv_x);
417 h->current_mv_y = decode_mv_component(&h->gb, h->current_mv_y);
418 } else {
419 h->current_mv_x = 0;
420 h->current_mv_y = 0;
421 }
422
423 // Read cbp
424 if (HAS_CBP(s->mtype))
425 cbp = get_vlc2(&h->gb, h261_cbp_vlc, H261_CBP_VLC_BITS, 1) + 1;
426
427 if (s->mb_intra) {
428 s->cur_pic.mb_type[xy] = MB_TYPE_INTRA;
429 goto intra;
430 }
431
432 //set motion vectors
433 s->mv_dir = MV_DIR_FORWARD;
434 s->mv_type = MV_TYPE_16X16;
435 s->cur_pic.mb_type[xy] = MB_TYPE_16x16 | MB_TYPE_FORWARD_MV;
436 s->mv[0][0][0] = h->current_mv_x * 2; // gets divided by 2 in motion compensation
437 s->mv[0][0][1] = h->current_mv_y * 2;
438
439 if (s->cur_pic.motion_val[0]) {
440 int b_stride = 2*s->mb_width + 1;
441 int b_xy = 2 * s->mb_x + (2 * s->mb_y) * b_stride;
442 s->cur_pic.motion_val[0][b_xy][0] = s->mv[0][0][0];
443 s->cur_pic.motion_val[0][b_xy][1] = s->mv[0][0][1];
444 }
445
446intra:
447 /* decode each block */
448 if (s->mb_intra || HAS_CBP(s->mtype)) {
449 s->bdsp.clear_blocks(h->block[0]);
450 for (i = 0; i < 6; i++) {
451 if (h261_decode_block(h, h->block[i], i, cbp & 32) < 0)
452 return SLICE_ERROR;
453 cbp += cbp;
454 }
455 } else {
456 for (i = 0; i < 6; i++)
457 s->block_last_index[i] = -1;
458 }
459
460 ff_mpv_reconstruct_mb(s, h->block);
461
462 return SLICE_OK;
463}
464
465/**
466 * Decode the H.261 picture header.
467 * @return <0 if no startcode found
468 */
470{
471 MpegEncContext *const s = &h->s;
472 uint32_t startcode = 0;
473
474 for (int i = get_bits_left(&h->gb); i > 24; i -= 1) {
475 startcode = ((startcode << 1) | get_bits(&h->gb, 1)) & 0x000FFFFF;
476
477 if (startcode == 0x10)
478 break;
479 }
480
481 if (startcode != 0x10) {
482 av_log(s->avctx, AV_LOG_ERROR, "Bad picture start code\n");
483 return -1;
484 }
485
486 /* temporal reference */
487 skip_bits(&h->gb, 5); /* picture timestamp */
488
489 /* PTYPE starts here */
490 skip_bits1(&h->gb); /* split screen off */
491 skip_bits1(&h->gb); /* camera off */
492 *is_key = get_bits1(&h->gb); /* freeze picture release off */
493
494 int format = get_bits1(&h->gb);
495
496 // only 2 formats possible
497 if (format == 0) { // QCIF
498 s->width = 176;
499 s->height = 144;
500 } else { // CIF
501 s->width = 352;
502 s->height = 288;
503 }
504
505 skip_bits1(&h->gb); /* still image mode off */
506 skip_bits1(&h->gb); /* Reserved */
507
508 /* PEI */
509 if (skip_1stop_8data_bits(&h->gb) < 0)
510 return AVERROR_INVALIDDATA;
511
512 h->gob_number = 0;
513 return 0;
514}
515
517{
518 MpegEncContext *const s = &h->s;
519
520 /* decode mb's */
521 while (h->current_mba <= MBA_STUFFING) {
522 int ret;
523 /* DCT & quantize */
524 ret = h261_decode_mb(h);
525 if (ret < 0) {
526 if (ret == SLICE_END) {
527 h261_decode_mb_skipped(h, h->current_mba, 33);
528 return 0;
529 }
530 av_log(s->avctx, AV_LOG_ERROR, "Error at MB: %d\n",
531 s->mb_x + s->mb_y * s->mb_stride);
532 return -1;
533 }
534
536 h->current_mba - h->mba_diff,
537 h->current_mba - 1);
538 }
539
540 return -1;
541}
542
543static int h261_decode_frame(AVCodecContext *avctx, AVFrame *pict,
544 int *got_frame, AVPacket *avpkt)
545{
546 H261DecContext *const h = avctx->priv_data;
547 const uint8_t *buf = avpkt->data;
548 int buf_size = avpkt->size;
549 MpegEncContext *s = &h->s;
550 int ret, is_key;
551
552 ff_dlog(avctx, "*****frame %"PRId64" size=%d\n", avctx->frame_num, buf_size);
553 ff_dlog(avctx, "bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]);
554
555 h->gob_start_code_skipped = 0;
556
557 init_get_bits(&h->gb, buf, buf_size * 8);
558
559 ret = h261_decode_picture_header(h, &is_key);
560
561 /* skip if the header was thrashed */
562 if (ret < 0) {
563 av_log(s->avctx, AV_LOG_ERROR, "header damaged\n");
564 return -1;
565 }
566
567 if (s->width != avctx->coded_width || s->height != avctx->coded_height) {
569 }
570
571 if (!s->context_initialized) {
572 if ((ret = ff_mpv_common_init(s)) < 0)
573 return ret;
574
575 ret = ff_set_dimensions(avctx, s->width, s->height);
576 if (ret < 0)
577 return ret;
578 }
579
580 if ((avctx->skip_frame >= AVDISCARD_NONINTRA && !is_key) ||
581 avctx->skip_frame >= AVDISCARD_ALL)
582 return buf_size;
583
584 if (ff_mpv_frame_start(s, avctx) < 0)
585 return -1;
586
588
589 /* decode each macroblock */
590 s->mb_x = 0;
591 s->mb_y = 0;
592
593 while (h->gob_number < (s->mb_height == 18 ? 12 : 5)) {
594 if (h261_decode_gob_header(h) < 0)
595 break;
597 }
599
600 if (is_key) {
601 s->cur_pic.ptr->f->pict_type = AV_PICTURE_TYPE_I;
602 s->cur_pic.ptr->f->flags |= AV_FRAME_FLAG_KEY;
603 }
604
605 if ((ret = av_frame_ref(pict, s->cur_pic.ptr->f)) < 0)
606 return ret;
607 ff_print_debug_info(s, s->cur_pic.ptr, pict);
608
609 *got_frame = 1;
610
611 return buf_size;
612}
613
615 .p.name = "h261",
616 CODEC_LONG_NAME("H.261"),
617 .p.type = AVMEDIA_TYPE_VIDEO,
618 .p.id = AV_CODEC_ID_H261,
619 .priv_data_size = sizeof(H261DecContext),
622 .close = ff_mpv_decode_close,
623 .p.capabilities = AV_CODEC_CAP_DR1,
624 .p.max_lowres = 3,
625 .caps_internal = FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM,
626};
static double val(void *priv, double ch)
Definition aeval.c:77
static const char *const format[]
Definition af_aiir.c:444
const FFCodec ff_h261_decoder
Definition h261dec.c:614
Libavcodec external API header.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
The decoder extracts and fills its parameters even if the frame is skipped due to the skip_frame sett...
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
static int16_t block[64]
Definition dct.c:125
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Definition utils.c:91
#define AV_EF_BITSTREAM
detect bitstream specification deviations
Definition defs.h:49
#define AV_EF_COMPLIANT
consider all spec non compliances as errors
Definition defs.h:55
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
bitstream reader API header.
static av_always_inline int get_vlc2(GetBitContext *s, const VLCElem *table, int bits, int max_depth)
Parse a vlc code.
Definition get_bits.h:645
#define SKIP_CACHE(name, gb, num)
Definition get_bits.h:216
#define CLOSE_READER(name, gb)
Definition get_bits.h:189
static int get_bits_left(GetBitContext *gb)
Definition get_bits.h:688
#define SHOW_UBITS(name, gb, num)
Definition get_bits.h:247
static unsigned int get_bits1(GetBitContext *s)
Definition get_bits.h:391
#define SHOW_SBITS(name, gb, num)
Definition get_bits.h:248
#define OPEN_READER(name, gb)
Definition get_bits.h:182
static void skip_bits(GetBitContext *s, int n)
Definition get_bits.h:383
static int skip_1stop_8data_bits(GetBitContext *gb)
Definition get_bits.h:693
#define GET_RL_VLC(level, run, name, gb, table, bits, max_depth, need_update)
Definition get_bits.h:602
#define UPDATE_CACHE(name, gb)
Definition get_bits.h:213
static void skip_bits1(GetBitContext *s)
Definition get_bits.h:416
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
Definition get_bits.h:337
#define SKIP_COUNTER(name, gb, num)
Definition get_bits.h:223
static unsigned int show_bits(GetBitContext *s, int n)
Show 1-25 bits.
Definition get_bits.h:373
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Definition get_bits.h:517
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
@ AV_CODEC_ID_H261
Definition codec_id.h:53
@ AVDISCARD_ALL
discard all
Definition defs.h:232
@ AVDISCARD_NONINTRA
discard all non intra frames
Definition defs.h:230
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition error.h:61
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
Definition frame.h:687
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
Definition frame.c:278
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
@ AV_PICTURE_TYPE_I
Intra.
Definition avutil.h:278
@ AV_PICTURE_TYPE_P
Predicted.
Definition avutil.h:279
H.261 codec.
RLTable ff_h261_rl_tcoeff
Definition h261data.c:150
const uint16_t ff_h261_mtype_map[10]
Definition h261data.c:75
const uint8_t ff_h261_mv_tab[17][2]
Definition h261data.c:89
const uint8_t ff_h261_mtype_bits[10]
Definition h261data.c:69
#define MB_TYPE_H261_FIL
Definition h261.h:34
const uint8_t ff_h261_mtype_code[10]
Definition h261data.c:63
const uint8_t ff_h261_mba_code[35]
Definition h261data.c:34
const uint8_t ff_h261_cbp_tab[63][2]
Definition h261data.c:95
const uint8_t ff_h261_mba_bits[35]
Definition h261data.c:48
static int h261_decode_frame(AVCodecContext *avctx, AVFrame *pict, int *got_frame, AVPacket *avpkt)
Definition h261dec.c:543
static int h261_decode_gob(H261DecContext *h)
Definition h261dec.c:516
static VLCElem h261_mtype_vlc[80]
Definition h261dec.c:53
static int h261_decode_mb(H261DecContext *h)
Definition h261dec.c:346
#define H261_MTYPE_VLC_BITS
Definition h261dec.c:45
static VLCElem h261_cbp_vlc[512]
Definition h261dec.c:55
#define TCOEFF_VLC_BITS
Definition h261dec.c:48
#define H261_MBA_VLC_BITS
Definition h261dec.c:44
#define SLICE_END
end marker found
Definition h261dec.c:42
static int h261_decode_picture_header(H261DecContext *h, int *is_key)
Decode the H.261 picture header.
Definition h261dec.c:469
static void h261_init_dest(MpegEncContext *s)
Definition h261dec.c:119
static av_cold int h261_decode_init(AVCodecContext *avctx)
Definition h261dec.c:90
#define H261_CBP_VLC_BITS
Definition h261dec.c:47
static av_cold void h261_decode_init_static(void)
Definition h261dec.c:72
#define H261_MV_VLC_BITS
Definition h261dec.c:46
#define SLICE_OK
Definition h261dec.c:40
static int h261_decode_gob_header(H261DecContext *h)
Decode the group of blocks header or slice header.
Definition h261dec.c:132
#define MBA_STUFFING
Definition h261dec.c:49
#define MBA_STARTCODE
Definition h261dec.c:50
static VLCElem h261_mv_vlc[144]
Definition h261dec.c:54
static int h261_decode_block(H261DecContext *h, int16_t *block, int n, int coded)
Decode a macroblock.
Definition h261dec.c:247
#define SLICE_ERROR
Definition h261dec.c:41
static VLCElem h261_mba_vlc[540]
Definition h261dec.c:52
static int decode_mv_component(GetBitContext *gb, int v)
Definition h261dec.c:223
static void h261_decode_mb_skipped(H261DecContext *h, int mba1, int mba2)
Decode skipped macroblocks.
Definition h261dec.c:186
#define av_cold
Definition attributes.h:117
#define AVOnce
Definition thread.h:202
static int ff_thread_once(char *control, void(*routine)(void))
Definition thread.h:205
#define AV_ONCE_INIT
Definition thread.h:203
#define check(x, y, S, v)
void ff_mpeg_er_frame_start(MpegEncContext *s)
Definition mpeg_er.c:46
#define IS_INTRA4x4(a)
Definition mpegutils.h:69
#define MB_TYPE_SKIP
Definition mpegutils.h:61
#define HAS_CBP(a)
Definition mpegutils.h:87
#define MB_TYPE_INTRA
Definition mpegutils.h:64
#define IS_16X16(a)
Definition mpegutils.h:80
#define MB_TYPE_16x16
Definition mpegutils.h:41
#define MB_TYPE_FORWARD_MV
Definition mpegutils.h:49
#define IS_QUANT(a)
Definition mpegutils.h:85
av_cold int ff_mpv_common_init(MpegEncContext *s)
init common structure for both encoder and decoder.
Definition mpegvideo.c:359
av_cold void ff_mpv_common_end(MpegEncContext *s)
Definition mpegvideo.c:428
void ff_init_block_index(MpegEncContext *s)
Definition mpegvideo.c:472
mpegvideo header.
#define MV_DIR_FORWARD
Definition mpegvideo.h:168
#define MV_TYPE_16X16
1 vector for the whole mb
Definition mpegvideo.h:172
@ FMT_H261
Definition mpegvideo.h:56
int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx)
generic function called after decoding the header and before a frame is decoded.
void ff_mpv_frame_end(MpegEncContext *s)
void ff_print_debug_info(const MpegEncContext *s, const MPVPicture *p, AVFrame *pict)
av_cold int ff_mpv_decode_close(AVCodecContext *avctx)
void ff_mpv_reconstruct_mb(MPVContext *s, int16_t block[][64])
av_cold int ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx)
Initialize the given MpegEncContext for decoding.
mpegvideo decoder header.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
#define INIT_FIRST_VLC_RL(rl, static_size)
Definition rl.h:93
main external API structure.
Definition avcodec.h:443
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition avcodec.h:643
int64_t frame_num
Frame counter, set by libavcodec.
Definition avcodec.h:1883
AVRational framerate
Definition avcodec.h:563
int coded_width
Bitstream width / height, may be different from width/height e.g.
Definition avcodec.h:619
void * priv_data
Definition avcodec.h:470
enum AVDiscard skip_frame
Skip decoding for selected frames.
Definition avcodec.h:1667
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
This structure stores compressed data.
Definition packet.h:580
int size
Definition packet.h:604
uint8_t * data
Definition packet.h:603
Rational number (pair of numerator and denominator).
Definition rational.h:58
int gob_start_code_skipped
Definition h261dec.c:67
int current_mv_y
Definition h261dec.c:65
MpegEncContext s
Definition h261dec.c:58
DECLARE_ALIGNED_32(int16_t, block)[6][64]
int current_mba
Definition h261dec.c:62
GetBitContext gb
Definition h261dec.c:60
int current_mv_x
Definition h261dec.c:64
MpegEncContext.
Definition mpegvideo.h:67
RLTable.
Definition rl.h:39
RL_VLC_ELEM * rl_vlc[32]
decoding only
Definition rl.h:48
Definition vlc.h:32
uint8_t run
Definition svq3.c:207
uint8_t level
Definition svq3.c:208
#define ff_dlog(a,...)
#define av_log(a,...)
#define VLC_INIT_STATIC_TABLE(vlc_table, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, flags)
Definition vlc.h:278
#define VLC_INIT_STATIC_SPARSE_TABLE(vlc_table, nb_bits, nb_codes, bits, bits_wrap, bits_size, codes, codes_wrap, codes_size, symbols, symbols_wrap, symbols_size, flags)
Definition vlc.h:266