28#include "config_components.h"
54 0 + 0 * 4, 0 + 1 * 4, 1 + 0 * 4, 0 + 2 * 4,
55 0 + 3 * 4, 1 + 1 * 4, 1 + 2 * 4, 1 + 3 * 4,
56 2 + 0 * 4, 2 + 1 * 4, 2 + 2 * 4, 2 + 3 * 4,
57 3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4,
61 0 + 0 * 8, 0 + 1 * 8, 0 + 2 * 8, 1 + 0 * 8,
62 1 + 1 * 8, 0 + 3 * 8, 0 + 4 * 8, 1 + 2 * 8,
63 2 + 0 * 8, 1 + 3 * 8, 0 + 5 * 8, 0 + 6 * 8,
64 0 + 7 * 8, 1 + 4 * 8, 2 + 1 * 8, 3 + 0 * 8,
65 2 + 2 * 8, 1 + 5 * 8, 1 + 6 * 8, 1 + 7 * 8,
66 2 + 3 * 8, 3 + 1 * 8, 4 + 0 * 8, 3 + 2 * 8,
67 2 + 4 * 8, 2 + 5 * 8, 2 + 6 * 8, 2 + 7 * 8,
68 3 + 3 * 8, 4 + 1 * 8, 5 + 0 * 8, 4 + 2 * 8,
69 3 + 4 * 8, 3 + 5 * 8, 3 + 6 * 8, 3 + 7 * 8,
70 4 + 3 * 8, 5 + 1 * 8, 6 + 0 * 8, 5 + 2 * 8,
71 4 + 4 * 8, 4 + 5 * 8, 4 + 6 * 8, 4 + 7 * 8,
72 5 + 3 * 8, 6 + 1 * 8, 6 + 2 * 8, 5 + 4 * 8,
73 5 + 5 * 8, 5 + 6 * 8, 5 + 7 * 8, 6 + 3 * 8,
74 7 + 0 * 8, 7 + 1 * 8, 6 + 4 * 8, 6 + 5 * 8,
75 6 + 6 * 8, 6 + 7 * 8, 7 + 2 * 8, 7 + 3 * 8,
76 7 + 4 * 8, 7 + 5 * 8, 7 + 6 * 8, 7 + 7 * 8,
80 0 + 0 * 8, 1 + 1 * 8, 2 + 0 * 8, 0 + 7 * 8,
81 2 + 2 * 8, 2 + 3 * 8, 2 + 4 * 8, 3 + 3 * 8,
82 3 + 4 * 8, 4 + 3 * 8, 4 + 4 * 8, 5 + 3 * 8,
83 5 + 5 * 8, 7 + 0 * 8, 6 + 6 * 8, 7 + 4 * 8,
84 0 + 1 * 8, 0 + 3 * 8, 1 + 3 * 8, 1 + 4 * 8,
85 1 + 5 * 8, 3 + 1 * 8, 2 + 5 * 8, 4 + 1 * 8,
86 3 + 5 * 8, 5 + 1 * 8, 4 + 5 * 8, 6 + 1 * 8,
87 5 + 6 * 8, 7 + 1 * 8, 6 + 7 * 8, 7 + 5 * 8,
88 0 + 2 * 8, 0 + 4 * 8, 0 + 5 * 8, 2 + 1 * 8,
89 1 + 6 * 8, 4 + 0 * 8, 2 + 6 * 8, 5 + 0 * 8,
90 3 + 6 * 8, 6 + 0 * 8, 4 + 6 * 8, 6 + 2 * 8,
91 5 + 7 * 8, 6 + 4 * 8, 7 + 2 * 8, 7 + 6 * 8,
92 1 + 0 * 8, 1 + 2 * 8, 0 + 6 * 8, 3 + 0 * 8,
93 1 + 7 * 8, 3 + 2 * 8, 2 + 7 * 8, 4 + 2 * 8,
94 3 + 7 * 8, 5 + 2 * 8, 4 + 7 * 8, 5 + 4 * 8,
95 6 + 3 * 8, 6 + 5 * 8, 7 + 3 * 8, 7 + 7 * 8,
100 0 + 0 * 8, 1 + 1 * 8, 1 + 2 * 8, 2 + 2 * 8,
101 4 + 1 * 8, 0 + 5 * 8, 3 + 3 * 8, 7 + 0 * 8,
102 3 + 4 * 8, 1 + 7 * 8, 5 + 3 * 8, 6 + 3 * 8,
103 2 + 7 * 8, 6 + 4 * 8, 5 + 6 * 8, 7 + 5 * 8,
104 1 + 0 * 8, 2 + 0 * 8, 0 + 3 * 8, 3 + 1 * 8,
105 3 + 2 * 8, 0 + 6 * 8, 4 + 2 * 8, 6 + 1 * 8,
106 2 + 5 * 8, 2 + 6 * 8, 6 + 2 * 8, 5 + 4 * 8,
107 3 + 7 * 8, 7 + 3 * 8, 4 + 7 * 8, 7 + 6 * 8,
108 0 + 1 * 8, 3 + 0 * 8, 0 + 4 * 8, 4 + 0 * 8,
109 2 + 3 * 8, 1 + 5 * 8, 5 + 1 * 8, 5 + 2 * 8,
110 1 + 6 * 8, 3 + 5 * 8, 7 + 1 * 8, 4 + 5 * 8,
111 4 + 6 * 8, 7 + 4 * 8, 5 + 7 * 8, 6 + 7 * 8,
112 0 + 2 * 8, 2 + 1 * 8, 1 + 3 * 8, 5 + 0 * 8,
113 1 + 4 * 8, 2 + 4 * 8, 6 + 0 * 8, 4 + 3 * 8,
114 0 + 7 * 8, 4 + 4 * 8, 7 + 2 * 8, 3 + 6 * 8,
115 5 + 5 * 8, 6 + 5 * 8, 6 + 6 * 8, 7 + 7 * 8,
124 if (
h->DPB[
i].f->buf[0] && !
h->DPB[
i].reference &&
125 (remove_current || &
h->DPB[
i] !=
h->cur_pic_ptr)) {
142 h->mb_width * 16 * 3 *
sizeof(uint8_t) * 2);
144 h->mb_width * 16 * 3 *
sizeof(uint8_t) * 2);
165 const int big_mb_num =
h->mb_stride * (
h->mb_height + 1) + 1;
166 const int mb_array_size =
h->mb_stride *
h->mb_height;
167 const int b4_stride =
h->mb_width * 4 + 1;
168 const int b4_array_size = b4_stride *
h->mb_height * 4;
172 sizeof(uint32_t), 0);
177 if (!
h->qscale_table_pool || !
h->mb_type_pool || !
h->motion_val_pool ||
178 !
h->ref_index_pool) {
195 if (
h->sei.common.itut_t35.lcevc) {
220 if (
h->decode_error_flags_pool) {
229 int h_chroma_shift, v_chroma_shift;
231 &h_chroma_shift, &v_chroma_shift);
241 if (!
h->qscale_table_pool) {
255 for (
i = 0;
i < 2;
i++) {
281 if (!
h->DPB[
i].f->buf[0])
288#define IN_RANGE(a, b, size) (((void*)(a) >= (void*)(b)) && ((void*)(a) < (void*)((b) + (size))))
290#define REBASE_PICTURE(pic, new_ctx, old_ctx) \
291 (((pic) && (pic) >= (old_ctx)->DPB && \
292 (pic) < (old_ctx)->DPB + H264_MAX_PICTURE_COUNT) ? \
293 &(new_ctx)->DPB[(pic) - (old_ctx)->DPB] : NULL)
300 for (
i = 0;
i < count;
i++) {
314 for (
int p = 0; p <
desc->nb_components; p++) {
316 int is_chroma = p == 1 || p == 2;
319 if (
desc->comp[0].depth >= 9) {
321 ((uint16_t*)
dst)[0] =
c[p];
325 for (
int y = 1; y <
height; y++) {
326 memcpy(
dst,
frame->data[p], 2*bytes);
330 for (
int y = 0; y <
height; y++) {
331 memset(
dst,
c[p], bytes);
344 int inited =
h->context_initialized, err = 0;
351 if (inited && !h1->ps.sps)
355 (
h->width != h1->width ||
356 h->height != h1->height ||
357 h->mb_width != h1->mb_width ||
358 h->mb_height != h1->mb_height ||
360 h->ps.sps->bit_depth_luma != h1->ps.sps->bit_depth_luma ||
361 h->ps.sps->chroma_format_idc != h1->ps.sps->chroma_format_idc ||
362 h->ps.sps->vui.matrix_coeffs != h1->ps.sps->vui.matrix_coeffs)) {
367 memcpy(
h->block_offset, h1->block_offset,
sizeof(
h->block_offset));
376 h->ps.sps = h1->ps.sps;
378 if (need_reinit || !inited) {
379 h->width = h1->width;
380 h->height = h1->height;
381 h->mb_height = h1->mb_height;
382 h->mb_width = h1->mb_width;
383 h->mb_num = h1->mb_num;
384 h->mb_stride = h1->mb_stride;
385 h->b_stride = h1->b_stride;
386 h->x264_build = h1->x264_build;
388 if (
h->context_initialized || h1->context_initialized) {
396 memcpy(
h->block_offset, h1->block_offset,
sizeof(
h->block_offset));
399 h->width_from_caller = h1->width_from_caller;
400 h->height_from_caller = h1->height_from_caller;
401 h->first_field = h1->first_field;
402 h->picture_structure = h1->picture_structure;
403 h->mb_aff_frame = h1->mb_aff_frame;
404 h->droppable = h1->droppable;
417 h->enable_er = h1->enable_er;
418 h->workaround_bugs = h1->workaround_bugs;
419 h->droppable = h1->droppable;
422 h->is_avc = h1->is_avc;
423 h->nal_length_size = h1->nal_length_size;
425 memcpy(&
h->poc, &h1->poc,
sizeof(
h->poc));
427 memcpy(
h->short_ref, h1->short_ref,
sizeof(
h->short_ref));
428 memcpy(
h->long_ref, h1->long_ref,
sizeof(
h->long_ref));
429 memcpy(
h->delayed_pic, h1->delayed_pic,
sizeof(
h->delayed_pic));
430 memcpy(
h->last_pocs, h1->last_pocs,
sizeof(
h->last_pocs));
432 h->next_output_pic = h1->next_output_pic;
433 h->next_outputed_poc = h1->next_outputed_poc;
434 h->poc_offset = h1->poc_offset;
436 memcpy(
h->mmco, h1->mmco,
sizeof(
h->mmco));
437 h->nb_mmco = h1->nb_mmco;
438 h->mmco_reset = h1->mmco_reset;
439 h->explicit_ref_marking = h1->explicit_ref_marking;
440 h->long_ref_count = h1->long_ref_count;
441 h->short_ref_count = h1->short_ref_count;
448 h->frame_recovered = h1->frame_recovered;
449 h->film_grain_warning_shown = h1->film_grain_warning_shown;
455 h->sei.common.unregistered.x264_build = h1->sei.common.unregistered.x264_build;
462 h->poc.prev_poc_msb =
h->poc.poc_msb;
463 h->poc.prev_poc_lsb =
h->poc.poc_lsb;
465 h->poc.prev_frame_num_offset =
h->poc.frame_num_offset;
466 h->poc.prev_frame_num =
h->poc.frame_num;
468 h->recovery_frame = h1->recovery_frame;
469 h->non_gray = h1->non_gray;
490 const int pixel_shift =
h->pixel_shift;
498 h->cur_pic_ptr =
NULL;
507 pic->
reference =
h->droppable ? 0 :
h->picture_structure;
529 h->sei.common.film_grain_characteristics &&
530 h->sei.common.film_grain_characteristics->present &&
532 !
h->avctx->hwaccel &&
537 h->avctx->pix_fmt)) {
539 "Unsupported film grain parameters. Ignoring film grain.\n");
546 h->cur_pic_ptr = pic;
548 if (CONFIG_ERROR_RESILIENCE) {
555 for (
i = 0;
i <
h->nb_slice_ctx;
i++) {
556 h->slice_ctx[
i].linesize =
h->cur_pic_ptr->f->linesize[0];
557 h->slice_ctx[
i].uvlinesize =
h->cur_pic_ptr->f->linesize[1];
560 if (CONFIG_ERROR_RESILIENCE &&
h->enable_er) {
566 for (
i = 0;
i < 16;
i++) {
570 for (
i = 0;
i < 16;
i++) {
571 h->block_offset[16 +
i] =
573 h->block_offset[48 + 16 +
i] =
581 h->cur_pic_ptr->reference = 0;
583 h->cur_pic_ptr->field_poc[0] =
h->cur_pic_ptr->field_poc[1] = INT_MAX;
585 h->next_output_pic =
NULL;
587 h->postpone_filter = 0;
589 h->mb_aff_frame =
h->ps.sps->mb_aff && (
h->picture_structure ==
PICT_FRAME);
591 if (
h->sei.common.unregistered.x264_build >= 0)
592 h->x264_build =
h->sei.common.unregistered.x264_build;
594 assert(
h->cur_pic_ptr->long_ref == 0);
600 const uint8_t *src_y,
601 const uint8_t *src_cb,
const uint8_t *src_cr,
602 int linesize,
int uvlinesize,
607 const int pixel_shift =
h->pixel_shift;
612 src_cb -= uvlinesize;
613 src_cr -= uvlinesize;
619 AV_COPY128(top_border, src_y + 15 * linesize);
621 AV_COPY128(top_border + 16, src_y + 15 * linesize + 16);
625 AV_COPY128(top_border + 32, src_cb + 15 * uvlinesize);
626 AV_COPY128(top_border + 48, src_cb + 15 * uvlinesize + 16);
627 AV_COPY128(top_border + 64, src_cr + 15 * uvlinesize);
628 AV_COPY128(top_border + 80, src_cr + 15 * uvlinesize + 16);
630 AV_COPY128(top_border + 16, src_cb + 15 * uvlinesize);
631 AV_COPY128(top_border + 32, src_cr + 15 * uvlinesize);
633 }
else if (chroma422) {
635 AV_COPY128(top_border + 32, src_cb + 15 * uvlinesize);
636 AV_COPY128(top_border + 48, src_cr + 15 * uvlinesize);
638 AV_COPY64(top_border + 16, src_cb + 15 * uvlinesize);
639 AV_COPY64(top_border + 24, src_cr + 15 * uvlinesize);
643 AV_COPY128(top_border + 32, src_cb + 7 * uvlinesize);
644 AV_COPY128(top_border + 48, src_cr + 7 * uvlinesize);
646 AV_COPY64(top_border + 16, src_cb + 7 * uvlinesize);
647 AV_COPY64(top_border + 24, src_cr + 7 * uvlinesize);
661 AV_COPY128(top_border, src_y + 16 * linesize);
663 AV_COPY128(top_border + 16, src_y + 16 * linesize + 16);
668 AV_COPY128(top_border + 32, src_cb + 16 * linesize);
669 AV_COPY128(top_border + 48, src_cb + 16 * linesize + 16);
670 AV_COPY128(top_border + 64, src_cr + 16 * linesize);
671 AV_COPY128(top_border + 80, src_cr + 16 * linesize + 16);
673 AV_COPY128(top_border + 16, src_cb + 16 * linesize);
674 AV_COPY128(top_border + 32, src_cr + 16 * linesize);
676 }
else if (chroma422) {
678 AV_COPY128(top_border + 32, src_cb + 16 * uvlinesize);
679 AV_COPY128(top_border + 48, src_cr + 16 * uvlinesize);
681 AV_COPY64(top_border + 16, src_cb + 16 * uvlinesize);
682 AV_COPY64(top_border + 24, src_cr + 16 * uvlinesize);
686 AV_COPY128(top_border + 32, src_cb + 8 * uvlinesize);
687 AV_COPY128(top_border + 48, src_cr + 8 * uvlinesize);
689 AV_COPY64(top_border + 16, src_cb + 8 * uvlinesize);
690 AV_COPY64(top_border + 24, src_cr + 8 * uvlinesize);
703 int ref0, ref1,
i, cur_poc, ref_start, ref_count0, ref_count1;
705 for (
i = 0;
i < 2;
i++) {
712 cur_poc =
h->cur_pic_ptr->poc;
714 cur_poc =
h->cur_pic_ptr->field_poc[
h->picture_structure - 1];
726 cur_poc =
h->cur_pic_ptr->field_poc[field];
737 for (ref0 = ref_start; ref0 < ref_count0; ref0++) {
739 for (ref1 = ref_start; ref1 < ref_count1; ref1++) {
746 int tx = (16384 + (
FFABS(td) >> 1)) / td;
747 int dist_scale_factor = (tb * tx + 32) >> 8;
748 if (dist_scale_factor >= -64 && dist_scale_factor <= 128)
749 w = 64 - dist_scale_factor;
768 for (
i = 0;
i < 16;
i++) {
769#define TRANSPOSE(x) ((x) >> 2) | (((x) << 2) & 0xF)
774 for (
i = 0;
i < 64;
i++) {
775#define TRANSPOSE(x) ((x) >> 3) | (((x) & 7) << 3)
782 if (
h->ps.sps->transform_bypass) {
786 memcpy(
h->field_scan_q0 ,
field_scan ,
sizeof(
h->field_scan_q0 ));
787 memcpy(
h->field_scan8x8_q0 ,
field_scan8x8 ,
sizeof(
h->field_scan8x8_q0 ));
790 memcpy(
h->zigzag_scan_q0 ,
h->zigzag_scan ,
sizeof(
h->zigzag_scan_q0 ));
791 memcpy(
h->zigzag_scan8x8_q0 ,
h->zigzag_scan8x8 ,
sizeof(
h->zigzag_scan8x8_q0 ));
792 memcpy(
h->zigzag_scan8x8_cavlc_q0 ,
h->zigzag_scan8x8_cavlc ,
sizeof(
h->zigzag_scan8x8_cavlc_q0));
793 memcpy(
h->field_scan_q0 ,
h->field_scan ,
sizeof(
h->field_scan_q0 ));
794 memcpy(
h->field_scan8x8_q0 ,
h->field_scan8x8 ,
sizeof(
h->field_scan8x8_q0 ));
795 memcpy(
h->field_scan8x8_cavlc_q0 ,
h->field_scan8x8_cavlc ,
sizeof(
h->field_scan8x8_cavlc_q0 ));
800 int data_partitioning)
802#define HWACCEL_MAX (CONFIG_H264_DXVA2_HWACCEL + \
803 (CONFIG_H264_D3D11VA_HWACCEL * 2) + \
804 CONFIG_H264_D3D12VA_HWACCEL + \
805 CONFIG_H264_NVDEC_HWACCEL + \
806 CONFIG_H264_NVDEC_CUARRAY_HWACCEL + \
807 CONFIG_H264_VAAPI_HWACCEL + \
808 CONFIG_H264_VIDEOTOOLBOX_HWACCEL + \
809 CONFIG_H264_VDPAU_HWACCEL + \
810 CONFIG_H264_VULKAN_HWACCEL)
813 switch (
h->ps.sps->bit_depth_luma) {
826#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL
830#if CONFIG_H264_VULKAN_HWACCEL
833#if CONFIG_H264_NVDEC_HWACCEL
836#if CONFIG_H264_NVDEC_CUARRAY_HWACCEL
847#if CONFIG_H264_VAAPI_HWACCEL
857#if CONFIG_H264_VULKAN_HWACCEL
882#if CONFIG_H264_VDPAU_HWACCEL
885#if CONFIG_H264_VULKAN_HWACCEL
888#if CONFIG_H264_NVDEC_HWACCEL
891#if CONFIG_H264_NVDEC_CUARRAY_HWACCEL
894#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL
911#if CONFIG_H264_DXVA2_HWACCEL
914#if CONFIG_H264_D3D11VA_HWACCEL
918#if CONFIG_H264_D3D12VA_HWACCEL
921#if CONFIG_H264_VAAPI_HWACCEL
932 "Unsupported bit depth %d\n",
h->ps.sps->bit_depth_luma);
937 if (data_partitioning) {
945 if (
pix_fmts[
i] ==
h->avctx->pix_fmt && !force_callback)
954 int cr =
sps->crop_right;
955 int cl =
sps->crop_left;
956 int ct =
sps->crop_top;
957 int cb =
sps->crop_bottom;
964 if (
h->width_from_caller > 0 &&
h->height_from_caller > 0 &&
965 !
sps->crop_top && !
sps->crop_left &&
968 h->width_from_caller <=
width &&
969 h->height_from_caller <=
height) {
970 width =
h->width_from_caller;
971 height =
h->height_from_caller;
977 h->width_from_caller = 0;
978 h->height_from_caller = 0;
981 h->avctx->coded_width =
h->width;
982 h->avctx->coded_height =
h->height;
1003 &
h->chroma_x_shift, &
h->chroma_y_shift);
1005 if (
sps->timing_info_present_flag) {
1007 if (
h->x264_build < 44U)
1009 av_reduce(&
h->avctx->framerate.den, &
h->avctx->framerate.num,
1010 sps->num_units_in_tick * 2, den, 1 << 30);
1016 h->prev_interlaced_frame = 1;
1025 if (
sps->bit_depth_luma < 8 ||
sps->bit_depth_luma > 14 ||
1026 sps->bit_depth_luma == 11 ||
sps->bit_depth_luma == 13
1029 sps->bit_depth_luma);
1034 h->cur_bit_depth_luma =
1035 h->avctx->bits_per_raw_sample =
sps->bit_depth_luma;
1036 h->cur_chroma_format_idc =
sps->chroma_format_idc;
1037 h->pixel_shift =
sps->bit_depth_luma > 8;
1038 h->chroma_format_idc =
sps->chroma_format_idc;
1039 h->bit_depth_luma =
sps->bit_depth_luma;
1042 sps->chroma_format_idc);
1046 sps->chroma_format_idc);
1052 for (
i = 0;
i <
h->nb_slice_ctx;
i++) {
1057 sl->
mvd_table[0] =
h->mvd_table[0] +
i * 8 * 2 *
h->mb_stride;
1058 sl->
mvd_table[1] =
h->mvd_table[1] +
i * 8 * 2 *
h->mb_stride;
1064 h->context_initialized = 1;
1069 h->context_initialized = 0;
1087 int needs_reinit = 0, must_reinit,
ret;
1092 if (
h->ps.sps !=
h->ps.pps->sps) {
1093 h->ps.sps =
h->ps.pps->sps;
1095 if (
h->mb_width !=
h->ps.sps->mb_width ||
1096 h->mb_height !=
h->ps.sps->mb_height ||
1097 h->cur_bit_depth_luma !=
h->ps.sps->bit_depth_luma ||
1098 h->cur_chroma_format_idc !=
h->ps.sps->chroma_format_idc
1102 if (
h->bit_depth_luma !=
h->ps.sps->bit_depth_luma ||
1103 h->chroma_format_idc !=
h->ps.sps->chroma_format_idc)
1108 must_reinit = (
h->context_initialized &&
1109 ( 16*
sps->mb_width !=
h->avctx->coded_width
1110 || 16*
sps->mb_height !=
h->avctx->coded_height
1111 ||
h->cur_bit_depth_luma !=
sps->bit_depth_luma
1112 ||
h->cur_chroma_format_idc !=
sps->chroma_format_idc
1113 ||
h->mb_width !=
sps->mb_width
1114 ||
h->mb_height !=
sps->mb_height
1121 if (first_slice &&
av_cmp_q(
sps->vui.sar,
h->avctx->sample_aspect_ratio))
1124 if (!
h->setup_finished) {
1126 h->avctx->level =
sps->level_idc;
1127 h->avctx->refs =
sps->ref_frame_count;
1129 h->mb_width =
sps->mb_width;
1130 h->mb_height =
sps->mb_height;
1131 h->mb_num =
h->mb_width *
h->mb_height;
1132 h->mb_stride =
h->mb_width + 1;
1134 h->b_stride =
h->mb_width * 4;
1136 h->chroma_y_shift =
sps->chroma_format_idc <= 1;
1138 h->width = 16 *
h->mb_width;
1139 h->height = 16 *
h->mb_height;
1143 if (
sps->vui.video_signal_type_present_flag) {
1146 if (
sps->vui.colour_description_present_flag) {
1147 if (
h->avctx->colorspace !=
sps->vui.matrix_coeffs)
1149 h->avctx->color_primaries =
sps->vui.colour_primaries;
1150 h->avctx->color_trc =
sps->vui.transfer_characteristics;
1151 h->avctx->colorspace =
sps->vui.matrix_coeffs;
1155 if (
h->sei.common.alternative_transfer.present &&
1158 h->avctx->color_trc =
h->sei.common.alternative_transfer.preferred_transfer_characteristics;
1161 h->avctx->chroma_sample_location =
sps->vui.chroma_location;
1163 if (!
h->context_initialized || must_reinit || needs_reinit) {
1164 int flush_changes =
h->context_initialized;
1165 h->context_initialized = 0;
1166 if (sl !=
h->slice_ctx) {
1168 "changing width %d -> %d / height %d -> %d on "
1170 h->width,
h->avctx->coded_width,
1171 h->height,
h->avctx->coded_height,
1172 h->current_slice + 1);
1184 h->avctx->pix_fmt =
ret;
1191 "h264_slice_header_init() failed\n");
1204 int interlaced_frame = 0, top_field_first = 0;
1208 out->repeat_pict = 0;
1213 if (
h->sei.picture_timing.present) {
1220 h->sei.picture_timing.present = 0;
1224 if (
sps->pic_struct_present_flag &&
h->sei.picture_timing.present) {
1226 switch (
pt->pic_struct) {
1231 interlaced_frame = 1;
1236 interlaced_frame = 1;
1239 interlaced_frame = !!
h->prev_interlaced_frame;
1246 out->repeat_pict = 1;
1249 out->repeat_pict = 2;
1252 out->repeat_pict = 4;
1256 if ((
pt->ct_type & 3) &&
1258 interlaced_frame = ((
pt->ct_type & (1 << 1)) != 0);
1263 h->prev_interlaced_frame = interlaced_frame;
1269 if (
sps->pic_struct_present_flag &&
h->sei.picture_timing.present) {
1274 top_field_first = 1;
1275 }
else if (interlaced_frame) {
1278 top_field_first = 1;
1287 &
sps->vui,
sps->bit_depth_luma,
sps->bit_depth_chroma,
1288 cur->
poc + (
unsigned)(
h->poc_offset << 5));
1292 if (
h->sei.picture_timing.timecode_cnt > 0) {
1297 sizeof(uint32_t)*4, &tcside);
1302 tc_sd = (uint32_t*)tcside->
data;
1303 tc_sd[0] =
h->sei.picture_timing.timecode_cnt;
1305 for (
int i = 0;
i < tc_sd[0];
i++) {
1306 int drop =
h->sei.picture_timing.timecode[
i].dropframe;
1307 int hh =
h->sei.picture_timing.timecode[
i].hours;
1308 int mm =
h->sei.picture_timing.timecode[
i].minutes;
1309 int ss =
h->sei.picture_timing.timecode[
i].seconds;
1310 int ff =
h->sei.picture_timing.timecode[
i].frame;
1317 h->sei.picture_timing.timecode_cnt = 0;
1328 int i, pics, out_of_order, out_idx;
1333 if (
sps->bitstream_restriction_flag ||
1335 h->avctx->has_b_frames =
FFMAX(
h->avctx->has_b_frames,
sps->num_reorder_frames);
1338 for (
i = 0; 1;
i++) {
1341 h->last_pocs[
i-1] = cur->
poc;
1344 h->last_pocs[
i-1]=
h->last_pocs[
i];
1350 out_of_order =
FFMAX(out_of_order, 1);
1354 h->last_pocs[
i] = INT_MIN;
1355 h->last_pocs[0] = cur->
poc;
1357 }
else if(
h->avctx->has_b_frames < out_of_order && !
sps->bitstream_restriction_flag){
1359 av_log(
h->avctx, loglevel,
"Increasing reorder buffer to %d\n", out_of_order);
1360 h->avctx->has_b_frames = out_of_order;
1364 while (
h->delayed_pic[pics])
1369 h->delayed_pic[pics++] = cur;
1373 out =
h->delayed_pic[0];
1375 for (
i = 1;
h->delayed_pic[
i] &&
1377 !
h->delayed_pic[
i]->mmco_reset;
1379 if (
h->delayed_pic[
i]->poc <
out->poc) {
1380 out =
h->delayed_pic[
i];
1385 h->next_outputed_poc = INT_MIN;
1386 out_of_order =
out->poc <
h->next_outputed_poc;
1388 if (out_of_order || pics >
h->avctx->has_b_frames) {
1390 for (
i = out_idx;
h->delayed_pic[
i];
i++)
1391 h->delayed_pic[
i] =
h->delayed_pic[
i + 1];
1393 if (!out_of_order && pics >
h->avctx->has_b_frames) {
1394 h->next_output_pic =
out;
1395 if (out_idx == 0 &&
h->delayed_pic[0] && ((
h->delayed_pic[0]->f->flags &
AV_FRAME_FLAG_KEY) ||
h->delayed_pic[0]->mmco_reset)) {
1396 h->next_outputed_poc = INT_MIN;
1398 h->next_outputed_poc =
out->poc;
1402 h->frame_recovered |=
out->recovered;
1406 if (!
out->recovered) {
1409 h->next_output_pic =
NULL;
1431 int last_pic_structure, last_pic_droppable,
ret;
1439 if (
sps->bitstream_restriction_flag &&
1440 h->avctx->has_b_frames <
sps->num_reorder_frames) {
1441 h->avctx->has_b_frames =
sps->num_reorder_frames;
1444 last_pic_droppable =
h->droppable;
1445 last_pic_structure =
h->picture_structure;
1446 h->droppable = (
nal->ref_idc == 0);
1457 else if (
h->picture_intra_only)
1462 if (
h->poc.frame_num !=
h->poc.prev_frame_num) {
1463 int unwrap_prev_frame_num =
h->poc.prev_frame_num;
1464 int max_frame_num = 1 <<
sps->log2_max_frame_num;
1466 if (unwrap_prev_frame_num >
h->poc.frame_num)
1467 unwrap_prev_frame_num -= max_frame_num;
1469 if ((
h->poc.frame_num - unwrap_prev_frame_num) >
sps->ref_frame_count) {
1470 unwrap_prev_frame_num = (
h->poc.frame_num -
sps->ref_frame_count) - 1;
1471 if (unwrap_prev_frame_num < 0)
1472 unwrap_prev_frame_num += max_frame_num;
1474 h->poc.prev_frame_num = unwrap_prev_frame_num;
1483 if (
h->first_field) {
1490 if (
h->cur_pic_ptr->tf.owner[last_field] ==
h->avctx) {
1495 if (!
FIELD_PICTURE(
h) ||
h->picture_structure == last_pic_structure) {
1503 if (
h->cur_pic_ptr->frame_num !=
h->poc.frame_num) {
1519 "Invalid field mode combination %d/%d\n",
1520 last_pic_structure,
h->picture_structure);
1521 h->picture_structure = last_pic_structure;
1522 h->droppable = last_pic_droppable;
1524 }
else if (last_pic_droppable !=
h->droppable) {
1526 "Found reference and non-reference fields in the same frame, which");
1527 h->picture_structure = last_pic_structure;
1528 h->droppable = last_pic_droppable;
1535 while (
h->poc.frame_num !=
h->poc.prev_frame_num && !
h->first_field &&
1536 h->poc.frame_num != (
h->poc.prev_frame_num + 1) % (1 <<
sps->log2_max_frame_num)) {
1539 h->poc.frame_num,
h->poc.prev_frame_num);
1540 if (!
sps->gaps_in_frame_num_allowed_flag)
1542 h->last_pocs[
i] = INT_MIN;
1549 h->poc.prev_frame_num++;
1550 h->poc.prev_frame_num %= 1 <<
sps->log2_max_frame_num;
1551 h->cur_pic_ptr->frame_num =
h->poc.prev_frame_num;
1552 h->cur_pic_ptr->invalid_gap = !
sps->gaps_in_frame_num_allowed_flag;
1556 h->explicit_ref_marking = 0;
1567 if (
h->short_ref_count) {
1569 1<<(
h->ps.sps->bit_depth_luma-1),
1570 1<<(
h->ps.sps->bit_depth_chroma-1),
1571 1<<(
h->ps.sps->bit_depth_chroma-1),
1576 h->short_ref[0]->f->width == prev->
f->
width &&
1577 h->short_ref[0]->f->height == prev->
f->
height &&
1578 h->short_ref[0]->f->format == prev->
f->
format) {
1583 h->short_ref[0]->tf.f =
h->short_ref[0]->f;
1587 h->short_ref[0]->poc = prev->
poc + 2U;
1590 h->short_ref[0]->field_poc[0] =
h->short_ref[0]->poc;
1591 h->short_ref[0]->field_poc[1] =
h->short_ref[0]->poc;
1592 h->short_ref[0]->gray = prev->
gray;
1600 if (
h->short_ref[0]->field_picture)
1602 }
else if (!
h->frame_recovered) {
1605 h->short_ref[0]->gray = 1;
1607 h->short_ref[0]->frame_num =
h->poc.prev_frame_num;
1614 if (
h->first_field) {
1620 if (!
FIELD_PICTURE(
h) ||
h->picture_structure == last_pic_structure) {
1623 h->missing_fields ++;
1624 h->cur_pic_ptr =
NULL;
1627 h->missing_fields = 0;
1628 if (
h->cur_pic_ptr->frame_num !=
h->poc.frame_num) {
1635 h->cur_pic_ptr =
NULL;
1641 h->cur_pic_ptr =
NULL;
1660 h->cur_pic_ptr->tf.owner[field] =
h->avctx;
1663 if (CONFIG_ERROR_RESILIENCE)
1670 memset(
h->slice_table +
i*
h->mb_stride, -1, (
h->mb_stride - (
i+1==
h->mb_height)) *
sizeof(*
h->slice_table));
1672 memset(
h->slice_table, -1,
1673 (
h->mb_height *
h->mb_stride - 1) *
sizeof(*
h->slice_table));
1677 h->ps.sps, &
h->poc,
h->picture_structure,
nal->ref_idc);
1687 if (
h->sei.recovery_point.recovery_frame_cnt >= 0) {
1688 const int sei_recovery_frame_cnt =
h->sei.recovery_point.recovery_frame_cnt;
1691 h->valid_recovery_point = 1;
1693 if (
h->recovery_frame < 0
1694 ||
av_zero_extend(
h->recovery_frame -
h->poc.frame_num,
h->ps.sps->log2_max_frame_num) > sei_recovery_frame_cnt) {
1695 h->recovery_frame =
av_zero_extend(
h->poc.frame_num + sei_recovery_frame_cnt,
h->ps.sps->log2_max_frame_num);
1697 if (!
h->valid_recovery_point)
1698 h->recovery_frame =
h->poc.frame_num;
1711 if (
h->recovery_frame ==
h->poc.frame_num &&
nal->ref_idc) {
1712 h->recovery_frame = -1;
1717 h->cur_pic_ptr->recovered |=
h->frame_recovered;
1744 unsigned int slice_type,
tmp,
i;
1745 int field_pic_flag, bottom_field_flag;
1746 int first_slice = sl ==
h->slice_ctx && !
h->current_slice;
1747 int picture_structure;
1755 if (slice_type > 9) {
1757 "slice type %d too large at %d\n",
1761 if (slice_type > 4) {
1782 if (!
h->ps.pps_list[sl->
pps_id]) {
1784 "non-existing PPS %u referenced\n",
1802 if (
sps->frame_mbs_only_flag) {
1806 av_log(
h->avctx,
AV_LOG_ERROR,
"This stream was generated by a broken encoder, invalid 8x8 inference\n");
1810 if (field_pic_flag) {
1830 if (idr_pic_id < 65536) {
1838 if (
sps->poc_type == 0) {
1841 if (
pps->pic_order_present == 1 && picture_structure ==
PICT_FRAME)
1846 if (
sps->poc_type == 1 && !
sps->delta_pic_order_always_zero_flag) {
1849 if (
pps->pic_order_present == 1 && picture_structure ==
PICT_FRAME)
1854 if (
pps->redundant_pic_cnt_present)
1862 picture_structure,
h->avctx);
1875 for (
i = 0;
i < 2;
i++) {
1880 (
pps->weighted_bipred_idc == 1 &&
1884 picture_structure,
h->avctx);
1907 if (
tmp > 51 + 6 * (
sps->bit_depth_luma - 8)) {
1924 if (
pps->deblocking_filter_parameters_present) {
1928 "deblocking_filter_idc %u out of range\n",
tmp);
1938 if (slice_alpha_c0_offset_div2 > 6 ||
1939 slice_alpha_c0_offset_div2 < -6 ||
1940 slice_beta_offset_div2 > 6 ||
1941 slice_beta_offset_div2 < -6) {
1943 "deblocking filter parameters %d %d out of range\n",
1944 slice_alpha_c0_offset_div2, slice_beta_offset_div2);
1984 if (
h->ps.pps->weighted_bipred_idc == 2 &&
2014 h->postpone_filter = 1;
2020 h->ps.pps->chroma_qp_index_offset[0],
2021 h->ps.pps->chroma_qp_index_offset[1]) +
2022 6 * (
h->ps.sps->bit_depth_luma - 8);
2025 if (
h->current_slice >= 0xFFFE) {
2041 for (j = 0; j < 2; j++) {
2044 for (
i = 0;
i < 16;
i++) {
2046 if (j < sl->list_count &&
i < sl->ref_count[j] &&
2050 for (k = 0; k <
h->short_ref_count; k++)
2051 if (
h->short_ref[k]->f->buf[0]->buffer == buf) {
2055 for (k = 0; k <
h->long_ref_count; k++)
2056 if (
h->long_ref[k] &&
h->long_ref[k]->f->buf[0]->buffer == buf) {
2057 id_list[
i] =
h->short_ref_count + k;
2065 for (
i = 0;
i < 16;
i++)
2068 ref2frm[18 + 1] = -1;
2069 for (
i = 16;
i < 48;
i++)
2070 ref2frm[
i + 4] = 4 * id_list[(
i - 16) >> 1] +
2075 h->cur_pic_ptr->gray = 0;
2084 h->cur_pic_ptr->gray = gray;
2089 "slice:%d %c mb:%d %c%s%s frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s %s\n",
2097 h->cur_pic_ptr->field_poc[0],
2098 h->cur_pic_ptr->field_poc[1],
2116 unsigned nb_slice_ids =
sps->mb_width *
sps->mb_height;
2127 if (sl->
slice_id >= nb_slice_ids) {
2142 int redundant_pic_cnt = 0;
2149 if (
pps->sps->residual_color_transform_flag)
2151 if (
pps->redundant_pic_cnt_present)
2162 "match the preceding partition A\n",
2182 int first_slice = sl ==
h->slice_ctx && !
h->current_slice;
2209 if (
h->setup_finished) {
2216 if (
h->current_slice) {
2219 if (
h->nb_slice_ctx_queued) {
2226 memcpy(&tmp_ctx,
h->slice_ctx,
sizeof(tmp_ctx));
2227 memcpy(
h->slice_ctx, sl,
sizeof(tmp_ctx));
2228 memcpy(sl, &tmp_ctx,
sizeof(tmp_ctx));
2241 h->cur_pic_ptr =
NULL;
2248 if (!
h->first_field) {
2249 if (
h->cur_pic_ptr && !
h->droppable) {
2253 h->cur_pic_ptr =
NULL;
2257 if (!
h->current_slice)
2260 if (
h->current_slice == 0 && !
h->first_field) {
2274 if (
h->ps.pps->sps_id !=
pps->sps_id ||
2275 h->ps.pps->transform_8x8_mode !=
pps->transform_8x8_mode
2280 if (
h->ps.sps !=
pps->sps) {
2282 "SPS changed in the middle of the frame\n");
2287 if (
h->current_slice == 0) {
2293 h->droppable != (
nal->ref_idc == 0)) {
2295 "Changing field mode (%d -> %d) between slices is not allowed\n",
2298 }
else if (!
h->cur_pic_ptr) {
2300 "unset cur_pic_ptr on slice %d\n",
2301 h->current_slice + 1);
2310 h->nb_slice_ctx_queued++;
2336 int mb_type,
int top_xy,
2340 int mb_xy,
int list)
2342 int b_stride =
h->b_stride;
2347 const int b_xy =
h->mb2b_xy[top_xy] + 3 * b_stride;
2348 const int b8_xy = 4 * top_xy + 2;
2351 ref_cache[0 - 1 * 8] =
2352 ref_cache[1 - 1 * 8] = ref2frm[
h->cur_pic.ref_index[
list][b8_xy + 0]];
2353 ref_cache[2 - 1 * 8] =
2354 ref_cache[3 - 1 * 8] = ref2frm[
h->cur_pic.ref_index[
list][b8_xy + 1]];
2362 const int b_xy =
h->mb2b_xy[left_xy[
LTOP]] + 3;
2363 const int b8_xy = 4 * left_xy[
LTOP] + 1;
2365 AV_COPY32(mv_dst - 1 + 0,
h->cur_pic.motion_val[
list][b_xy + b_stride * 0]);
2366 AV_COPY32(mv_dst - 1 + 8,
h->cur_pic.motion_val[
list][b_xy + b_stride * 1]);
2367 AV_COPY32(mv_dst - 1 + 16,
h->cur_pic.motion_val[
list][b_xy + b_stride * 2]);
2368 AV_COPY32(mv_dst - 1 + 24,
h->cur_pic.motion_val[
list][b_xy + b_stride * 3]);
2370 ref_cache[-1 + 8] = ref2frm[
h->cur_pic.ref_index[
list][b8_xy + 2 * 0]];
2371 ref_cache[-1 + 16] =
2372 ref_cache[-1 + 24] = ref2frm[
h->cur_pic.ref_index[
list][b8_xy + 2 * 1]];
2380 ref_cache[-1 + 16] =
2396 const int8_t *
ref = &
h->cur_pic.ref_index[
list][4 * mb_xy];
2398 uint32_t ref01 = (
pack16to32(ref2frm[
ref[0]], ref2frm[
ref[1]]) & 0x00FF00FF) * 0x0101;
2399 uint32_t ref23 = (
pack16to32(ref2frm[
ref[2]], ref2frm[
ref[3]]) & 0x00FF00FF) * 0x0101;
2400 AV_WN32A(&ref_cache[0 * 8], ref01);
2401 AV_WN32A(&ref_cache[1 * 8], ref01);
2402 AV_WN32A(&ref_cache[2 * 8], ref23);
2403 AV_WN32A(&ref_cache[3 * 8], ref23);
2407 int16_t(*mv_src)[2] = &
h->cur_pic.motion_val[
list][4 * sl->
mb_x + 4 * sl->
mb_y * b_stride];
2408 AV_COPY128(mv_dst + 8 * 0, mv_src + 0 * b_stride);
2409 AV_COPY128(mv_dst + 8 * 1, mv_src + 1 * b_stride);
2410 AV_COPY128(mv_dst + 8 * 2, mv_src + 2 * b_stride);
2411 AV_COPY128(mv_dst + 8 * 3, mv_src + 3 * b_stride);
2420 const int mb_xy = sl->
mb_xy;
2426 top_xy = mb_xy - (
h->mb_stride <<
MB_FIELD(sl));
2428 left_xy[
LBOT] = left_xy[
LTOP] = mb_xy - 1;
2430 const int left_mb_field_flag =
IS_INTERLACED(
h->cur_pic.mb_type[mb_xy - 1]);
2433 if (left_mb_field_flag != curr_mb_field_flag)
2434 left_xy[
LTOP] -=
h->mb_stride;
2436 if (curr_mb_field_flag)
2437 top_xy +=
h->mb_stride &
2438 (((
h->cur_pic.mb_type[top_xy] >> 7) & 1) - 1);
2439 if (left_mb_field_flag != curr_mb_field_flag)
2440 left_xy[
LBOT] +=
h->mb_stride;
2452 int qp =
h->cur_pic.qscale_table[mb_xy];
2453 if (qp <= qp_thresh &&
2454 (left_xy[
LTOP] < 0 ||
2455 ((qp +
h->cur_pic.qscale_table[left_xy[
LTOP]] + 1) >> 1) <= qp_thresh) &&
2457 ((qp +
h->cur_pic.qscale_table[top_xy] + 1) >> 1) <= qp_thresh)) {
2460 if ((left_xy[
LTOP] < 0 ||
2461 ((qp +
h->cur_pic.qscale_table[left_xy[
LBOT]] + 1) >> 1) <= qp_thresh) &&
2462 (top_xy < h->mb_stride ||
2463 ((qp +
h->cur_pic.qscale_table[top_xy -
h->mb_stride] + 1) >> 1) <= qp_thresh))
2468 top_type =
h->cur_pic.mb_type[top_xy];
2469 left_type[
LTOP] =
h->cur_pic.mb_type[left_xy[
LTOP]];
2470 left_type[
LBOT] =
h->cur_pic.mb_type[left_xy[
LBOT]];
2475 left_type[
LTOP] = left_type[
LBOT] = 0;
2477 if (
h->slice_table[top_xy] == 0xFFFF)
2479 if (
h->slice_table[left_xy[
LBOT]] == 0xFFFF)
2480 left_type[
LTOP] = left_type[
LBOT] = 0;
2490 top_type, left_type, mb_xy, 0);
2493 top_type, left_type, mb_xy, 1);
2495 nnz =
h->non_zero_count[mb_xy];
2497 AV_COPY32(&nnz_cache[4 + 8 * 1], &nnz[0]);
2498 AV_COPY32(&nnz_cache[4 + 8 * 2], &nnz[4]);
2499 AV_COPY32(&nnz_cache[4 + 8 * 3], &nnz[8]);
2500 AV_COPY32(&nnz_cache[4 + 8 * 4], &nnz[12]);
2501 sl->
cbp =
h->cbp_table[mb_xy];
2504 nnz =
h->non_zero_count[top_xy];
2505 AV_COPY32(&nnz_cache[4 + 8 * 0], &nnz[3 * 4]);
2508 if (left_type[
LTOP]) {
2509 nnz =
h->non_zero_count[left_xy[
LTOP]];
2510 nnz_cache[3 + 8 * 1] = nnz[3 + 0 * 4];
2511 nnz_cache[3 + 8 * 2] = nnz[3 + 1 * 4];
2512 nnz_cache[3 + 8 * 3] = nnz[3 + 2 * 4];
2513 nnz_cache[3 + 8 * 4] = nnz[3 + 3 * 4];
2518 if (!
CABAC(
h) &&
h->ps.pps->transform_8x8_mode) {
2520 nnz_cache[4 + 8 * 0] =
2521 nnz_cache[5 + 8 * 0] = (
h->cbp_table[top_xy] & 0x4000) >> 12;
2522 nnz_cache[6 + 8 * 0] =
2523 nnz_cache[7 + 8 * 0] = (
h->cbp_table[top_xy] & 0x8000) >> 12;
2526 nnz_cache[3 + 8 * 1] =
2527 nnz_cache[3 + 8 * 2] = (
h->cbp_table[left_xy[
LTOP]] & 0x2000) >> 12;
2530 nnz_cache[3 + 8 * 3] =
2531 nnz_cache[3 + 8 * 4] = (
h->cbp_table[left_xy[
LBOT]] & 0x8000) >> 12;
2535 nnz_cache[
scan8[0]] =
2536 nnz_cache[
scan8[1]] =
2537 nnz_cache[
scan8[2]] =
2538 nnz_cache[
scan8[3]] = (sl->
cbp & 0x1000) >> 12;
2540 nnz_cache[
scan8[0 + 4]] =
2541 nnz_cache[
scan8[1 + 4]] =
2542 nnz_cache[
scan8[2 + 4]] =
2543 nnz_cache[
scan8[3 + 4]] = (sl->
cbp & 0x2000) >> 12;
2545 nnz_cache[
scan8[0 + 8]] =
2546 nnz_cache[
scan8[1 + 8]] =
2547 nnz_cache[
scan8[2 + 8]] =
2548 nnz_cache[
scan8[3 + 8]] = (sl->
cbp & 0x4000) >> 12;
2550 nnz_cache[
scan8[0 + 12]] =
2551 nnz_cache[
scan8[1 + 12]] =
2552 nnz_cache[
scan8[2 + 12]] =
2553 nnz_cache[
scan8[3 + 12]] = (sl->
cbp & 0x8000) >> 12;
2562 uint8_t *dest_y, *dest_cb, *dest_cr;
2563 int linesize, uvlinesize, mb_x, mb_y;
2566 const int pixel_shift =
h->pixel_shift;
2567 const int block_h = 16 >>
h->chroma_y_shift;
2569 if (
h->postpone_filter)
2573 for (mb_x = start_x; mb_x < end_x; mb_x++)
2574 for (mb_y = end_mb_y -
FRAME_MBAFF(
h); mb_y <= end_mb_y; mb_y++) {
2576 mb_xy = sl->
mb_xy = mb_x + mb_y *
h->mb_stride;
2577 mb_type =
h->cur_pic.mb_type[mb_xy];
2585 dest_y =
h->cur_pic.f->data[0] +
2586 ((mb_x << pixel_shift) + mb_y * sl->
linesize) * 16;
2587 dest_cb =
h->cur_pic.f->data[1] +
2588 (mb_x << pixel_shift) * (8 <<
CHROMA444(
h)) +
2590 dest_cr =
h->cur_pic.f->data[2] +
2591 (mb_x << pixel_shift) * (8 <<
CHROMA444(
h)) +
2616 linesize, uvlinesize);
2619 dest_cr, linesize, uvlinesize);
2632 const int mb_xy = sl->
mb_x + sl->
mb_y *
h->mb_stride;
2633 int mb_type = (
h->slice_table[mb_xy - 1] == sl->
slice_num) ?
2634 h->cur_pic.mb_type[mb_xy - 1] :
2635 (
h->slice_table[mb_xy -
h->mb_stride] == sl->
slice_num) ?
2636 h->cur_pic.mb_type[mb_xy -
h->mb_stride] : 0;
2651 if ((top +
height) >= pic_height)
2652 height += deblock_border;
2653 top -= deblock_border;
2656 if (top >= pic_height || (top +
height) < 0)
2667 if (
h->droppable ||
h->er.error_occurred)
2675 int startx,
int starty,
2676 int endx,
int endy,
int status)
2681 if (CONFIG_ERROR_RESILIENCE) {
2690 int lf_x_start = sl->
mb_x;
2694 sl->
linesize =
h->cur_pic_ptr->f->linesize[0];
2705 if (
h->postpone_filter)
2715 prev_status &= ~ VP_START;
2721 if (
h->ps.pps->cabac) {
2765 if (sl->
mb_x >= lf_x_start)
2773 "error while decoding MB %d %d, bytestream %td\n",
2781 if (++sl->
mb_x >=
h->mb_width) {
2783 sl->
mb_x = lf_x_start = 0;
2793 if (eos || sl->
mb_y >=
h->mb_height) {
2794 ff_tlog(
h->avctx,
"slice end %d %d\n",
2798 if (sl->
mb_x > lf_x_start)
2832 "error while decoding MB %d %d\n", sl->
mb_x, sl->
mb_y);
2838 if (++sl->
mb_x >=
h->mb_width) {
2840 sl->
mb_x = lf_x_start = 0;
2848 if (sl->
mb_y >=
h->mb_height) {
2849 ff_tlog(
h->avctx,
"slice end %d %d\n",
2868 ff_tlog(
h->avctx,
"slice end %d %d\n",
2874 if (sl->
mb_x > lf_x_start)
2902 int context_count =
h->nb_slice_ctx_queued;
2906 h->slice_ctx[0].next_slice_idx = INT_MAX;
2908 if (
h->avctx->hwaccel || context_count < 1)
2912 h->mb_y =
h->mb_height;
2916 av_assert0(context_count &&
h->slice_ctx[context_count - 1].mb_y <
h->mb_height);
2918 if (context_count == 1) {
2920 h->slice_ctx[0].next_slice_idx =
h->mb_width *
h->mb_height;
2921 h->postpone_filter = 0;
2924 h->mb_y =
h->slice_ctx[0].mb_y;
2929 for (
i = 0;
i < context_count;
i++) {
2930 int next_slice_idx =
h->mb_width *
h->mb_height;
2933 sl = &
h->slice_ctx[
i];
2936 slice_idx = sl->
mb_y *
h->mb_width + sl->
mb_x;
2937 for (j = 0; j < context_count; j++) {
2939 int slice_idx2 = sl2->
mb_y *
h->mb_width + sl2->
mb_x;
2941 if (
i == j || slice_idx2 < slice_idx)
2943 next_slice_idx =
FFMIN(next_slice_idx, slice_idx2);
2949 NULL, context_count,
sizeof(
h->slice_ctx[0]));
2952 sl = &
h->slice_ctx[context_count - 1];
2955 if (
h->postpone_filter) {
2956 h->postpone_filter = 0;
2958 for (
i = 0;
i < context_count;
i++) {
2961 sl = &
h->slice_ctx[
i];
2963 x_end = (sl->
mb_y >=
h->mb_height) ?
h->mb_width : sl->
mb_x;
2968 j == y_end - 1 ? x_end :
h->mb_width);
2975 h->nb_slice_ctx_queued = 0;
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
#define FF_DEBUG_PICT_INFO
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
int ff_init_cabac_decoder(CABACContext *c, const uint8_t *buf, int buf_size)
Context Adaptive Binary Arithmetic Coder.
Context Adaptive Binary Arithmetic Coder inline functions.
static av_unused int get_cabac_terminate(CABACContext *c)
#define i(width, name, range_min, range_max)
static int FUNC sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
static int FUNC nal(CodedBitstreamContext *ctx, RWContext *rw, LCEVCRawNAL *current, int nal_unit_type)
#define ss(width, name, subs,...)
#define AV_CEIL_RSHIFT(a, b)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
int ff_frame_new_side_data_from_buf(const AVCodecContext *avctx, AVFrame *frame, enum AVFrameSideDataType type, AVBufferRef **buf)
Similar to ff_frame_new_side_data, but using an existing buffer ref.
int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt)
Select the (possibly hardware accelerated) pixel format.
int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_private)
Allocate a hwaccel frame private data if the provided avctx uses a hwaccel method that needs it.
int ff_frame_new_side_data(const AVCodecContext *avctx, AVFrame *frame, enum AVFrameSideDataType type, size_t size, AVFrameSideData **psd)
Wrapper around av_frame_new_side_data, which rejects side data overridden by the demuxer.
static int ff_decode_skip_all_pixels(const AVCodecContext *avctx)
int ff_set_sar(AVCodecContext *avctx, AVRational sar)
Check that the provided sample aspect ratio is valid and set it on the codec context.
#define FF_COMPLIANCE_STRICT
Strictly conform to all the things in the spec no matter what consequences.
#define AV_EF_EXPLODE
abort decoding on minor error detection
#define AV_EF_AGGRESSIVE
consider things that a sane encoder/muxer should not do as an error
void ff_er_add_slice(ERContext *s, int startx, int starty, int endx, int endy, int status)
Add a slice.
void ff_er_frame_start(ERContext *s)
static void fill_rectangle(int x, int y, int w, int h)
static int decode_slice(AVCodecContext *c, void *arg)
static int get_bits_left(GetBitContext *gb)
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static const uint8_t * align_get_bits(GetBitContext *s)
static int get_bits_count(const GetBitContext *s)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
static int get_se_golomb(GetBitContext *gb)
read signed exp golomb code.
static int get_ue_golomb_31(GetBitContext *gb)
read unsigned exp golomb code, constraint to a max of 31.
static int get_ue_golomb(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to 8190.
static unsigned get_ue_golomb_long(GetBitContext *gb)
Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
#define AV_CODEC_FLAG2_FAST
Allow non spec compliant speedup tricks.
#define AV_CODEC_FLAG2_SHOW_ALL
Show all frames before the first keyframe.
#define AV_GET_BUFFER_FLAG_REF
The decoder will keep a reference to the frame and may reuse it later.
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
#define AV_CODEC_EXPORT_DATA_FILM_GRAIN
Decoding only.
#define AV_CODEC_FLAG_OUTPUT_CORRUPT
Output even those frames that might be corrupted.
@ AVDISCARD_ALL
discard all
@ AVDISCARD_NONKEY
discard all frames except keyframes
@ AVDISCARD_BIDIR
discard all bidirectional frames
@ AVDISCARD_NONINTRA
discard all non intra frames
@ AVDISCARD_NONREF
discard all non reference
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
#define AV_FRAME_FLAG_CORRUPT
The frame data may be corrupted, e.g.
#define AV_FRAME_FLAG_KEY
A flag to mark frames that are keyframes.
@ AV_FRAME_DATA_LCEVC
Raw LCEVC payload data, as a uint8_t array, with NAL emulation bytes intact.
@ AV_FRAME_DATA_S12M_TIMECODE
Timecode which conforms to SMPTE ST 12-1.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
static int av_cmp_q(AVRational a, AVRational b)
Compare two rationals.
void av_fast_mallocz(void *ptr, unsigned int *size, size_t min_size)
Allocate and clear a buffer, reusing the given one if large enough.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
Overlapping memcpy() implementation.
char av_get_picture_type_char(enum AVPictureType pict_type)
Return a single letter to describe the given picture type pict_type.
@ AV_PICTURE_TYPE_I
Intra.
@ AV_PICTURE_TYPE_SP
Switching Predicted.
@ AV_PICTURE_TYPE_P
Predicted.
@ AV_PICTURE_TYPE_SI
Switching Intra.
@ AV_PICTURE_TYPE_B
Bi-dir predicted.
int ff_h2645_sei_to_frame(AVFrame *frame, H2645SEI *sei, enum AVCodecID codec_id, AVCodecContext *avctx, const H2645VUI *vui, unsigned bit_depth_luma, unsigned bit_depth_chroma, int seed)
int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src)
H.264 common definitions.
int ff_h264_decode_mb_cabac(const H264Context *h, H264SliceContext *sl)
Decode a macroblock.
void ff_h264_init_cabac_states(const H264Context *h, H264SliceContext *sl)
int ff_h264_decode_mb_cavlc(const H264Context *h, H264SliceContext *sl)
Decode a macroblock.
void ff_h264_direct_ref_list_init(const H264Context *const h, H264SliceContext *sl)
void ff_h264_direct_dist_scale_factor(const H264Context *const h, H264SliceContext *sl)
void ff_h264_filter_mb(const H264Context *h, H264SliceContext *sl, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize)
void ff_h264_filter_mb_fast(const H264Context *h, H264SliceContext *sl, int mb_x, int mb_y, uint8_t *img_y, uint8_t *img_cb, uint8_t *img_cr, unsigned int linesize, unsigned int uvlinesize)
void ff_h264_hl_decode_mb(const H264Context *h, H264SliceContext *sl)
int ff_h264_get_profile(const SPS *sps)
Compute profile from profile_idc and constraint_set?_flags.
int ff_h264_parse_ref_count(int *plist_count, int ref_count[2], GetBitContext *gb, const PPS *pps, int slice_type_nos, int picture_structure, void *logctx)
int ff_h264_init_poc(int pic_field_poc[2], int *pic_poc, const SPS *sps, H264POCContext *pc, int picture_structure, int nal_ref_idc)
int ff_h264_pred_weight_table(GetBitContext *gb, const SPS *sps, const int *ref_count, int slice_type_nos, H264PredWeightTable *pwt, int picture_structure, void *logctx)
static const uint8_t scan8[16 *3+3]
static av_always_inline uint32_t pack16to32(unsigned a, unsigned b)
void ff_h264_set_erpic(ERPicture *dst, const H264Picture *src)
void ff_h264_unref_picture(H264Picture *pic)
int ff_h264_ref_picture(H264Picture *dst, const H264Picture *src)
int ff_h264_field_end(H264Context *h, H264SliceContext *sl, int in_setup)
int ff_h264_replace_picture(H264Picture *dst, const H264Picture *src)
H.264 parameter set handling.
int ff_h264_decode_ref_pic_list_reordering(H264SliceContext *sl, void *logctx)
int ff_h264_decode_ref_pic_marking(H264SliceContext *sl, GetBitContext *gb, const H2645NAL *nal, void *logctx)
int ff_h264_execute_ref_pic_marking(H264Context *h)
Execute the reference picture marking (memory management control operations).
int ff_h264_build_ref_list(H264Context *h, H264SliceContext *sl)
int ff_h264_sei_process_picture_timing(H264SEIPictureTiming *h, const SPS *sps, void *logctx)
Parse the contents of a picture timing message given an active SPS.
@ H264_SEI_PIC_STRUCT_BOTTOM_FIELD
2: bottom field
@ H264_SEI_PIC_STRUCT_BOTTOM_TOP
4: bottom field, top field, in that order
@ H264_SEI_PIC_STRUCT_TOP_BOTTOM_TOP
5: top field, bottom field, top field repeated, in that order
@ H264_SEI_PIC_STRUCT_TOP_FIELD
1: top field
@ H264_SEI_PIC_STRUCT_FRAME_TRIPLING
8: frame tripling
@ H264_SEI_PIC_STRUCT_BOTTOM_TOP_BOTTOM
6: bottom field, top field, bottom field repeated, in that order
@ H264_SEI_PIC_STRUCT_TOP_BOTTOM
3: top field, bottom field, in that order
@ H264_SEI_PIC_STRUCT_FRAME_DOUBLING
7: frame doubling
@ H264_SEI_PIC_STRUCT_FRAME
0: frame
static int find_unused_picture(const H264Context *h)
static av_always_inline void backup_mb_border(const H264Context *h, H264SliceContext *sl, const uint8_t *src_y, const uint8_t *src_cb, const uint8_t *src_cr, int linesize, int uvlinesize, int simple)
static int h264_frame_start(H264Context *h)
static void init_dimensions(H264Context *h)
int ff_h264_update_thread_context(AVCodecContext *dst, const AVCodecContext *src)
static void init_scan_tables(H264Context *h)
initialize scan tables
static int fill_filter_caches(const H264Context *h, H264SliceContext *sl, int mb_type)
static int h264_slice_init(H264Context *h, H264SliceContext *sl, const H2645NAL *nal)
static void implicit_weight_table(const H264Context *h, H264SliceContext *sl, int field)
Initialize implicit_weight table.
static void er_add_slice(H264SliceContext *sl, int startx, int starty, int endx, int endy, int status)
int ff_h264_execute_decode_slices(H264Context *h)
Call decode_slice() for each context.
static void predict_field_decoding_flag(const H264Context *h, H264SliceContext *sl)
static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback, int data_partitioning)
int ff_h264_queue_decode_slice(H264Context *h, const H2645NAL *nal, H264SliceContext **queued)
Submit a slice for decoding.
static int h264_field_start(H264Context *h, const H264SliceContext *sl, const H2645NAL *nal, int first_slice)
#define REBASE_PICTURE(pic, new_ctx, old_ctx)
static void copy_picture_range(H264Picture **to, H264Picture *const *from, int count, H264Context *new_base, const H264Context *old_base)
static const uint8_t field_scan[16+1]
static void loop_filter(const H264Context *h, H264SliceContext *sl, int start_x, int end_x)
#define IN_RANGE(a, b, size)
static int alloc_scratch_buffers(H264SliceContext *sl, int linesize)
static int h264_slice_header_parse(const H264Context *h, H264SliceContext *sl, const H2645NAL *nal)
static av_always_inline void fill_filter_caches_inter(const H264Context *h, H264SliceContext *sl, int mb_type, int top_xy, const int left_xy[LEFT_MBS], int top_type, const int left_type[LEFT_MBS], int mb_xy, int list)
static void color_frame(AVFrame *frame, const int c[4])
static const uint8_t field_scan8x8[64+1]
static int h264_export_frame_props(H264Context *h)
static int h264_parse_slice_id(const H264Context *h, H264SliceContext *sl)
static int alloc_picture(H264Context *h, H264Picture *pic)
static const uint8_t field_scan8x8_cavlc[64+1]
static void release_unused_pictures(H264Context *h, int remove_current)
static int h264_slice_header_init(H264Context *h)
static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_slice)
int ff_h264_update_thread_context_for_user(AVCodecContext *dst, const AVCodecContext *src)
static int decode_slice(struct AVCodecContext *avctx, void *arg)
int ff_h264_get_slice_type(const H264SliceContext *sl)
Reconstruct bitstream slice_type.
static int init_table_pools(H264Context *h)
static void decode_finish_row(const H264Context *h, H264SliceContext *sl)
Draw edges and report progress for the last MB row.
int ff_h264_attach_slice_partition(const H264Context *h, H264SliceContext *sl, const H2645NAL *nal)
Attach a slice data partition B or C to the slice started by partition A.
static enum AVPixelFormat non_j_pixfmt(enum AVPixelFormat a)
static int h264_select_output_frame(H264Context *h)
static const uint8_t zigzag_scan8x8_cavlc[64+1]
const uint8_t ff_h264_golomb_to_pict_type[5]
H.264 / AVC / MPEG-4 part10 codec.
#define FIELD_OR_MBAFF_PICTURE(h)
#define FRAME_RECOVERED_IDR
We have seen an IDR, so all the following frames in coded order are correctly decodable.
#define H264_MAX_PICTURE_COUNT
static av_always_inline int get_chroma_qp(const PPS *pps, int t, int qscale)
Get the chroma qp.
#define FRAME_RECOVERED_SEI
Sufficient number of frames have been decoded since a SEI recovery point, so all the following frames...
#define USES_LIST(a, list)
H.274 film grain synthesis.
static int ff_h274_film_grain_params_supported(int model_id, enum AVPixelFormat pix_fmt)
Check whether ff_h274_apply_film_grain() supports the given parameter combination.
#define DELAYED_PIC_REF
Value of Picture.reference when Picture is not a reference picture, but is held for delayed output.
av_cold void ff_h264chroma_init(H264ChromaContext *c, int bit_depth)
int ff_h264_alloc_tables(H264Context *h)
Allocate tables.
void ff_h264_free_tables(H264Context *h)
void ff_h264_draw_horiz_band(const H264Context *h, H264SliceContext *sl, int y, int height)
void ff_h264_slice_context_init(H264Context *h, H264SliceContext *sl)
Init slice context.
void ff_h264_flush_change(H264Context *h)
av_cold void ff_h264dsp_init(H264DSPContext *c, const int bit_depth, const int chroma_format_idc)
av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id, const int bit_depth, int chroma_format_idc)
Set the intra prediction function pointers.
av_cold void ff_h264qpel_init(H264QpelContext *c, int bit_depth)
Multithreading API for decoders.
av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
static enum AVPixelFormat pix_fmts[]
void av_log_once(void *avcl, int initial_level, int subsequent_level, int *state, const char *fmt,...)
const uint8_t ff_zigzag_direct[64]
const uint8_t ff_zigzag_scan[16+1]
Memory handling functions.
#define PICT_BOTTOM_FIELD
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
const char * av_color_transfer_name(enum AVColorTransferCharacteristic transfer)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
#define AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV422P9
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_JPEG
Full range content.
#define AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P14
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_VULKAN
Vulkan hardware images.
@ AV_PIX_FMT_VIDEOTOOLBOX
hardware decoding through Videotoolbox
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_D3D12
Hardware surfaces for Direct3D 12.
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_DXVA2_VLD
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer.
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_D3D11
Hardware surfaces for Direct3D11.
@ AV_PIX_FMT_CUARRAY
hardware decoding through openharmony
@ AV_PIX_FMT_D3D11VA_VLD
HW decoding through Direct3D11 via old API, Picture.data[3] contains a ID3D11VideoDecoderOutputView p...
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
@ AV_PIX_FMT_VDPAU
HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface.
#define AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_YUV444P10
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
int ff_thread_get_buffer(AVCodecContext *avctx, AVFrame *f, int flags)
Wrapper around get_buffer() for frame-multithreaded codecs.
void ff_thread_report_progress(ThreadFrame *f, int n, int field)
Notify later decoding threads when part of their reference picture is ready.
void ff_thread_release_ext_buffer(ThreadFrame *f)
Unref a ThreadFrame.
int ff_thread_get_ext_buffer(AVCodecContext *avctx, ThreadFrame *f, int flags)
Wrapper around ff_get_buffer() for frame-multithreaded codecs.
int ff_thread_can_start_frame(AVCodecContext *avctx)
void ff_thread_await_progress(const ThreadFrame *f, int n, int field)
Wait for earlier decoding threads to finish reference pictures.
useful rectangle filling function
AVRefStructPool * av_refstruct_pool_alloc(size_t size, unsigned flags)
Equivalent to av_refstruct_pool_alloc(size, flags, NULL, NULL, NULL, NULL, NULL)
void av_refstruct_replace(void *dstp, const void *src)
Ensure *dstp refers to the same object as src.
const void * av_refstruct_ref_c(const void *obj)
Analog of av_refstruct_ref(), but for constant objects.
void * av_refstruct_pool_get(AVRefStructPool *pool)
Get an object from the pool, reusing an old one from the pool when available.
static void av_refstruct_pool_uninit(AVRefStructPool **poolp)
Mark the pool as being available for freeing.
#define FF_ARRAY_ELEMS(a)
#define atomic_init(obj, value)
A reference counted buffer type.
main external API structure.
int(* execute)(struct AVCodecContext *c, int(*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size)
The codec may call this to execute several independent things.
Structure to hold side data for an AVFrame.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
enum AVPictureType pict_type
Picture type of the frame.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
const uint8_t * bytestream_end
const uint8_t * bytestream
uint8_t * error_status_table
H264Picture DPB[H264_MAX_PICTURE_COUNT]
int is_avc
Used to parse AVC variant of H.264.
int nal_length_size
Number of bytes used for nal length (1, 2 or 4)
atomic_int * decode_error_flags
RefStruct reference; its pointee is shared between decoding threads.
int recovered
picture at IDR or recovery point + recovery count
int16_t(*[2] motion_val)[2]
int8_t * ref_index[2]
RefStruct reference.
int sei_recovery_frame_cnt
int field_picture
whether or not picture was encoded in separate fields
int frame_num
frame_num (raw frame_num from slice header)
int long_ref
1->long term reference 0->short term reference
void * hwaccel_picture_private
RefStruct reference for hardware accelerator private data.
int mmco_reset
MMCO_RESET set this 1.
int field_poc[2]
top/bottom POC
int8_t * qscale_table_base
RefStruct reference.
int16_t(*[2] motion_val_base)[2]
RefStruct reference.
uint32_t * mb_type_base
RefStruct reference.
int needs_fg
whether picture needs film grain synthesis (see f_grain)
int chroma_log2_weight_denom
int luma_log2_weight_denom
int implicit_weight[48][48][2]
int chroma_weight_flag[2]
7.4.3.2 chroma_weight_lX_flag
int luma_weight_flag[2]
7.4.3.2 luma_weight_lX_flag
const H264Picture * parent
ptrdiff_t mb_linesize
may be equal to s->linesize or s->linesize * 2, for mbaff
int mb_field_decoding_flag
int8_t ref_cache[2][5 *8]
unsigned int first_mb_addr
int bipred_scratchpad_allocated
int16_t mv_cache[2][5 *8][2]
Motion vector cache.
uint8_t * edge_emu_buffer
int deblocking_filter
disable_deblocking_filter_idc with 1 <-> 0
int top_borders_allocated[2]
uint8_t * bipred_scratchpad
int qp_thresh
QP threshold to skip loopfilter.
int slice_type_nos
S free slice type (SI/SP are remapped to I/P)
uint8_t(*[2] top_borders)[(16 *3) *2]
H264Ref ref_list[2][48]
0..15: frame refs, 16..47: mbaff field refs.
int direct_spatial_mv_pred
int mb_mbaff
mb_aff_frame && mb_field_decoding_flag
uint8_t(*[2] mvd_table)[2]
int8_t * intra4x4_pred_mode
const struct H264Context * h264
int edge_emu_buffer_allocated
int slice_alpha_c0_offset
uint8_t non_zero_count_cache[15 *8]
non zero coeff count cache.
unsigned int ref_count[2]
num_ref_idx_l0/1_active_minus1 + 1
MMCO mmco[H264_MAX_MMCO_COUNT]
#define avpriv_request_sample(...)
static int ref[MAX_W *MAX_W]
int ff_thread_ref_frame(ThreadFrame *dst, const ThreadFrame *src)
uint32_t av_timecode_get_smpte(AVRational rate, int drop, int hh, int mm, int ss, int ff)
Convert sei info to SMPTE 12M binary representation.
char * av_timecode_make_smpte_tc_string2(char *buf, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field)
Get the timecode string from the SMPTE timecode format.
#define AV_TIMECODE_STR_SIZE
static double cr(void *priv, double x, double y)
static double cb(void *priv, double x, double y)