Libav
h264dec.c
Go to the documentation of this file.
1 /*
2  * H.26L/H.264/AVC/JVT/14496-10/... decoder
3  * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
4  *
5  * This file is part of Libav.
6  *
7  * Libav is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * Libav is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
28 #include "libavutil/display.h"
29 #include "libavutil/imgutils.h"
30 #include "libavutil/opt.h"
31 #include "libavutil/stereo3d.h"
32 #include "libavutil/timer.h"
33 #include "internal.h"
34 #include "bytestream.h"
35 #include "cabac.h"
36 #include "cabac_functions.h"
37 #include "error_resilience.h"
38 #include "avcodec.h"
39 #include "h264.h"
40 #include "h264dec.h"
41 #include "h2645_parse.h"
42 #include "h264data.h"
43 #include "h264chroma.h"
44 #include "h264_mvpred.h"
45 #include "h264_ps.h"
46 #include "golomb.h"
47 #include "mathops.h"
48 #include "me_cmp.h"
49 #include "mpegutils.h"
50 #include "profiles.h"
51 #include "rectangle.h"
52 #include "thread.h"
53 
54 #include <assert.h>
55 
56 const uint16_t ff_h264_mb_sizes[4] = { 256, 384, 512, 768 };
57 
58 static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
59  int (*mv)[2][4][2],
60  int mb_x, int mb_y, int mb_intra, int mb_skipped)
61 {
62  H264Context *h = opaque;
63  H264SliceContext *sl = &h->slice_ctx[0];
64 
65  sl->mb_x = mb_x;
66  sl->mb_y = mb_y;
67  sl->mb_xy = mb_x + mb_y * h->mb_stride;
68  memset(sl->non_zero_count_cache, 0, sizeof(sl->non_zero_count_cache));
69  assert(ref >= 0);
70  /* FIXME: It is possible albeit uncommon that slice references
71  * differ between slices. We take the easy approach and ignore
72  * it for now. If this turns out to have any relevance in
73  * practice then correct remapping should be added. */
74  if (ref >= sl->ref_count[0])
75  ref = 0;
76  fill_rectangle(&h->cur_pic.ref_index[0][4 * sl->mb_xy],
77  2, 2, 2, ref, 1);
78  fill_rectangle(&sl->ref_cache[0][scan8[0]], 4, 4, 8, ref, 1);
79  fill_rectangle(sl->mv_cache[0][scan8[0]], 4, 4, 8,
80  pack16to32((*mv)[0][0][0], (*mv)[0][0][1]), 4);
81  assert(!FRAME_MBAFF(h));
83 }
84 
86  int y, int height)
87 {
88  AVCodecContext *avctx = h->avctx;
89  const AVFrame *src = h->cur_pic.f;
91  int vshift = desc->log2_chroma_h;
92  const int field_pic = h->picture_structure != PICT_FRAME;
93  if (field_pic) {
94  height <<= 1;
95  y <<= 1;
96  }
97 
98  height = FFMIN(height, avctx->height - y);
99 
100  if (field_pic && h->first_field && !(avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD))
101  return;
102 
103  if (avctx->draw_horiz_band) {
104  int offset[AV_NUM_DATA_POINTERS];
105  int i;
106 
107  offset[0] = y * src->linesize[0];
108  offset[1] =
109  offset[2] = (y >> vshift) * src->linesize[1];
110  for (i = 3; i < AV_NUM_DATA_POINTERS; i++)
111  offset[i] = 0;
112 
113  emms_c();
114 
115  avctx->draw_horiz_band(avctx, src, offset,
116  y, h->picture_structure, height);
117  }
118 }
119 
121 {
122  int i;
123 
126  av_freep(&h->cbp_table);
127  av_freep(&h->mvd_table[0]);
128  av_freep(&h->mvd_table[1]);
129  av_freep(&h->direct_table);
132  h->slice_table = NULL;
133  av_freep(&h->list_counts);
134 
135  av_freep(&h->mb2b_xy);
136  av_freep(&h->mb2br_xy);
137 
142 
143  for (i = 0; i < h->nb_slice_ctx; i++) {
144  H264SliceContext *sl = &h->slice_ctx[i];
145 
146  av_freep(&sl->dc_val_base);
147  av_freep(&sl->er.mb_index2xy);
149  av_freep(&sl->er.er_temp_buffer);
150 
153  av_freep(&sl->top_borders[0]);
154  av_freep(&sl->top_borders[1]);
155 
158  sl->top_borders_allocated[0] = 0;
159  sl->top_borders_allocated[1] = 0;
160  }
161 }
162 
164 {
165  const int big_mb_num = h->mb_stride * (h->mb_height + 1);
166  const int row_mb_num = h->mb_stride * 2 * h->nb_slice_ctx;
167  int x, y;
168 
170  row_mb_num * 8 * sizeof(uint8_t), fail)
172 
174  big_mb_num * 48 * sizeof(uint8_t), fail)
176  (big_mb_num + h->mb_stride) * sizeof(*h->slice_table_base), fail)
178  big_mb_num * sizeof(uint16_t), fail)
180  big_mb_num * sizeof(uint8_t), fail)
182  16 * row_mb_num * sizeof(uint8_t), fail);
184  16 * row_mb_num * sizeof(uint8_t), fail);
185  h->slice_ctx[0].mvd_table[0] = h->mvd_table[0];
186  h->slice_ctx[0].mvd_table[1] = h->mvd_table[1];
187 
189  4 * big_mb_num * sizeof(uint8_t), fail);
191  big_mb_num * sizeof(uint8_t), fail)
192 
193  memset(h->slice_table_base, -1,
194  (big_mb_num + h->mb_stride) * sizeof(*h->slice_table_base));
195  h->slice_table = h->slice_table_base + h->mb_stride * 2 + 1;
196 
198  big_mb_num * sizeof(uint32_t), fail);
200  big_mb_num * sizeof(uint32_t), fail);
201  for (y = 0; y < h->mb_height; y++)
202  for (x = 0; x < h->mb_width; x++) {
203  const int mb_xy = x + y * h->mb_stride;
204  const int b_xy = 4 * x + 4 * y * h->b_stride;
205 
206  h->mb2b_xy[mb_xy] = b_xy;
207  h->mb2br_xy[mb_xy] = 8 * (FMO ? mb_xy : (mb_xy % (2 * h->mb_stride)));
208  }
209 
210  return 0;
211 
212 fail:
214  return AVERROR(ENOMEM);
215 }
216 
222 {
223  ERContext *er = &sl->er;
224  int mb_array_size = h->mb_height * h->mb_stride;
225  int y_size = (2 * h->mb_width + 1) * (2 * h->mb_height + 1);
226  int c_size = h->mb_stride * (h->mb_height + 1);
227  int yc_size = y_size + 2 * c_size;
228  int x, y, i;
229 
230  sl->ref_cache[0][scan8[5] + 1] =
231  sl->ref_cache[0][scan8[7] + 1] =
232  sl->ref_cache[0][scan8[13] + 1] =
233  sl->ref_cache[1][scan8[5] + 1] =
234  sl->ref_cache[1][scan8[7] + 1] =
235  sl->ref_cache[1][scan8[13] + 1] = PART_NOT_AVAILABLE;
236 
238  /* init ER */
239  er->avctx = h->avctx;
241  er->opaque = h;
242  er->quarter_sample = 1;
243 
244  er->mb_num = h->mb_num;
245  er->mb_width = h->mb_width;
246  er->mb_height = h->mb_height;
247  er->mb_stride = h->mb_stride;
248  er->b8_stride = h->mb_width * 2 + 1;
249 
250  // error resilience code looks cleaner with this
252  (h->mb_num + 1) * sizeof(int), fail);
253 
254  for (y = 0; y < h->mb_height; y++)
255  for (x = 0; x < h->mb_width; x++)
256  er->mb_index2xy[x + y * h->mb_width] = x + y * h->mb_stride;
257 
258  er->mb_index2xy[h->mb_height * h->mb_width] = (h->mb_height - 1) *
259  h->mb_stride + h->mb_width;
260 
262  mb_array_size * sizeof(uint8_t), fail);
263 
265  h->mb_height * h->mb_stride, fail);
266 
268  yc_size * sizeof(int16_t), fail);
269  er->dc_val[0] = sl->dc_val_base + h->mb_width * 2 + 2;
270  er->dc_val[1] = sl->dc_val_base + y_size + h->mb_stride + 1;
271  er->dc_val[2] = er->dc_val[1] + c_size;
272  for (i = 0; i < yc_size; i++)
273  sl->dc_val_base[i] = 1024;
274  }
275 
276  return 0;
277 
278 fail:
279  return AVERROR(ENOMEM); // ff_h264_free_tables will clean up for us
280 }
281 
283 {
284  int i;
285 
286  h->avctx = avctx;
287 
289  h->workaround_bugs = avctx->workaround_bugs;
290  h->flags = avctx->flags;
291  h->poc.prev_poc_msb = 1 << 16;
292  h->recovery_frame = -1;
293  h->x264_build = -1;
294  h->frame_recovered = 0;
295 
296  h->next_outputed_poc = INT_MIN;
297  for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
298  h->last_pocs[i] = INT_MIN;
299 
300  ff_h264_sei_uninit(&h->sei);
301 
303 
304  h->nb_slice_ctx = (avctx->active_thread_type & FF_THREAD_SLICE) ? avctx->thread_count : 1;
305  h->slice_ctx = av_mallocz_array(h->nb_slice_ctx, sizeof(*h->slice_ctx));
306  if (!h->slice_ctx) {
307  h->nb_slice_ctx = 0;
308  return AVERROR(ENOMEM);
309  }
310 
311  for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) {
312  h->DPB[i].f = av_frame_alloc();
313  if (!h->DPB[i].f)
314  return AVERROR(ENOMEM);
315  }
316 
317  h->cur_pic.f = av_frame_alloc();
318  if (!h->cur_pic.f)
319  return AVERROR(ENOMEM);
320 
322  if (!h->output_frame)
323  return AVERROR(ENOMEM);
324 
325  for (i = 0; i < h->nb_slice_ctx; i++)
326  h->slice_ctx[i].h264 = h;
327 
328  return 0;
329 }
330 
332 {
333  H264Context *h = avctx->priv_data;
334  int i;
335 
337 
338  for (i = 0; i < H264_MAX_PICTURE_COUNT; i++) {
339  ff_h264_unref_picture(h, &h->DPB[i]);
340  av_frame_free(&h->DPB[i].f);
341  }
342 
343  h->cur_pic_ptr = NULL;
344 
345  av_freep(&h->slice_ctx);
346  h->nb_slice_ctx = 0;
347 
348  for (i = 0; i < MAX_SPS_COUNT; i++)
349  av_buffer_unref(&h->ps.sps_list[i]);
350 
351  for (i = 0; i < MAX_PPS_COUNT; i++)
352  av_buffer_unref(&h->ps.pps_list[i]);
353 
355 
357  av_frame_free(&h->cur_pic.f);
359 
360  return 0;
361 }
362 
364 
366 {
367  H264Context *h = avctx->priv_data;
368  int ret;
369 
370  ret = h264_init_context(avctx, h);
371  if (ret < 0)
372  return ret;
373 
374  ret = ff_thread_once(&h264_vlc_init, ff_h264_decode_init_vlc);
375  if (ret != 0) {
376  av_log(avctx, AV_LOG_ERROR, "pthread_once has failed.");
377  return AVERROR_UNKNOWN;
378  }
379 
380  if (avctx->ticks_per_frame == 1)
381  h->avctx->framerate.num *= 2;
382  avctx->ticks_per_frame = 2;
383 
384  if (avctx->extradata_size > 0 && avctx->extradata) {
386  &h->ps, &h->is_avc, &h->nal_length_size,
387  avctx->err_recognition, avctx);
388  if (ret < 0) {
389  h264_decode_end(avctx);
390  return ret;
391  }
392  }
393 
394  if (h->ps.sps && h->ps.sps->bitstream_restriction_flag &&
397  }
398 
399  avctx->internal->allocate_progress = 1;
400 
401  if (h->enable_er) {
402  av_log(avctx, AV_LOG_WARNING,
403  "Error resilience is enabled. It is unsafe and unsupported and may crash. "
404  "Use it at your own risk\n");
405  }
406 
407  return 0;
408 }
409 
411 {
412  H264Context *h = avctx->priv_data;
413  int ret;
414 
415  if (!avctx->internal->is_copy)
416  return 0;
417 
418  memset(h, 0, sizeof(*h));
419 
420  ret = h264_init_context(avctx, h);
421  if (ret < 0)
422  return ret;
423 
424  h->context_initialized = 0;
425 
426  return 0;
427 }
428 
432 static void idr(H264Context *h)
433 {
435  h->poc.prev_frame_num =
437  h->poc.prev_poc_msb =
438  h->poc.prev_poc_lsb = 0;
439 }
440 
441 /* forget old pics after a seek */
443 {
444  int i;
445  for (i = 0; i < MAX_DELAYED_PIC_COUNT; i++)
446  h->last_pocs[i] = INT_MIN;
447  h->next_outputed_poc = INT_MIN;
448  h->prev_interlaced_frame = 1;
449  idr(h);
450  if (h->cur_pic_ptr)
451  h->cur_pic_ptr->reference = 0;
452  h->first_field = 0;
453  h->recovery_frame = -1;
454  h->frame_recovered = 0;
455 }
456 
457 /* forget old pics after a seek */
458 static void flush_dpb(AVCodecContext *avctx)
459 {
460  H264Context *h = avctx->priv_data;
461  int i;
462 
463  memset(h->delayed_pic, 0, sizeof(h->delayed_pic));
464 
466  ff_h264_sei_uninit(&h->sei);
467 
468  for (i = 0; i < H264_MAX_PICTURE_COUNT; i++)
469  ff_h264_unref_picture(h, &h->DPB[i]);
470  h->cur_pic_ptr = NULL;
472 
473  h->mb_y = 0;
474 
476  h->context_initialized = 0;
477 }
478 
480 {
481  int nals_needed = 0;
482  int i, ret;
483 
484  for (i = 0; i < h->pkt.nb_nals; i++) {
485  H2645NAL *nal = &h->pkt.nals[i];
486  GetBitContext gb;
487 
488  /* packets can sometimes contain multiple PPS/SPS,
489  * e.g. two PAFF field pictures in one packet, or a demuxer
490  * which splits NALs strangely if so, when frame threading we
491  * can't start the next thread until we've read all of them */
492  switch (nal->type) {
493  case H264_NAL_SPS:
494  case H264_NAL_PPS:
495  nals_needed = i;
496  break;
497  case H264_NAL_DPA:
498  case H264_NAL_IDR_SLICE:
499  case H264_NAL_SLICE:
500  ret = init_get_bits8(&gb, nal->data + 1, nal->size - 1);
501  if (ret < 0) {
502  av_log(h->avctx, AV_LOG_ERROR, "Invalid zero-sized VCL NAL unit\n");
504  return ret;
505 
506  break;
507  }
508  if (!get_ue_golomb(&gb))
509  nals_needed = i;
510  }
511  }
512 
513  return nals_needed;
514 }
515 
516 static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
517 {
518  AVCodecContext *const avctx = h->avctx;
519  int nals_needed = 0;
520  int i, ret = 0;
521 
522  if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS)) {
523  h->current_slice = 0;
524  h->field_started = 0;
525  if (!h->first_field)
526  h->cur_pic_ptr = NULL;
527  ff_h264_sei_uninit(&h->sei);
528  }
529 
530  ret = ff_h2645_packet_split(&h->pkt, buf, buf_size, avctx, h->is_avc,
531  h->nal_length_size, avctx->codec_id);
532  if (ret < 0) {
533  av_log(avctx, AV_LOG_ERROR,
534  "Error splitting the input into NAL units.\n");
535 
536  /* There are samples in the wild with mp4-style extradata, but Annex B
537  * data in the packets. If we fail parsing the packet as mp4, try it again
538  * as Annex B. */
539  if (h->is_avc && !(avctx->err_recognition & AV_EF_EXPLODE)) {
540  int err = ff_h2645_packet_split(&h->pkt, buf, buf_size, avctx, 0, 0,
541  avctx->codec_id);
542  if (err >= 0) {
543  av_log(avctx, AV_LOG_WARNING,
544  "The stream seems to contain AVCC extradata with Annex B "
545  "formatted data, which is invalid.");
546  h->is_avc = 0;
547  ret = 0;
548  }
549  }
550 
551  if (ret < 0)
552  return ret;
553  }
554 
555  if (avctx->active_thread_type & FF_THREAD_FRAME)
556  nals_needed = get_last_needed_nal(h);
557 
558  for (i = 0; i < h->pkt.nb_nals; i++) {
559  H2645NAL *nal = &h->pkt.nals[i];
560  int max_slice_ctx, err;
561 
562  if (avctx->skip_frame >= AVDISCARD_NONREF &&
563  nal->ref_idc == 0 && nal->type != H264_NAL_SEI)
564  continue;
565 
566  // FIXME these should stop being context-global variables
567  h->nal_ref_idc = nal->ref_idc;
568  h->nal_unit_type = nal->type;
569 
570  err = 0;
571  switch (nal->type) {
572  case H264_NAL_IDR_SLICE:
573  idr(h); // FIXME ensure we don't lose some frames if there is reordering
574  case H264_NAL_SLICE:
575  if ((err = ff_h264_queue_decode_slice(h, nal)))
576  break;
577 
578  if (avctx->active_thread_type & FF_THREAD_FRAME && !h->avctx->hwaccel &&
579  i >= nals_needed && !h->setup_finished && h->cur_pic_ptr) {
580  ff_thread_finish_setup(avctx);
581  h->setup_finished = 1;
582  }
583 
584  max_slice_ctx = avctx->hwaccel ? 1 : h->nb_slice_ctx;
585  if (h->nb_slice_ctx_queued == max_slice_ctx) {
586  if (avctx->hwaccel) {
587  ret = avctx->hwaccel->decode_slice(avctx, nal->raw_data, nal->raw_size);
588  h->nb_slice_ctx_queued = 0;
589  } else
591  if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
592  goto end;
593  }
594  break;
595  case H264_NAL_DPA:
596  case H264_NAL_DPB:
597  case H264_NAL_DPC:
598  avpriv_request_sample(avctx, "data partitioning");
599  ret = AVERROR(ENOSYS);
600  goto end;
601  break;
602  case H264_NAL_SEI:
603  ret = ff_h264_sei_decode(&h->sei, &nal->gb, &h->ps, avctx);
604  if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
605  goto end;
606  break;
607  case H264_NAL_SPS:
608  ret = ff_h264_decode_seq_parameter_set(&nal->gb, avctx, &h->ps);
609  if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
610  goto end;
611  break;
612  case H264_NAL_PPS:
613  ret = ff_h264_decode_picture_parameter_set(&nal->gb, avctx, &h->ps,
614  nal->size_bits);
615  if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
616  goto end;
617  break;
618  case H264_NAL_AUD:
620  case H264_NAL_END_STREAM:
622  case H264_NAL_SPS_EXT:
624  break;
625  default:
626  av_log(avctx, AV_LOG_DEBUG, "Unknown NAL code: %d (%d bits)\n",
627  nal->type, nal->size_bits);
628  }
629 
630  if (err < 0) {
631  av_log(h->avctx, AV_LOG_ERROR, "decode_slice_header error\n");
632  }
633  }
634 
636  if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
637  goto end;
638 
639  ret = 0;
640 end:
641  /* clean up */
642  if (h->cur_pic_ptr && !h->droppable) {
645  }
646 
647  return (ret < 0) ? ret : buf_size;
648 }
649 
653 static int get_consumed_bytes(int pos, int buf_size)
654 {
655  if (pos == 0)
656  pos = 1; // avoid infinite loops (I doubt that is needed but...)
657  if (pos + 10 > buf_size)
658  pos = buf_size; // oops ;)
659 
660  return pos;
661 }
662 
664 {
665  int i;
666  int ret = av_frame_ref(dst, src);
667  if (ret < 0)
668  return ret;
669 
670  if (!h->ps.sps || !h->ps.sps->crop)
671  return 0;
672 
673  for (i = 0; i < 3; i++) {
674  int hshift = (i > 0) ? h->chroma_x_shift : 0;
675  int vshift = (i > 0) ? h->chroma_y_shift : 0;
676  int off = ((h->ps.sps->crop_left >> hshift) << h->pixel_shift) +
677  (h->ps.sps->crop_top >> vshift) * dst->linesize[i];
678  dst->data[i] += off;
679  }
680  return 0;
681 }
682 
683 static int h264_decode_frame(AVCodecContext *avctx, void *data,
684  int *got_frame, AVPacket *avpkt)
685 {
686  const uint8_t *buf = avpkt->data;
687  int buf_size = avpkt->size;
688  H264Context *h = avctx->priv_data;
689  AVFrame *pict = data;
690  int buf_index = 0;
691  int ret;
692  const uint8_t *new_extradata;
693  int new_extradata_size;
694 
695  h->flags = avctx->flags;
696  h->setup_finished = 0;
697  h->nb_slice_ctx_queued = 0;
698 
699  /* end of stream, output what is still in the buffers */
700 out:
701  if (buf_size == 0) {
702  H264Picture *out;
703  int i, out_idx;
704 
705  h->cur_pic_ptr = NULL;
706 
707  // FIXME factorize this with the output code below
708  out = h->delayed_pic[0];
709  out_idx = 0;
710  for (i = 1;
711  h->delayed_pic[i] &&
712  !h->delayed_pic[i]->f->key_frame &&
713  !h->delayed_pic[i]->mmco_reset;
714  i++)
715  if (h->delayed_pic[i]->poc < out->poc) {
716  out = h->delayed_pic[i];
717  out_idx = i;
718  }
719 
720  for (i = out_idx; h->delayed_pic[i]; i++)
721  h->delayed_pic[i] = h->delayed_pic[i + 1];
722 
723  if (out) {
724  ret = output_frame(h, pict, out->f);
725  if (ret < 0)
726  return ret;
727  *got_frame = 1;
728  }
729 
730  return buf_index;
731  }
732 
733  new_extradata_size = 0;
734  new_extradata = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
735  &new_extradata_size);
736  if (new_extradata_size > 0 && new_extradata) {
737  ret = ff_h264_decode_extradata(new_extradata, new_extradata_size,
738  &h->ps, &h->is_avc, &h->nal_length_size,
739  avctx->err_recognition, avctx);
740  if (ret < 0)
741  return ret;
742  }
743 
744  buf_index = decode_nal_units(h, buf, buf_size);
745  if (buf_index < 0)
746  return AVERROR_INVALIDDATA;
747 
749  buf_size = 0;
750  goto out;
751  }
752 
753  if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) && !h->cur_pic_ptr) {
754  if (avctx->skip_frame >= AVDISCARD_NONREF)
755  return 0;
756  av_log(avctx, AV_LOG_ERROR, "no frame!\n");
757  return AVERROR_INVALIDDATA;
758  }
759 
760  if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) ||
761  (h->mb_y >= h->mb_height && h->mb_height)) {
762  if (h->field_started)
763  ff_h264_field_end(h, &h->slice_ctx[0], 0);
764 
765  *got_frame = 0;
766  if (h->output_frame->buf[0]) {
767  ret = output_frame(h, pict, h->output_frame) ;
769  if (ret < 0)
770  return ret;
771  *got_frame = 1;
772  }
773  }
774 
775  assert(pict->buf[0] || !*got_frame);
776 
777  return get_consumed_bytes(buf_index, buf_size);
778 }
779 
780 #define OFFSET(x) offsetof(H264Context, x)
781 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
782 static const AVOption h264_options[] = {
783  { "enable_er", "Enable error resilience on damaged frames (unsafe)", OFFSET(enable_er), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VD },
784  { NULL },
785 };
786 
787 static const AVClass h264_class = {
788  .class_name = "h264",
789  .item_name = av_default_item_name,
790  .option = h264_options,
791  .version = LIBAVUTIL_VERSION_INT,
792 };
793 
795  .name = "h264",
796  .long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
797  .type = AVMEDIA_TYPE_VIDEO,
798  .id = AV_CODEC_ID_H264,
799  .priv_data_size = sizeof(H264Context),
801  .close = h264_decode_end,
803  .capabilities = /*AV_CODEC_CAP_DRAW_HORIZ_BAND |*/ AV_CODEC_CAP_DR1 |
806  .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE,
807  .flush = flush_dpb,
809  .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context),
811  .priv_class = &h264_class,
812 };
int ff_h264_decode_picture_parameter_set(GetBitContext *gb, AVCodecContext *avctx, H264ParamSets *ps, int bit_length)
Decode PPS.
Definition: h264_ps.c:672
struct H264Context * h264
Definition: h264dec.h:175
AVRational framerate
Definition: avcodec.h:3063
int workaround_bugs
Definition: h264dec.h:363
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:54
#define AV_NUM_DATA_POINTERS
Definition: frame.h:141
#define SLICE_FLAG_ALLOW_FIELD
allow draw_horiz_band() with field slices (MPEG-2 field pics)
Definition: avcodec.h:1935
int ff_h264_queue_decode_slice(H264Context *h, const H2645NAL *nal)
Submit a slice for decoding.
Definition: h264_slice.c:1859
H264POCContext poc
Definition: h264dec.h:448
int mb_num
Definition: h264dec.h:427
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
Definition: buffer.c:106
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:1768
MPEG-2/4, H.264 default.
Definition: pixfmt.h:378
This structure describes decoded (raw) audio or video data.
Definition: frame.h:140
#define MAX_SPS_COUNT
Definition: h264_ps.h:37
int16_t mv_cache[2][5 *8][2]
Motion vector cache.
Definition: h264dec.h:296
AVOption.
Definition: opt.h:234
int size
Definition: h2645_parse.h:33
int edge_emu_buffer_allocated
Definition: h264dec.h:284
int first_field
Definition: h264dec.h:399
misc image utilities
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:130
AVBufferRef * sps_list[MAX_SPS_COUNT]
Definition: h264_ps.h:134
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
Definition: frame.h:308
const char * desc
Definition: nvenc.c:101
uint16_t * cbp_table
Definition: h264dec.h:404
int mb_y
Definition: h264dec.h:424
int bitstream_restriction_flag
Definition: h264_ps.h:84
int num
numerator
Definition: rational.h:44
int bipred_scratchpad_allocated
Definition: h264dec.h:283
int size
Definition: avcodec.h:1347
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
AVBufferPool * mb_type_pool
Definition: h264dec.h:525
int ff_h2645_packet_split(H2645Packet *pkt, const uint8_t *buf, int length, void *logctx, int is_nalff, int nal_length_size, enum AVCodecID codec_id)
Split an input packet into NAL units.
Definition: h2645_parse.c:214
int chroma_x_shift
Definition: h264dec.h:356
static void idr(H264Context *h)
instantaneous decoder refresh.
Definition: h264dec.c:432
int flags
Definition: h264dec.h:362
void ff_h264_flush_change(H264Context *h)
Definition: h264dec.c:442
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1621
int mb_height
Definition: h264dec.h:425
H264Picture * delayed_pic[MAX_DELAYED_PIC_COUNT+2]
Definition: h264dec.h:452
int is_avc
Used to parse AVC variant of H.264.
Definition: h264dec.h:438
AVBufferPool * ref_index_pool
Definition: h264dec.h:527
void ff_h264_sei_uninit(H264SEIContext *h)
Reset SEI values at the beginning of the frame.
Definition: h264_sei.c:39
H264Context.
Definition: h264dec.h:334
AVFrame * f
Definition: h264dec.h:128
#define AV_CODEC_FLAG2_CHUNKS
Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries...
Definition: avcodec.h:816
AVCodec.
Definition: avcodec.h:3120
int picture_structure
Definition: h264dec.h:398
void(* draw_horiz_band)(struct AVCodecContext *s, const AVFrame *src, int offset[AV_NUM_DATA_POINTERS], int y, int type, int height)
If non NULL, &#39;draw_horiz_band&#39; is called by the libavcodec decoder to draw a horizontal band...
Definition: avcodec.h:1654
static void flush_dpb(AVCodecContext *avctx)
Definition: h264dec.c:458
unsigned int ref_count[2]
num_ref_idx_l0/1_active_minus1 + 1
Definition: h264dec.h:264
int size_bits
Size, in bits, of just the data, excluding the stop bit and any trailing padding. ...
Definition: h2645_parse.h:40
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:202
int ff_h264_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
Definition: h264_slice.c:313
uint8_t * chroma_pred_mode_table
Definition: h264dec.h:407
int setup_finished
Definition: h264dec.h:511
void ff_h264_remove_all_refs(H264Context *h)
Definition: h264_refs.c:512
av_cold int ff_h264_decode_init(AVCodecContext *avctx)
Definition: h264dec.c:365
enum AVDiscard skip_frame
Definition: avcodec.h:2989
int ff_h264_execute_decode_slices(H264Context *h)
Call decode_slice() for each context.
Definition: h264_slice.c:2495
H264SEIContext sei
Definition: h264dec.h:522
struct AVHWAccel * hwaccel
Hardware accelerator in use.
Definition: avcodec.h:2696
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:39
unsigned int crop_top
frame_cropping_rect_top_offset
Definition: h264_ps.h:69
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: avcodec.h:863
static int get_consumed_bytes(int pos, int buf_size)
Return the number of bytes consumed for building the current frame.
Definition: h264dec.c:653
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
Definition: internal.h:40
uint8_t
#define av_cold
Definition: attributes.h:66
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:68
unsigned int crop_left
frame_cropping_rect_left_offset
Definition: h264_ps.h:67
AVOptions.
void ff_h264_hl_decode_mb(const H264Context *h, H264SliceContext *sl)
Definition: h264_mb.c:798
int poc
frame POC
Definition: h264dec.h:147
Multithreading support functions.
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:199
#define emms_c()
Definition: internal.h:48
AVFrame * output_frame
Definition: h264dec.h:518
static int get_last_needed_nal(H264Context *h)
Definition: h264dec.c:479
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
Definition: avcodec.h:1523
void ff_h2645_packet_uninit(H2645Packet *pkt)
Free all the allocated memory in the packet.
Definition: h2645_parse.c:323
int frame_recovered
Initial frame has been completely recovered.
Definition: h264dec.h:505
const char data[16]
Definition: mxf.c:70
int ff_h264_decode_extradata(const uint8_t *data, int size, H264ParamSets *ps, int *is_avc, int *nal_length_size, int err_recognition, void *logctx)
Definition: h264_parse.c:406
#define PICT_BOTTOM_FIELD
Definition: mpegutils.h:38
#define MAX_PPS_COUNT
Definition: h264_ps.h:38
uint8_t * data
Definition: avcodec.h:1346
static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
Definition: h264dec.c:516
int chroma_y_shift
Definition: h264dec.h:356
static int h264_init_context(AVCodecContext *avctx, H264Context *h)
Definition: h264dec.c:282
void ff_thread_finish_setup(AVCodecContext *avctx)
If the codec defines update_thread_context(), call this when they are ready for the next thread to st...
high precision timer, useful to profile code
#define AVOnce
Definition: thread.h:56
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
Definition: avcodec.h:2134
int last_pocs[MAX_DELAYED_PIC_COUNT]
Definition: h264dec.h:453
static int output_frame(H264Context *h, AVFrame *dst, AVFrame *src)
Definition: h264dec.c:663
H.264 common definitions.
void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl, int y, int height)
Definition: h264dec.c:85
#define src
Definition: vp8dsp.c:254
H.264 parameter set handling.
H264Picture DPB[H264_MAX_PICTURE_COUNT]
Definition: h264dec.h:342
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:124
int has_b_frames
Size of the frame reordering buffer in the decoder.
Definition: avcodec.h:1715
static int get_ue_golomb(GetBitContext *gb)
read unsigned exp golomb code.
Definition: golomb.h:53
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:100
static const AVClass h264_class
Definition: h264dec.c:787
int16_t * dc_val_base
Definition: h264dec.h:278
int context_initialized
Definition: h264dec.h:361
ERContext er
Definition: h264dec.h:177
int nal_unit_type
Definition: h264dec.h:433
int num_reorder_frames
Definition: h264_ps.h:85
int is_copy
Whether the parent AVCodecContext is a copy of the context which had init() called on it...
Definition: internal.h:104
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:80
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:148
static const AVOption h264_options[]
Definition: h264dec.c:782
int active_thread_type
Which multithreading methods are in use by the codec.
Definition: avcodec.h:2825
H2645Packet pkt
Definition: h264dec.h:350
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:145
uint8_t(*[2] mvd_table)[2]
Definition: h264dec.h:408
static av_cold int h264_decode_end(AVCodecContext *avctx)
Definition: h264dec.c:331
int prev_interlaced_frame
Complement sei_pic_struct SEI_PIC_STRUCT_TOP_BOTTOM and SEI_PIC_STRUCT_BOTTOM_TOP indicate interlaced...
Definition: h264dec.h:484
int flags
AV_CODEC_FLAG_*.
Definition: avcodec.h:1503
ThreadFrame tf
Definition: h264dec.h:129
uint8_t(*[2] top_borders)[(16 *3) *2]
Definition: h264dec.h:282
const char * name
Name of the codec implementation.
Definition: avcodec.h:3127
uint8_t * list_counts
Array of list_count per MB specifying the slice type.
Definition: h264dec.h:401
#define fail()
Definition: checkasm.h:80
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: avcodec.h:893
int * mb_index2xy
int raw_size
Definition: h2645_parse.h:42
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
Definition: internal.h:188
int crop
frame_cropping_flag
Definition: h264_ps.h:64
uint8_t * error_status_table
uint8_t * direct_table
Definition: h264dec.h:409
int nal_length_size
Number of bytes used for nal length (1, 2 or 4)
Definition: h264dec.h:439
useful rectangle filling function
int prev_poc_msb
poc_msb of the last reference pic for POC type 0
Definition: h264_parse.h:49
static int decode_init_thread_copy(AVCodecContext *avctx)
Definition: h264dec.c:410
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
Definition: avcodec.h:2670
int x264_build
Definition: h264dec.h:364
#define FF_THREAD_FRAME
Decode more than one frame at once.
Definition: avcodec.h:2817
uint32_t * mb2br_xy
Definition: h264dec.h:391
uint8_t * er_temp_buffer
#define FFMIN(a, b)
Definition: common.h:66
uint16_t * slice_table
slice_table_base + 2*mb_stride + 1
Definition: h264dec.h:394
static void h264_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type, int(*mv)[2][4][2], int mb_x, int mb_y, int mb_intra, int mb_skipped)
Definition: h264dec.c:58
int reference
Definition: h264dec.h:159
int nb_slice_ctx
Definition: h264dec.h:347
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
Definition: avconv.c:1288
int field_started
Definition: h264dec.h:516
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
static void fill_rectangle(SDL_Surface *screen, int x, int y, int w, int h, int color)
Definition: avplay.c:392
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
Definition: avcodec.h:2818
Context Adaptive Binary Arithmetic Coder inline functions.
H.264 / AVC / MPEG-4 part10 codec.
H264SliceContext * slice_ctx
Definition: h264dec.h:346
#define AV_EF_EXPLODE
Definition: avcodec.h:2681
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
Definition: avcodec.h:1544
int top_borders_allocated[2]
Definition: h264dec.h:285
int ref_idc
H.264 only, nal_ref_idc.
Definition: h2645_parse.h:60
int type
NAL unit type.
Definition: h2645_parse.h:50
LIBAVUTIL_VERSION_INT
Definition: eval.c:55
int thread_count
thread count is used to decide how many independent tasks should be passed to execute() ...
Definition: avcodec.h:2806
uint8_t * edge_emu_buffer
Definition: h264dec.h:281
if(ac->has_optimized_func)
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: avcodec.h:897
static const int8_t mv[256][2]
Definition: 4xm.c:75
NULL
Definition: eval.c:55
The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format that the extradata buffer was...
Definition: avcodec.h:1201
int mb_stride
Definition: h264dec.h:426
AVCodecContext * avctx
Definition: h264dec.h:336
#define AV_ONCE_INIT
Definition: thread.h:57
Libavcodec external API header.
#define MAX_DELAYED_PIC_COUNT
Definition: h264dec.h:56
AVBufferRef * pps_list[MAX_PPS_COUNT]
Definition: h264_ps.h:135
enum AVCodecID codec_id
Definition: avcodec.h:1426
AVCodec ff_h264_decoder
Definition: h264dec.c:794
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:158
int next_outputed_poc
Definition: h264dec.h:454
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
Definition: get_bits.h:395
av_default_item_name
Definition: dnxhdenc.c:55
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:80
int recovery_frame
recovery_frame is the frame_num at which the next frame should be fully constructed.
Definition: h264dec.h:492
main external API structure.
Definition: avcodec.h:1409
const uint8_t * data
Definition: h2645_parse.h:34
static av_always_inline uint32_t pack16to32(int a, int b)
Definition: h264dec.h:638
static AVOnce h264_vlc_init
Definition: h264dec.c:363
static const uint8_t scan8[16 *3+3]
Definition: h264dec.h:622
int extradata_size
Definition: avcodec.h:1524
int slice_flags
slice flags
Definition: avcodec.h:1933
Describe the class of an AVClass context structure.
Definition: log.h:34
int prev_frame_num
frame_num of the last pic for POC type 1/2
Definition: h264_parse.h:53
uint8_t non_zero_count_cache[15 *8]
non zero coeff count cache.
Definition: h264dec.h:291
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
Definition: buffer.c:254
#define FRAME_MBAFF(h)
Definition: h264dec.h:73
int8_t * ref_index[2]
Definition: h264dec.h:144
av_cold void ff_h264_decode_init_vlc(void)
Definition: h264_cavlc.c:326
int pixel_shift
0 for 8-bit H.264, 1 for high-bit-depth H.264
Definition: h264dec.h:352
int mmco_reset
MMCO_RESET set this 1.
Definition: h264dec.h:149
H264Picture * cur_pic_ptr
Definition: h264dec.h:343
#define FMO
Definition: h264dec.h:62
int enable_er
Definition: h264dec.h:520
int allocate_progress
Whether to allocate progress for frame threading.
Definition: internal.h:119
AVCodecContext * avctx
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:302
int(* decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Callback for each slice.
Definition: avcodec.h:3314
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:146
int prev_poc_lsb
poc_lsb of the last reference pic for POC type 0
Definition: h264_parse.h:50
int ff_h264_alloc_tables(H264Context *h)
Allocate tables.
Definition: h264dec.c:163
int height
Definition: gxfenc.c:72
#define CONFIG_ERROR_RESILIENCE
Definition: config.h:424
int nb_slice_ctx_queued
Definition: h264dec.h:348
discard all non reference
Definition: avcodec.h:686
int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
Definition: h264_picture.c:145
AVBufferPool * qscale_table_pool
Definition: h264dec.h:524
AVBufferPool * motion_val_pool
Definition: h264dec.h:526
common internal api header.
#define FF_ALLOC_OR_GOTO(ctx, p, size, label)
Definition: internal.h:120
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
Definition: alsdec.c:1797
uint16_t * slice_table_base
Definition: h264dec.h:446
#define OFFSET(x)
Definition: h264dec.c:780
H264ParamSets ps
Definition: h264dec.h:444
int16_t * dc_val[3]
H.264 / AVC / MPEG-4 part10 motion vector prediction.
int workaround_bugs
Work around bugs in encoders which sometimes cannot be detected automatically.
Definition: avcodec.h:2571
const AVProfile ff_h264_profiles[]
Definition: profiles.c:48
int8_t * intra4x4_pred_mode
Definition: h264dec.h:203
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:61
static av_cold int init(AVCodecParserContext *s)
Definition: h264_parser.c:582
static int h264_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Definition: h264dec.c:683
GetBitContext gb
Definition: h2645_parse.h:45
#define VD
Definition: h264dec.c:781
void ff_h264_free_tables(H264Context *h)
Definition: h264dec.c:120
void * priv_data
Definition: avcodec.h:1451
const uint8_t * raw_data
Definition: h2645_parse.h:43
#define PICT_FRAME
Definition: mpegutils.h:39
int8_t ref_cache[2][5 *8]
Definition: h264dec.h:297
struct AVCodecInternal * internal
Private context used for internal data.
Definition: avcodec.h:1459
static int ff_thread_once(char *control, void(*routine)(void))
Definition: thread.h:59
H2645NAL * nals
Definition: h2645_parse.h:65
H264Picture cur_pic
Definition: h264dec.h:344
#define PART_NOT_AVAILABLE
Definition: h264dec.h:382
int key_frame
1 -> keyframe, 0-> not
Definition: frame.h:196
int mb_width
Definition: h264dec.h:425
int current_slice
current slice number, used to initialize slice_num of each thread/context
Definition: h264dec.h:474
int flags2
AV_CODEC_FLAG2_*.
Definition: avcodec.h:1510
uint32_t * mb2b_xy
Definition: h264dec.h:390
SPS * sps
Definition: h264_ps.h:140
static void * av_mallocz_array(size_t nmemb, size_t size)
Definition: mem.h:205
FILE * out
Definition: movenc.c:54
uint8_t(*[2] mvd_table)[2]
Definition: h264dec.h:310
int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb, const H264ParamSets *ps, void *logctx)
Definition: h264_sei.c:346
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
Definition: avpacket.c:284
int prev_frame_num_offset
for POC type 2
Definition: h264_parse.h:52
int8_t * intra4x4_pred_mode
Definition: h264dec.h:376
int ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl)
Init context Allocate buffers which are not shared amongst multiple threads.
Definition: h264dec.c:221
uint8_t(* non_zero_count)[48]
Definition: h264dec.h:379
exp golomb vlc stuff
uint8_t * bipred_scratchpad
Definition: h264dec.h:280
void ff_h264_unref_picture(H264Context *h, H264Picture *pic)
Definition: h264_picture.c:45
This structure stores compressed data.
Definition: avcodec.h:1323
int droppable
Definition: h264dec.h:358
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: avcodec.h:838
int nal_ref_idc
Definition: h264dec.h:432
for(j=16;j >0;--j)
#define FF_ALLOCZ_OR_GOTO(ctx, p, size, label)
Definition: internal.h:129
int b_stride
Definition: h264dec.h:392
const uint16_t ff_h264_mb_sizes[4]
Definition: h264dec.c:56
int ff_h264_decode_seq_parameter_set(GetBitContext *gb, AVCodecContext *avctx, H264ParamSets *ps)
Decode SPS.
Definition: h264_ps.c:324
void(* decode_mb)(void *opaque, int ref, int mv_dir, int mv_type, int(*mv)[2][4][2], int mb_x, int mb_y, int mb_intra, int mb_skipped)
Context Adaptive Binary Arithmetic Coder.
#define H264_MAX_PICTURE_COUNT
Definition: h264dec.h:52