51 0 + 0 * 4, 0 + 1 * 4, 1 + 0 * 4, 0 + 2 * 4,
52 0 + 3 * 4, 1 + 1 * 4, 1 + 2 * 4, 1 + 3 * 4,
53 2 + 0 * 4, 2 + 1 * 4, 2 + 2 * 4, 2 + 3 * 4,
54 3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4,
58 0 + 0 * 8, 0 + 1 * 8, 0 + 2 * 8, 1 + 0 * 8,
59 1 + 1 * 8, 0 + 3 * 8, 0 + 4 * 8, 1 + 2 * 8,
60 2 + 0 * 8, 1 + 3 * 8, 0 + 5 * 8, 0 + 6 * 8,
61 0 + 7 * 8, 1 + 4 * 8, 2 + 1 * 8, 3 + 0 * 8,
62 2 + 2 * 8, 1 + 5 * 8, 1 + 6 * 8, 1 + 7 * 8,
63 2 + 3 * 8, 3 + 1 * 8, 4 + 0 * 8, 3 + 2 * 8,
64 2 + 4 * 8, 2 + 5 * 8, 2 + 6 * 8, 2 + 7 * 8,
65 3 + 3 * 8, 4 + 1 * 8, 5 + 0 * 8, 4 + 2 * 8,
66 3 + 4 * 8, 3 + 5 * 8, 3 + 6 * 8, 3 + 7 * 8,
67 4 + 3 * 8, 5 + 1 * 8, 6 + 0 * 8, 5 + 2 * 8,
68 4 + 4 * 8, 4 + 5 * 8, 4 + 6 * 8, 4 + 7 * 8,
69 5 + 3 * 8, 6 + 1 * 8, 6 + 2 * 8, 5 + 4 * 8,
70 5 + 5 * 8, 5 + 6 * 8, 5 + 7 * 8, 6 + 3 * 8,
71 7 + 0 * 8, 7 + 1 * 8, 6 + 4 * 8, 6 + 5 * 8,
72 6 + 6 * 8, 6 + 7 * 8, 7 + 2 * 8, 7 + 3 * 8,
73 7 + 4 * 8, 7 + 5 * 8, 7 + 6 * 8, 7 + 7 * 8,
77 0 + 0 * 8, 1 + 1 * 8, 2 + 0 * 8, 0 + 7 * 8,
78 2 + 2 * 8, 2 + 3 * 8, 2 + 4 * 8, 3 + 3 * 8,
79 3 + 4 * 8, 4 + 3 * 8, 4 + 4 * 8, 5 + 3 * 8,
80 5 + 5 * 8, 7 + 0 * 8, 6 + 6 * 8, 7 + 4 * 8,
81 0 + 1 * 8, 0 + 3 * 8, 1 + 3 * 8, 1 + 4 * 8,
82 1 + 5 * 8, 3 + 1 * 8, 2 + 5 * 8, 4 + 1 * 8,
83 3 + 5 * 8, 5 + 1 * 8, 4 + 5 * 8, 6 + 1 * 8,
84 5 + 6 * 8, 7 + 1 * 8, 6 + 7 * 8, 7 + 5 * 8,
85 0 + 2 * 8, 0 + 4 * 8, 0 + 5 * 8, 2 + 1 * 8,
86 1 + 6 * 8, 4 + 0 * 8, 2 + 6 * 8, 5 + 0 * 8,
87 3 + 6 * 8, 6 + 0 * 8, 4 + 6 * 8, 6 + 2 * 8,
88 5 + 7 * 8, 6 + 4 * 8, 7 + 2 * 8, 7 + 6 * 8,
89 1 + 0 * 8, 1 + 2 * 8, 0 + 6 * 8, 3 + 0 * 8,
90 1 + 7 * 8, 3 + 2 * 8, 2 + 7 * 8, 4 + 2 * 8,
91 3 + 7 * 8, 5 + 2 * 8, 4 + 7 * 8, 5 + 4 * 8,
92 6 + 3 * 8, 6 + 5 * 8, 7 + 3 * 8, 7 + 7 * 8,
97 0 + 0 * 8, 1 + 1 * 8, 1 + 2 * 8, 2 + 2 * 8,
98 4 + 1 * 8, 0 + 5 * 8, 3 + 3 * 8, 7 + 0 * 8,
99 3 + 4 * 8, 1 + 7 * 8, 5 + 3 * 8, 6 + 3 * 8,
100 2 + 7 * 8, 6 + 4 * 8, 5 + 6 * 8, 7 + 5 * 8,
101 1 + 0 * 8, 2 + 0 * 8, 0 + 3 * 8, 3 + 1 * 8,
102 3 + 2 * 8, 0 + 6 * 8, 4 + 2 * 8, 6 + 1 * 8,
103 2 + 5 * 8, 2 + 6 * 8, 6 + 2 * 8, 5 + 4 * 8,
104 3 + 7 * 8, 7 + 3 * 8, 4 + 7 * 8, 7 + 6 * 8,
105 0 + 1 * 8, 3 + 0 * 8, 0 + 4 * 8, 4 + 0 * 8,
106 2 + 3 * 8, 1 + 5 * 8, 5 + 1 * 8, 5 + 2 * 8,
107 1 + 6 * 8, 3 + 5 * 8, 7 + 1 * 8, 4 + 5 * 8,
108 4 + 6 * 8, 7 + 4 * 8, 5 + 7 * 8, 6 + 7 * 8,
109 0 + 2 * 8, 2 + 1 * 8, 1 + 3 * 8, 5 + 0 * 8,
110 1 + 4 * 8, 2 + 4 * 8, 6 + 0 * 8, 4 + 3 * 8,
111 0 + 7 * 8, 4 + 4 * 8, 7 + 2 * 8, 3 + 6 * 8,
112 5 + 5 * 8, 6 + 5 * 8, 6 + 6 * 8, 7 + 7 * 8,
121 if (
h->DPB[
i].f->buf[0] && !
h->DPB[
i].reference &&
122 (remove_current || &
h->DPB[
i] !=
h->cur_pic_ptr)) {
139 h->mb_width * 16 * 3 *
sizeof(
uint8_t) * 2);
141 h->mb_width * 16 * 3 *
sizeof(
uint8_t) * 2);
162 const int big_mb_num =
h->mb_stride * (
h->mb_height + 1) + 1;
163 const int mb_array_size =
h->mb_stride *
h->mb_height;
164 const int b4_stride =
h->mb_width * 4 + 1;
165 const int b4_array_size = b4_stride *
h->mb_height * 4;
175 if (!
h->qscale_table_pool || !
h->mb_type_pool || !
h->motion_val_pool ||
176 !
h->ref_index_pool) {
199 if (
h->avctx->hwaccel) {
210 int h_chroma_shift, v_chroma_shift;
212 &h_chroma_shift, &v_chroma_shift);
222 if (!
h->qscale_table_pool) {
266 if (!
h->DPB[
i].f->buf[0])
273 #define IN_RANGE(a, b, size) (((void*)(a) >= (void*)(b)) && ((void*)(a) < (void*)((b) + (size))))
275 #define REBASE_PICTURE(pic, new_ctx, old_ctx) \
276 (((pic) && (pic) >= (old_ctx)->DPB && \
277 (pic) < (old_ctx)->DPB + H264_MAX_PICTURE_COUNT) ? \
278 &(new_ctx)->DPB[(pic) - (old_ctx)->DPB] : NULL)
286 for (
i = 0;
i < count;
i++) {
300 int inited =
h->context_initialized, err = 0;
312 (
h->width != h1->width ||
313 h->height != h1->height ||
314 h->mb_width != h1->mb_width ||
315 h->mb_height != h1->mb_height ||
317 h->ps.sps->bit_depth_luma != h1->ps.sps->bit_depth_luma ||
318 h->ps.sps->chroma_format_idc != h1->ps.sps->chroma_format_idc ||
319 h->ps.sps->colorspace != h1->ps.sps->colorspace)) {
324 memcpy(
h->block_offset, h1->block_offset,
sizeof(
h->block_offset));
329 if (h1->ps.sps_list[
i]) {
331 if (!
h->ps.sps_list[
i])
337 if (h1->ps.pps_list[
i]) {
339 if (!
h->ps.pps_list[
i])
347 if (h1->ps.pps_ref) {
351 h->ps.pps = (
const PPS*)
h->ps.pps_ref->data;
352 h->ps.sps =
h->ps.pps->sps;
355 if (need_reinit || !inited) {
356 h->width = h1->width;
357 h->height = h1->height;
358 h->mb_height = h1->mb_height;
359 h->mb_width = h1->mb_width;
360 h->mb_num = h1->mb_num;
361 h->mb_stride = h1->mb_stride;
362 h->b_stride = h1->b_stride;
363 h->x264_build = h1->x264_build;
365 if (
h->context_initialized || h1->context_initialized) {
373 memcpy(
h->block_offset, h1->block_offset,
sizeof(
h->block_offset));
376 h->avctx->coded_height = h1->avctx->coded_height;
377 h->avctx->coded_width = h1->avctx->coded_width;
378 h->avctx->width = h1->avctx->width;
379 h->avctx->height = h1->avctx->height;
380 h->width_from_caller = h1->width_from_caller;
381 h->height_from_caller = h1->height_from_caller;
382 h->coded_picture_number = h1->coded_picture_number;
383 h->first_field = h1->first_field;
384 h->picture_structure = h1->picture_structure;
385 h->mb_aff_frame = h1->mb_aff_frame;
386 h->droppable = h1->droppable;
390 if (h1->DPB[
i].f->buf[0] &&
397 if (h1->cur_pic.f->buf[0]) {
403 h->enable_er = h1->enable_er;
404 h->workaround_bugs = h1->workaround_bugs;
405 h->droppable = h1->droppable;
408 h->is_avc = h1->is_avc;
409 h->nal_length_size = h1->nal_length_size;
411 memcpy(&
h->poc, &h1->poc,
sizeof(
h->poc));
413 memcpy(
h->short_ref, h1->short_ref,
sizeof(
h->short_ref));
414 memcpy(
h->long_ref, h1->long_ref,
sizeof(
h->long_ref));
415 memcpy(
h->delayed_pic, h1->delayed_pic,
sizeof(
h->delayed_pic));
416 memcpy(
h->last_pocs, h1->last_pocs,
sizeof(
h->last_pocs));
418 h->next_output_pic = h1->next_output_pic;
419 h->next_outputed_poc = h1->next_outputed_poc;
421 memcpy(
h->mmco, h1->mmco,
sizeof(
h->mmco));
422 h->nb_mmco = h1->nb_mmco;
423 h->mmco_reset = h1->mmco_reset;
424 h->explicit_ref_marking = h1->explicit_ref_marking;
425 h->long_ref_count = h1->long_ref_count;
426 h->short_ref_count = h1->short_ref_count;
433 h->frame_recovered = h1->frame_recovered;
436 if (h1->sei.a53_caption.buf_ref) {
437 h->sei.a53_caption.buf_ref =
av_buffer_ref(h1->sei.a53_caption.buf_ref);
438 if (!
h->sei.a53_caption.buf_ref)
447 h->poc.prev_poc_msb =
h->poc.poc_msb;
448 h->poc.prev_poc_lsb =
h->poc.poc_lsb;
450 h->poc.prev_frame_num_offset =
h->poc.frame_num_offset;
451 h->poc.prev_frame_num =
h->poc.frame_num;
453 h->recovery_frame = h1->recovery_frame;
462 const int pixel_shift =
h->pixel_shift;
470 h->cur_pic_ptr =
NULL;
479 pic->
reference =
h->droppable ? 0 :
h->picture_structure;
504 h->cur_pic_ptr = pic;
513 for (
i = 0;
i <
h->nb_slice_ctx;
i++) {
514 h->slice_ctx[
i].linesize =
h->cur_pic_ptr->f->linesize[0];
515 h->slice_ctx[
i].uvlinesize =
h->cur_pic_ptr->f->linesize[1];
524 for (
i = 0;
i < 16;
i++) {
528 for (
i = 0;
i < 16;
i++) {
529 h->block_offset[16 +
i] =
531 h->block_offset[48 + 16 +
i] =
539 h->cur_pic_ptr->reference = 0;
541 h->cur_pic_ptr->field_poc[0] =
h->cur_pic_ptr->field_poc[1] = INT_MAX;
543 h->next_output_pic =
NULL;
545 h->postpone_filter = 0;
547 h->mb_aff_frame =
h->ps.sps->mb_aff && (
h->picture_structure ==
PICT_FRAME);
549 if (
h->sei.unregistered.x264_build >= 0)
550 h->x264_build =
h->sei.unregistered.x264_build;
552 assert(
h->cur_pic_ptr->long_ref == 0);
560 int linesize,
int uvlinesize,
565 const int pixel_shift =
h->pixel_shift;
570 src_cb -= uvlinesize;
571 src_cr -= uvlinesize;
577 AV_COPY128(top_border, src_y + 15 * linesize);
579 AV_COPY128(top_border + 16, src_y + 15 * linesize + 16);
583 AV_COPY128(top_border + 32, src_cb + 15 * uvlinesize);
584 AV_COPY128(top_border + 48, src_cb + 15 * uvlinesize + 16);
585 AV_COPY128(top_border + 64, src_cr + 15 * uvlinesize);
586 AV_COPY128(top_border + 80, src_cr + 15 * uvlinesize + 16);
588 AV_COPY128(top_border + 16, src_cb + 15 * uvlinesize);
589 AV_COPY128(top_border + 32, src_cr + 15 * uvlinesize);
591 }
else if (chroma422) {
593 AV_COPY128(top_border + 32, src_cb + 15 * uvlinesize);
594 AV_COPY128(top_border + 48, src_cr + 15 * uvlinesize);
596 AV_COPY64(top_border + 16, src_cb + 15 * uvlinesize);
597 AV_COPY64(top_border + 24, src_cr + 15 * uvlinesize);
601 AV_COPY128(top_border + 32, src_cb + 7 * uvlinesize);
602 AV_COPY128(top_border + 48, src_cr + 7 * uvlinesize);
604 AV_COPY64(top_border + 16, src_cb + 7 * uvlinesize);
605 AV_COPY64(top_border + 24, src_cr + 7 * uvlinesize);
619 AV_COPY128(top_border, src_y + 16 * linesize);
621 AV_COPY128(top_border + 16, src_y + 16 * linesize + 16);
626 AV_COPY128(top_border + 32, src_cb + 16 * linesize);
627 AV_COPY128(top_border + 48, src_cb + 16 * linesize + 16);
628 AV_COPY128(top_border + 64, src_cr + 16 * linesize);
629 AV_COPY128(top_border + 80, src_cr + 16 * linesize + 16);
631 AV_COPY128(top_border + 16, src_cb + 16 * linesize);
632 AV_COPY128(top_border + 32, src_cr + 16 * linesize);
634 }
else if (chroma422) {
636 AV_COPY128(top_border + 32, src_cb + 16 * uvlinesize);
637 AV_COPY128(top_border + 48, src_cr + 16 * uvlinesize);
639 AV_COPY64(top_border + 16, src_cb + 16 * uvlinesize);
640 AV_COPY64(top_border + 24, src_cr + 16 * uvlinesize);
644 AV_COPY128(top_border + 32, src_cb + 8 * uvlinesize);
645 AV_COPY128(top_border + 48, src_cr + 8 * uvlinesize);
647 AV_COPY64(top_border + 16, src_cb + 8 * uvlinesize);
648 AV_COPY64(top_border + 24, src_cr + 8 * uvlinesize);
661 int ref0, ref1,
i, cur_poc, ref_start, ref_count0, ref_count1;
663 for (
i = 0;
i < 2;
i++) {
670 cur_poc =
h->cur_pic_ptr->poc;
672 cur_poc =
h->cur_pic_ptr->field_poc[
h->picture_structure - 1];
684 cur_poc =
h->cur_pic_ptr->field_poc[
field];
695 for (ref0 = ref_start; ref0 < ref_count0; ref0++) {
697 for (ref1 = ref_start; ref1 < ref_count1; ref1++) {
701 int td = av_clip_int8(poc1 - poc0);
703 int tb = av_clip_int8(cur_poc - poc0);
704 int tx = (16384 + (
FFABS(
td) >> 1)) /
td;
705 int dist_scale_factor = (
tb * tx + 32) >> 8;
706 if (dist_scale_factor >= -64 && dist_scale_factor <= 128)
707 w = 64 - dist_scale_factor;
726 for (
i = 0;
i < 16;
i++) {
727 #define TRANSPOSE(x) ((x) >> 2) | (((x) << 2) & 0xF)
732 for (
i = 0;
i < 64;
i++) {
733 #define TRANSPOSE(x) ((x) >> 3) | (((x) & 7) << 3)
740 if (
h->ps.sps->transform_bypass) {
744 memcpy(
h->field_scan_q0 ,
field_scan ,
sizeof(
h->field_scan_q0 ));
745 memcpy(
h->field_scan8x8_q0 ,
field_scan8x8 ,
sizeof(
h->field_scan8x8_q0 ));
748 memcpy(
h->zigzag_scan_q0 ,
h->zigzag_scan ,
sizeof(
h->zigzag_scan_q0 ));
749 memcpy(
h->zigzag_scan8x8_q0 ,
h->zigzag_scan8x8 ,
sizeof(
h->zigzag_scan8x8_q0 ));
750 memcpy(
h->zigzag_scan8x8_cavlc_q0 ,
h->zigzag_scan8x8_cavlc ,
sizeof(
h->zigzag_scan8x8_cavlc_q0));
751 memcpy(
h->field_scan_q0 ,
h->field_scan ,
sizeof(
h->field_scan_q0 ));
752 memcpy(
h->field_scan8x8_q0 ,
h->field_scan8x8 ,
sizeof(
h->field_scan8x8_q0 ));
753 memcpy(
h->field_scan8x8_cavlc_q0 ,
h->field_scan8x8_cavlc ,
sizeof(
h->field_scan8x8_cavlc_q0 ));
759 #define HWACCEL_MAX (CONFIG_H264_DXVA2_HWACCEL + \
760 (CONFIG_H264_D3D11VA_HWACCEL * 2) + \
761 CONFIG_H264_NVDEC_HWACCEL + \
762 CONFIG_H264_VAAPI_HWACCEL + \
763 CONFIG_H264_VIDEOTOOLBOX_HWACCEL + \
764 CONFIG_H264_VDPAU_HWACCEL)
769 switch (
h->ps.sps->bit_depth_luma) {
815 #if CONFIG_H264_VDPAU_HWACCEL
818 #if CONFIG_H264_NVDEC_HWACCEL
834 #if CONFIG_H264_DXVA2_HWACCEL
837 #if CONFIG_H264_D3D11VA_HWACCEL
841 #if CONFIG_H264_VAAPI_HWACCEL
844 #if CONFIG_H264_VIDEOTOOLBOX_HWACCEL
847 if (
h->avctx->codec->pix_fmts)
848 choices =
h->avctx->codec->pix_fmts;
857 "Unsupported bit depth %d\n",
h->ps.sps->bit_depth_luma);
864 if (choices[
i] ==
h->avctx->pix_fmt && !force_callback)
873 int cr =
sps->crop_right;
874 int cl =
sps->crop_left;
875 int ct =
sps->crop_top;
876 int cb =
sps->crop_bottom;
883 if (
h->width_from_caller > 0 &&
h->height_from_caller > 0 &&
884 !
sps->crop_top && !
sps->crop_left &&
887 h->width_from_caller <=
width &&
888 h->height_from_caller <=
height) {
889 width =
h->width_from_caller;
890 height =
h->height_from_caller;
896 h->width_from_caller = 0;
897 h->height_from_caller = 0;
900 h->avctx->coded_width =
h->width;
901 h->avctx->coded_height =
h->height;
917 &
h->chroma_x_shift, &
h->chroma_y_shift);
919 if (
sps->timing_info_present_flag) {
920 int64_t den =
sps->time_scale;
921 if (
h->x264_build < 44
U)
923 av_reduce(&
h->avctx->framerate.den, &
h->avctx->framerate.num,
924 sps->num_units_in_tick *
h->avctx->ticks_per_frame, den, 1 << 30);
930 h->prev_interlaced_frame = 1;
939 if (
sps->bit_depth_luma < 8 ||
sps->bit_depth_luma > 14 ||
940 sps->bit_depth_luma == 11 ||
sps->bit_depth_luma == 13
943 sps->bit_depth_luma);
948 h->cur_bit_depth_luma =
949 h->avctx->bits_per_raw_sample =
sps->bit_depth_luma;
950 h->cur_chroma_format_idc =
sps->chroma_format_idc;
951 h->pixel_shift =
sps->bit_depth_luma > 8;
952 h->chroma_format_idc =
sps->chroma_format_idc;
953 h->bit_depth_luma =
sps->bit_depth_luma;
956 sps->chroma_format_idc);
960 sps->chroma_format_idc);
970 for (
i = 0;
i <
h->nb_slice_ctx;
i++) {
975 sl->
mvd_table[0] =
h->mvd_table[0] +
i * 8 * 2 *
h->mb_stride;
976 sl->
mvd_table[1] =
h->mvd_table[1] +
i * 8 * 2 *
h->mb_stride;
985 h->context_initialized = 1;
990 h->context_initialized = 0;
1008 int needs_reinit = 0, must_reinit,
ret;
1016 h->ps.pps = (
const PPS*)
h->ps.pps_ref->data;
1019 if (
h->ps.sps !=
h->ps.pps->sps) {
1020 h->ps.sps = (
const SPS*)
h->ps.pps->sps;
1022 if (
h->mb_width !=
h->ps.sps->mb_width ||
1023 h->mb_height !=
h->ps.sps->mb_height ||
1024 h->cur_bit_depth_luma !=
h->ps.sps->bit_depth_luma ||
1025 h->cur_chroma_format_idc !=
h->ps.sps->chroma_format_idc
1029 if (
h->bit_depth_luma !=
h->ps.sps->bit_depth_luma ||
1030 h->chroma_format_idc !=
h->ps.sps->chroma_format_idc)
1035 must_reinit = (
h->context_initialized &&
1036 ( 16*
sps->mb_width !=
h->avctx->coded_width
1037 || 16*
sps->mb_height !=
h->avctx->coded_height
1038 ||
h->cur_bit_depth_luma !=
sps->bit_depth_luma
1039 ||
h->cur_chroma_format_idc !=
sps->chroma_format_idc
1040 ||
h->mb_width !=
sps->mb_width
1041 ||
h->mb_height !=
sps->mb_height
1047 if (first_slice &&
av_cmp_q(
sps->sar,
h->avctx->sample_aspect_ratio))
1050 if (!
h->setup_finished) {
1052 h->avctx->level =
sps->level_idc;
1053 h->avctx->refs =
sps->ref_frame_count;
1055 h->mb_width =
sps->mb_width;
1056 h->mb_height =
sps->mb_height;
1057 h->mb_num =
h->mb_width *
h->mb_height;
1058 h->mb_stride =
h->mb_width + 1;
1060 h->b_stride =
h->mb_width * 4;
1062 h->chroma_y_shift =
sps->chroma_format_idc <= 1;
1064 h->width = 16 *
h->mb_width;
1065 h->height = 16 *
h->mb_height;
1069 if (
sps->video_signal_type_present_flag) {
1072 if (
sps->colour_description_present_flag) {
1073 if (
h->avctx->colorspace !=
sps->colorspace)
1075 h->avctx->color_primaries =
sps->color_primaries;
1076 h->avctx->color_trc =
sps->color_trc;
1077 h->avctx->colorspace =
sps->colorspace;
1081 if (
h->sei.alternative_transfer.present &&
1084 h->avctx->color_trc =
h->sei.alternative_transfer.preferred_transfer_characteristics;
1087 h->avctx->chroma_sample_location =
sps->chroma_location;
1089 if (!
h->context_initialized || must_reinit || needs_reinit) {
1090 int flush_changes =
h->context_initialized;
1091 h->context_initialized = 0;
1092 if (sl !=
h->slice_ctx) {
1094 "changing width %d -> %d / height %d -> %d on "
1096 h->width,
h->avctx->coded_width,
1097 h->height,
h->avctx->coded_height,
1098 h->current_slice + 1);
1109 h->avctx->pix_fmt =
ret;
1116 "h264_slice_header_init() failed\n");
1135 if (
h->sei.picture_timing.present) {
1142 h->sei.picture_timing.present = 0;
1146 if (
sps->pic_struct_present_flag &&
h->sei.picture_timing.present) {
1148 switch (
pt->pic_struct) {
1178 if ((
pt->ct_type & 3) &&
1191 if (
sps->pic_struct_present_flag &&
h->sei.picture_timing.present) {
1209 if (
h->sei.frame_packing.present &&
1210 h->sei.frame_packing.arrangement_type <= 6 &&
1211 h->sei.frame_packing.content_interpretation_type > 0 &&
1212 h->sei.frame_packing.content_interpretation_type < 3) {
1216 switch (
fp->arrangement_type) {
1227 if (
fp->quincunx_sampling_flag)
1243 if (
fp->content_interpretation_type == 2)
1247 if (
fp->current_frame_is_frame0_flag)
1255 if (
h->sei.display_orientation.present &&
1256 (
h->sei.display_orientation.anticlockwise_rotation ||
1257 h->sei.display_orientation.hflip ||
1258 h->sei.display_orientation.vflip)) {
1271 if (
h->sei.afd.present) {
1276 *sd->
data =
h->sei.afd.active_format_description;
1277 h->sei.afd.present = 0;
1281 if (
h->sei.a53_caption.buf_ref) {
1292 if (
h->sei.picture_timing.timecode_cnt > 0) {
1298 sizeof(uint32_t)*4);
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++) {
1311 frames =
h->sei.picture_timing.timecode[
i].frame / 2;
1312 if (
h->sei.picture_timing.timecode[
i].frame % 2 == 1) {
1319 frames =
h->sei.picture_timing.timecode[
i].frame;
1322 tc |=
h->sei.picture_timing.timecode[
i].dropframe << 30;
1325 tc |= (
h->sei.picture_timing.timecode[
i].seconds / 10) << 20;
1326 tc |= (
h->sei.picture_timing.timecode[
i].seconds % 10) << 16;
1327 tc |= (
h->sei.picture_timing.timecode[
i].minutes / 10) << 12;
1328 tc |= (
h->sei.picture_timing.timecode[
i].minutes % 10) << 8;
1329 tc |= (
h->sei.picture_timing.timecode[
i].hours / 10) << 4;
1330 tc |= (
h->sei.picture_timing.timecode[
i].hours % 10);
1334 h->sei.picture_timing.timecode_cnt = 0;
1345 int i, pics, out_of_order, out_idx;
1350 if (
sps->bitstream_restriction_flag ||
1352 h->avctx->has_b_frames =
FFMAX(
h->avctx->has_b_frames,
sps->num_reorder_frames);
1355 for (
i = 0; 1;
i++) {
1358 h->last_pocs[
i-1] = cur->
poc;
1361 h->last_pocs[
i-1]=
h->last_pocs[
i];
1367 out_of_order =
FFMAX(out_of_order, 1);
1371 h->last_pocs[
i] = INT_MIN;
1372 h->last_pocs[0] = cur->
poc;
1374 }
else if(
h->avctx->has_b_frames < out_of_order && !
sps->bitstream_restriction_flag){
1376 av_log(
h->avctx, loglevel,
"Increasing reorder buffer to %d\n", out_of_order);
1377 h->avctx->has_b_frames = out_of_order;
1381 while (
h->delayed_pic[pics])
1386 h->delayed_pic[pics++] = cur;
1390 out =
h->delayed_pic[0];
1392 for (
i = 1;
h->delayed_pic[
i] &&
1393 !
h->delayed_pic[
i]->f->key_frame &&
1394 !
h->delayed_pic[
i]->mmco_reset;
1396 if (
h->delayed_pic[
i]->poc <
out->poc) {
1397 out =
h->delayed_pic[
i];
1400 if (
h->avctx->has_b_frames == 0 &&
1401 (
h->delayed_pic[0]->f->key_frame ||
h->delayed_pic[0]->mmco_reset))
1402 h->next_outputed_poc = INT_MIN;
1403 out_of_order =
out->poc <
h->next_outputed_poc;
1405 if (out_of_order || pics >
h->avctx->has_b_frames) {
1407 for (
i = out_idx;
h->delayed_pic[
i];
i++)
1408 h->delayed_pic[
i] =
h->delayed_pic[
i + 1];
1410 if (!out_of_order && pics >
h->avctx->has_b_frames) {
1411 h->next_output_pic =
out;
1412 if (out_idx == 0 &&
h->delayed_pic[0] && (
h->delayed_pic[0]->f->key_frame ||
h->delayed_pic[0]->mmco_reset)) {
1413 h->next_outputed_poc = INT_MIN;
1415 h->next_outputed_poc =
out->poc;
1417 if (
out->recovered) {
1424 if (!
out->recovered) {
1427 h->next_output_pic =
NULL;
1444 const H2645NAL *nal,
int first_slice)
1449 int last_pic_structure, last_pic_droppable,
ret;
1457 if (
sps &&
sps->bitstream_restriction_flag &&
1458 h->avctx->has_b_frames <
sps->num_reorder_frames) {
1459 h->avctx->has_b_frames =
sps->num_reorder_frames;
1462 last_pic_droppable =
h->droppable;
1463 last_pic_structure =
h->picture_structure;
1464 h->droppable = (nal->
ref_idc == 0);
1475 if (
h->poc.frame_num !=
h->poc.prev_frame_num) {
1476 int unwrap_prev_frame_num =
h->poc.prev_frame_num;
1477 int max_frame_num = 1 <<
sps->log2_max_frame_num;
1479 if (unwrap_prev_frame_num >
h->poc.frame_num)
1480 unwrap_prev_frame_num -= max_frame_num;
1482 if ((
h->poc.frame_num - unwrap_prev_frame_num) >
sps->ref_frame_count) {
1483 unwrap_prev_frame_num = (
h->poc.frame_num -
sps->ref_frame_count) - 1;
1484 if (unwrap_prev_frame_num < 0)
1485 unwrap_prev_frame_num += max_frame_num;
1487 h->poc.prev_frame_num = unwrap_prev_frame_num;
1496 if (
h->first_field) {
1503 if (
h->cur_pic_ptr->tf.owner[last_field] ==
h->avctx) {
1508 if (!
FIELD_PICTURE(
h) ||
h->picture_structure == last_pic_structure) {
1516 if (
h->cur_pic_ptr->frame_num !=
h->poc.frame_num) {
1532 "Invalid field mode combination %d/%d\n",
1533 last_pic_structure,
h->picture_structure);
1534 h->picture_structure = last_pic_structure;
1535 h->droppable = last_pic_droppable;
1537 }
else if (last_pic_droppable !=
h->droppable) {
1539 "Found reference and non-reference fields in the same frame, which");
1540 h->picture_structure = last_pic_structure;
1541 h->droppable = last_pic_droppable;
1548 while (
h->poc.frame_num !=
h->poc.prev_frame_num && !
h->first_field &&
1549 h->poc.frame_num != (
h->poc.prev_frame_num + 1) % (1 <<
sps->log2_max_frame_num)) {
1552 h->poc.frame_num,
h->poc.prev_frame_num);
1553 if (!
sps->gaps_in_frame_num_allowed_flag)
1555 h->last_pocs[
i] = INT_MIN;
1562 h->poc.prev_frame_num++;
1563 h->poc.prev_frame_num %= 1 <<
sps->log2_max_frame_num;
1564 h->cur_pic_ptr->frame_num =
h->poc.prev_frame_num;
1565 h->cur_pic_ptr->invalid_gap = !
sps->gaps_in_frame_num_allowed_flag;
1569 h->explicit_ref_marking = 0;
1580 if (
h->short_ref_count) {
1582 1<<(
h->ps.sps->bit_depth_luma-1),
1583 1<<(
h->ps.sps->bit_depth_chroma-1),
1584 1<<(
h->ps.sps->bit_depth_chroma-1),
1589 h->short_ref[0]->f->width == prev->
f->
width &&
1590 h->short_ref[0]->f->height == prev->
f->
height &&
1591 h->short_ref[0]->f->format == prev->
f->
format) {
1596 h->short_ref[0]->f->linesize,
1602 h->short_ref[0]->poc = prev->
poc + 2;
1603 }
else if (!
h->frame_recovered && !
h->avctx->hwaccel)
1605 h->short_ref[0]->frame_num =
h->poc.prev_frame_num;
1612 if (
h->first_field) {
1618 if (!
FIELD_PICTURE(
h) ||
h->picture_structure == last_pic_structure) {
1621 h->missing_fields ++;
1622 h->cur_pic_ptr =
NULL;
1625 h->missing_fields = 0;
1626 if (
h->cur_pic_ptr->frame_num !=
h->poc.frame_num) {
1633 h->cur_pic_ptr =
NULL;
1639 h->cur_pic_ptr =
NULL;
1658 h->cur_pic_ptr->tf.owner[
field] =
h->avctx;
1664 memset(
h->slice_table +
i*
h->mb_stride, -1, (
h->mb_stride - (
i+1==
h->mb_height)) *
sizeof(*
h->slice_table));
1666 memset(
h->slice_table, -1,
1667 (
h->mb_height *
h->mb_stride - 1) *
sizeof(*
h->slice_table));
1671 h->ps.sps, &
h->poc,
h->picture_structure, nal->
ref_idc);
1681 if (
h->sei.recovery_point.recovery_frame_cnt >= 0) {
1682 const int sei_recovery_frame_cnt =
h->sei.recovery_point.recovery_frame_cnt;
1685 h->valid_recovery_point = 1;
1687 if (
h->recovery_frame < 0
1688 || av_mod_uintp2(
h->recovery_frame -
h->poc.frame_num,
h->ps.sps->log2_max_frame_num) > sei_recovery_frame_cnt) {
1689 h->recovery_frame = av_mod_uintp2(
h->poc.frame_num + sei_recovery_frame_cnt,
h->ps.sps->log2_max_frame_num);
1691 if (!
h->valid_recovery_point)
1692 h->recovery_frame =
h->poc.frame_num;
1699 (
h->recovery_frame ==
h->poc.frame_num && nal->
ref_idc)) {
1700 h->recovery_frame = -1;
1701 h->cur_pic_ptr->recovered = 1;
1708 h->cur_pic_ptr->recovered |=
h->frame_recovered;
1735 unsigned int slice_type,
tmp,
i;
1736 int field_pic_flag, bottom_field_flag;
1737 int first_slice = sl ==
h->slice_ctx && !
h->current_slice;
1738 int picture_structure;
1746 if (slice_type > 9) {
1748 "slice type %d too large at %d\n",
1752 if (slice_type > 4) {
1773 if (!
h->ps.pps_list[sl->
pps_id]) {
1775 "non-existing PPS %u referenced\n",
1793 if (
sps->frame_mbs_only_flag) {
1797 av_log(
h->avctx,
AV_LOG_ERROR,
"This stream was generated by a broken encoder, invalid 8x8 inference\n");
1801 if (field_pic_flag) {
1822 if (
sps->poc_type == 0) {
1825 if (
pps->pic_order_present == 1 && picture_structure ==
PICT_FRAME)
1829 if (
sps->poc_type == 1 && !
sps->delta_pic_order_always_zero_flag) {
1832 if (
pps->pic_order_present == 1 && picture_structure ==
PICT_FRAME)
1837 if (
pps->redundant_pic_cnt_present)
1845 picture_structure,
h->avctx);
1858 for (
i = 0;
i < 2;
i++) {
1863 (
pps->weighted_bipred_idc == 1 &&
1867 picture_structure,
h->avctx);
1890 if (
tmp > 51 + 6 * (
sps->bit_depth_luma - 8)) {
1907 if (
pps->deblocking_filter_parameters_present) {
1911 "deblocking_filter_idc %u out of range\n",
tmp);
1921 if (slice_alpha_c0_offset_div2 > 6 ||
1922 slice_alpha_c0_offset_div2 < -6 ||
1923 slice_beta_offset_div2 > 6 ||
1924 slice_beta_offset_div2 < -6) {
1926 "deblocking filter parameters %d %d out of range\n",
1927 slice_alpha_c0_offset_div2, slice_beta_offset_div2);
1967 if (
h->ps.pps->weighted_bipred_idc == 2 &&
1978 if (!
h->setup_finished)
1998 h->postpone_filter = 1;
2004 h->ps.pps->chroma_qp_index_offset[0],
2005 h->ps.pps->chroma_qp_index_offset[1]) +
2006 6 * (
h->ps.sps->bit_depth_luma - 8);
2019 for (j = 0; j < 2; j++) {
2022 for (
i = 0;
i < 16;
i++) {
2024 if (j < sl->list_count && i < sl->ref_count[j] &&
2028 for (k = 0; k <
h->short_ref_count; k++)
2029 if (
h->short_ref[k]->f->buf[0]->buffer == buf) {
2033 for (k = 0; k <
h->long_ref_count; k++)
2034 if (
h->long_ref[k] &&
h->long_ref[k]->f->buf[0]->buffer == buf) {
2035 id_list[
i] =
h->short_ref_count + k;
2043 for (
i = 0;
i < 16;
i++)
2046 ref2frm[18 + 1] = -1;
2047 for (
i = 16;
i < 48;
i++)
2048 ref2frm[
i + 4] = 4 * id_list[(
i - 16) >> 1] +
2054 "slice:%d %s mb:%d %c%s%s frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s %s\n",
2062 h->cur_pic_ptr->field_poc[0],
2063 h->cur_pic_ptr->field_poc[1],
2079 int first_slice = sl ==
h->slice_ctx && !
h->current_slice;
2095 if (
h->setup_finished) {
2102 if (
h->current_slice) {
2105 if (
h->nb_slice_ctx_queued) {
2112 memcpy(&tmp_ctx,
h->slice_ctx,
sizeof(tmp_ctx));
2113 memcpy(
h->slice_ctx, sl,
sizeof(tmp_ctx));
2114 memcpy(sl, &tmp_ctx,
sizeof(tmp_ctx));
2127 h->cur_pic_ptr =
NULL;
2134 if (!
h->first_field) {
2135 if (
h->cur_pic_ptr && !
h->droppable) {
2139 h->cur_pic_ptr =
NULL;
2143 if (!
h->current_slice)
2146 if (
h->current_slice == 0 && !
h->first_field) {
2160 if (
h->ps.pps->sps_id !=
pps->sps_id ||
2161 h->ps.pps->transform_8x8_mode !=
pps->transform_8x8_mode
2166 if (
h->ps.sps !=
pps->sps) {
2168 "SPS changed in the middle of the frame\n");
2173 if (
h->current_slice == 0) {
2179 h->droppable != (nal->
ref_idc == 0)) {
2181 "Changing field mode (%d -> %d) between slices is not allowed\n",
2184 }
else if (!
h->cur_pic_ptr) {
2186 "unset cur_pic_ptr on slice %d\n",
2187 h->current_slice + 1);
2196 h->nb_slice_ctx_queued++;
2221 int mb_type,
int top_xy,
2225 int mb_xy,
int list)
2227 int b_stride =
h->b_stride;
2232 const int b_xy =
h->mb2b_xy[top_xy] + 3 * b_stride;
2233 const int b8_xy = 4 * top_xy + 2;
2236 ref_cache[0 - 1 * 8] =
2237 ref_cache[1 - 1 * 8] = ref2frm[
h->cur_pic.ref_index[
list][b8_xy + 0]];
2238 ref_cache[2 - 1 * 8] =
2239 ref_cache[3 - 1 * 8] = ref2frm[
h->cur_pic.ref_index[
list][b8_xy + 1]];
2247 const int b_xy =
h->mb2b_xy[left_xy[
LTOP]] + 3;
2248 const int b8_xy = 4 * left_xy[
LTOP] + 1;
2250 AV_COPY32(mv_dst - 1 + 0,
h->cur_pic.motion_val[
list][b_xy + b_stride * 0]);
2251 AV_COPY32(mv_dst - 1 + 8,
h->cur_pic.motion_val[
list][b_xy + b_stride * 1]);
2252 AV_COPY32(mv_dst - 1 + 16,
h->cur_pic.motion_val[
list][b_xy + b_stride * 2]);
2253 AV_COPY32(mv_dst - 1 + 24,
h->cur_pic.motion_val[
list][b_xy + b_stride * 3]);
2255 ref_cache[-1 + 8] = ref2frm[
h->cur_pic.ref_index[
list][b8_xy + 2 * 0]];
2256 ref_cache[-1 + 16] =
2257 ref_cache[-1 + 24] = ref2frm[
h->cur_pic.ref_index[
list][b8_xy + 2 * 1]];
2265 ref_cache[-1 + 16] =
2281 int8_t *
ref = &
h->cur_pic.ref_index[
list][4 * mb_xy];
2283 uint32_t ref01 = (
pack16to32(ref2frm[
ref[0]], ref2frm[
ref[1]]) & 0x00FF00FF) * 0x0101;
2284 uint32_t ref23 = (
pack16to32(ref2frm[
ref[2]], ref2frm[
ref[3]]) & 0x00FF00FF) * 0x0101;
2285 AV_WN32A(&ref_cache[0 * 8], ref01);
2286 AV_WN32A(&ref_cache[1 * 8], ref01);
2287 AV_WN32A(&ref_cache[2 * 8], ref23);
2288 AV_WN32A(&ref_cache[3 * 8], ref23);
2292 int16_t(*mv_src)[2] = &
h->cur_pic.motion_val[
list][4 * sl->
mb_x + 4 * sl->
mb_y * b_stride];
2293 AV_COPY128(mv_dst + 8 * 0, mv_src + 0 * b_stride);
2294 AV_COPY128(mv_dst + 8 * 1, mv_src + 1 * b_stride);
2295 AV_COPY128(mv_dst + 8 * 2, mv_src + 2 * b_stride);
2296 AV_COPY128(mv_dst + 8 * 3, mv_src + 3 * b_stride);
2305 const int mb_xy = sl->
mb_xy;
2311 top_xy = mb_xy - (
h->mb_stride <<
MB_FIELD(sl));
2313 left_xy[
LBOT] = left_xy[
LTOP] = mb_xy - 1;
2315 const int left_mb_field_flag =
IS_INTERLACED(
h->cur_pic.mb_type[mb_xy - 1]);
2318 if (left_mb_field_flag != curr_mb_field_flag)
2319 left_xy[
LTOP] -=
h->mb_stride;
2321 if (curr_mb_field_flag)
2322 top_xy +=
h->mb_stride &
2323 (((
h->cur_pic.mb_type[top_xy] >> 7) & 1) - 1);
2324 if (left_mb_field_flag != curr_mb_field_flag)
2325 left_xy[
LBOT] +=
h->mb_stride;
2337 int qp =
h->cur_pic.qscale_table[mb_xy];
2338 if (qp <= qp_thresh &&
2339 (left_xy[
LTOP] < 0 ||
2340 ((qp +
h->cur_pic.qscale_table[left_xy[
LTOP]] + 1) >> 1) <= qp_thresh) &&
2342 ((qp +
h->cur_pic.qscale_table[top_xy] + 1) >> 1) <= qp_thresh)) {
2345 if ((left_xy[
LTOP] < 0 ||
2346 ((qp +
h->cur_pic.qscale_table[left_xy[
LBOT]] + 1) >> 1) <= qp_thresh) &&
2347 (top_xy <
h->mb_stride ||
2348 ((qp +
h->cur_pic.qscale_table[top_xy -
h->mb_stride] + 1) >> 1) <= qp_thresh))
2353 top_type =
h->cur_pic.mb_type[top_xy];
2354 left_type[
LTOP] =
h->cur_pic.mb_type[left_xy[
LTOP]];
2355 left_type[
LBOT] =
h->cur_pic.mb_type[left_xy[
LBOT]];
2360 left_type[
LTOP] = left_type[
LBOT] = 0;
2362 if (
h->slice_table[top_xy] == 0xFFFF)
2364 if (
h->slice_table[left_xy[
LBOT]] == 0xFFFF)
2365 left_type[
LTOP] = left_type[
LBOT] = 0;
2375 top_type, left_type, mb_xy, 0);
2378 top_type, left_type, mb_xy, 1);
2380 nnz =
h->non_zero_count[mb_xy];
2382 AV_COPY32(&nnz_cache[4 + 8 * 1], &nnz[0]);
2383 AV_COPY32(&nnz_cache[4 + 8 * 2], &nnz[4]);
2384 AV_COPY32(&nnz_cache[4 + 8 * 3], &nnz[8]);
2385 AV_COPY32(&nnz_cache[4 + 8 * 4], &nnz[12]);
2386 sl->
cbp =
h->cbp_table[mb_xy];
2389 nnz =
h->non_zero_count[top_xy];
2390 AV_COPY32(&nnz_cache[4 + 8 * 0], &nnz[3 * 4]);
2393 if (left_type[
LTOP]) {
2394 nnz =
h->non_zero_count[left_xy[
LTOP]];
2395 nnz_cache[3 + 8 * 1] = nnz[3 + 0 * 4];
2396 nnz_cache[3 + 8 * 2] = nnz[3 + 1 * 4];
2397 nnz_cache[3 + 8 * 3] = nnz[3 + 2 * 4];
2398 nnz_cache[3 + 8 * 4] = nnz[3 + 3 * 4];
2403 if (!
CABAC(
h) &&
h->ps.pps->transform_8x8_mode) {
2405 nnz_cache[4 + 8 * 0] =
2406 nnz_cache[5 + 8 * 0] = (
h->cbp_table[top_xy] & 0x4000) >> 12;
2407 nnz_cache[6 + 8 * 0] =
2408 nnz_cache[7 + 8 * 0] = (
h->cbp_table[top_xy] & 0x8000) >> 12;
2411 nnz_cache[3 + 8 * 1] =
2412 nnz_cache[3 + 8 * 2] = (
h->cbp_table[left_xy[
LTOP]] & 0x2000) >> 12;
2415 nnz_cache[3 + 8 * 3] =
2416 nnz_cache[3 + 8 * 4] = (
h->cbp_table[left_xy[
LBOT]] & 0x8000) >> 12;
2420 nnz_cache[
scan8[0]] =
2421 nnz_cache[
scan8[1]] =
2422 nnz_cache[
scan8[2]] =
2423 nnz_cache[
scan8[3]] = (sl->
cbp & 0x1000) >> 12;
2425 nnz_cache[
scan8[0 + 4]] =
2426 nnz_cache[
scan8[1 + 4]] =
2427 nnz_cache[
scan8[2 + 4]] =
2428 nnz_cache[
scan8[3 + 4]] = (sl->
cbp & 0x2000) >> 12;
2430 nnz_cache[
scan8[0 + 8]] =
2431 nnz_cache[
scan8[1 + 8]] =
2432 nnz_cache[
scan8[2 + 8]] =
2433 nnz_cache[
scan8[3 + 8]] = (sl->
cbp & 0x4000) >> 12;
2435 nnz_cache[
scan8[0 + 12]] =
2436 nnz_cache[
scan8[1 + 12]] =
2437 nnz_cache[
scan8[2 + 12]] =
2438 nnz_cache[
scan8[3 + 12]] = (sl->
cbp & 0x8000) >> 12;
2447 uint8_t *dest_y, *dest_cb, *dest_cr;
2448 int linesize, uvlinesize, mb_x, mb_y;
2451 const int pixel_shift =
h->pixel_shift;
2452 const int block_h = 16 >>
h->chroma_y_shift;
2454 if (
h->postpone_filter)
2458 for (mb_x = start_x; mb_x < end_x; mb_x++)
2459 for (mb_y = end_mb_y -
FRAME_MBAFF(
h); mb_y <= end_mb_y; mb_y++) {
2461 mb_xy = sl->
mb_xy = mb_x + mb_y *
h->mb_stride;
2462 mb_type =
h->cur_pic.mb_type[mb_xy];
2470 dest_y =
h->cur_pic.f->data[0] +
2471 ((mb_x << pixel_shift) + mb_y * sl->
linesize) * 16;
2472 dest_cb =
h->cur_pic.f->data[1] +
2473 (mb_x << pixel_shift) * (8 <<
CHROMA444(
h)) +
2475 dest_cr =
h->cur_pic.f->data[2] +
2476 (mb_x << pixel_shift) * (8 <<
CHROMA444(
h)) +
2501 linesize, uvlinesize);
2504 dest_cr, linesize, uvlinesize);
2517 const int mb_xy = sl->
mb_x + sl->
mb_y *
h->mb_stride;
2518 int mb_type = (
h->slice_table[mb_xy - 1] == sl->
slice_num) ?
2519 h->cur_pic.mb_type[mb_xy - 1] :
2520 (
h->slice_table[mb_xy -
h->mb_stride] == sl->
slice_num) ?
2521 h->cur_pic.mb_type[mb_xy -
h->mb_stride] : 0;
2536 if ((top +
height) >= pic_height)
2537 height += deblock_border;
2538 top -= deblock_border;
2541 if (top >= pic_height || (top +
height) < 0)
2560 int startx,
int starty,
2561 int endx,
int endy,
int status)
2577 int lf_x_start = sl->
mb_x;
2581 sl->
linesize =
h->cur_pic_ptr->f->linesize[0];
2592 if (
h->postpone_filter)
2598 if (!(
h->avctx->active_thread_type &
FF_THREAD_SLICE) &&
h->picture_structure ==
PICT_FRAME &&
h->slice_ctx[0].er.error_status_table) {
2601 int prev_status =
h->slice_ctx[0].er.error_status_table[
h->slice_ctx[0].er.mb_index2xy[start_i - 1]];
2604 h->slice_ctx[0].er.error_occurred = 1;
2608 if (
h->ps.pps->cabac) {
2652 if (sl->
mb_x >= lf_x_start)
2668 if (++sl->
mb_x >=
h->mb_width) {
2670 sl->
mb_x = lf_x_start = 0;
2680 if (eos || sl->
mb_y >=
h->mb_height) {
2681 ff_tlog(
h->avctx,
"slice end %d %d\n",
2685 if (sl->
mb_x > lf_x_start)
2719 "error while decoding MB %d %d\n", sl->
mb_x, sl->
mb_y);
2725 if (++sl->
mb_x >=
h->mb_width) {
2727 sl->
mb_x = lf_x_start = 0;
2735 if (sl->
mb_y >=
h->mb_height) {
2736 ff_tlog(
h->avctx,
"slice end %d %d\n",
2755 ff_tlog(
h->avctx,
"slice end %d %d\n",
2761 if (sl->
mb_x > lf_x_start)
2789 int context_count =
h->nb_slice_ctx_queued;
2793 h->slice_ctx[0].next_slice_idx = INT_MAX;
2795 if (
h->avctx->hwaccel || context_count < 1)
2798 av_assert0(context_count &&
h->slice_ctx[context_count - 1].mb_y <
h->mb_height);
2800 if (context_count == 1) {
2802 h->slice_ctx[0].next_slice_idx =
h->mb_width *
h->mb_height;
2803 h->postpone_filter = 0;
2806 h->mb_y =
h->slice_ctx[0].mb_y;
2811 for (
i = 0;
i < context_count;
i++) {
2812 int next_slice_idx =
h->mb_width *
h->mb_height;
2815 sl = &
h->slice_ctx[
i];
2821 slice_idx = sl->
mb_y *
h->mb_width + sl->
mb_x;
2822 for (j = 0; j < context_count; j++) {
2824 int slice_idx2 = sl2->
mb_y *
h->mb_width + sl2->
mb_x;
2826 if (
i == j || slice_idx2 < slice_idx)
2828 next_slice_idx =
FFMIN(next_slice_idx, slice_idx2);
2834 NULL, context_count,
sizeof(
h->slice_ctx[0]));
2837 sl = &
h->slice_ctx[context_count - 1];
2840 for (
i = 1;
i < context_count;
i++)
2841 h->slice_ctx[0].er.error_count +=
h->slice_ctx[
i].er.error_count;
2844 if (
h->postpone_filter) {
2845 h->postpone_filter = 0;
2847 for (
i = 0;
i < context_count;
i++) {
2850 sl = &
h->slice_ctx[
i];
2852 x_end = (sl->
mb_y >=
h->mb_height) ?
h->mb_width : sl->
mb_x;
2857 j == y_end - 1 ? x_end :
h->mb_width);
2864 h->nb_slice_ctx_queued = 0;