28 #include "config_components.h" 
   52     0 + 0 * 4, 0 + 1 * 4, 1 + 0 * 4, 0 + 2 * 4,
 
   53     0 + 3 * 4, 1 + 1 * 4, 1 + 2 * 4, 1 + 3 * 4,
 
   54     2 + 0 * 4, 2 + 1 * 4, 2 + 2 * 4, 2 + 3 * 4,
 
   55     3 + 0 * 4, 3 + 1 * 4, 3 + 2 * 4, 3 + 3 * 4,
 
   59     0 + 0 * 8, 0 + 1 * 8, 0 + 2 * 8, 1 + 0 * 8,
 
   60     1 + 1 * 8, 0 + 3 * 8, 0 + 4 * 8, 1 + 2 * 8,
 
   61     2 + 0 * 8, 1 + 3 * 8, 0 + 5 * 8, 0 + 6 * 8,
 
   62     0 + 7 * 8, 1 + 4 * 8, 2 + 1 * 8, 3 + 0 * 8,
 
   63     2 + 2 * 8, 1 + 5 * 8, 1 + 6 * 8, 1 + 7 * 8,
 
   64     2 + 3 * 8, 3 + 1 * 8, 4 + 0 * 8, 3 + 2 * 8,
 
   65     2 + 4 * 8, 2 + 5 * 8, 2 + 6 * 8, 2 + 7 * 8,
 
   66     3 + 3 * 8, 4 + 1 * 8, 5 + 0 * 8, 4 + 2 * 8,
 
   67     3 + 4 * 8, 3 + 5 * 8, 3 + 6 * 8, 3 + 7 * 8,
 
   68     4 + 3 * 8, 5 + 1 * 8, 6 + 0 * 8, 5 + 2 * 8,
 
   69     4 + 4 * 8, 4 + 5 * 8, 4 + 6 * 8, 4 + 7 * 8,
 
   70     5 + 3 * 8, 6 + 1 * 8, 6 + 2 * 8, 5 + 4 * 8,
 
   71     5 + 5 * 8, 5 + 6 * 8, 5 + 7 * 8, 6 + 3 * 8,
 
   72     7 + 0 * 8, 7 + 1 * 8, 6 + 4 * 8, 6 + 5 * 8,
 
   73     6 + 6 * 8, 6 + 7 * 8, 7 + 2 * 8, 7 + 3 * 8,
 
   74     7 + 4 * 8, 7 + 5 * 8, 7 + 6 * 8, 7 + 7 * 8,
 
   78     0 + 0 * 8, 1 + 1 * 8, 2 + 0 * 8, 0 + 7 * 8,
 
   79     2 + 2 * 8, 2 + 3 * 8, 2 + 4 * 8, 3 + 3 * 8,
 
   80     3 + 4 * 8, 4 + 3 * 8, 4 + 4 * 8, 5 + 3 * 8,
 
   81     5 + 5 * 8, 7 + 0 * 8, 6 + 6 * 8, 7 + 4 * 8,
 
   82     0 + 1 * 8, 0 + 3 * 8, 1 + 3 * 8, 1 + 4 * 8,
 
   83     1 + 5 * 8, 3 + 1 * 8, 2 + 5 * 8, 4 + 1 * 8,
 
   84     3 + 5 * 8, 5 + 1 * 8, 4 + 5 * 8, 6 + 1 * 8,
 
   85     5 + 6 * 8, 7 + 1 * 8, 6 + 7 * 8, 7 + 5 * 8,
 
   86     0 + 2 * 8, 0 + 4 * 8, 0 + 5 * 8, 2 + 1 * 8,
 
   87     1 + 6 * 8, 4 + 0 * 8, 2 + 6 * 8, 5 + 0 * 8,
 
   88     3 + 6 * 8, 6 + 0 * 8, 4 + 6 * 8, 6 + 2 * 8,
 
   89     5 + 7 * 8, 6 + 4 * 8, 7 + 2 * 8, 7 + 6 * 8,
 
   90     1 + 0 * 8, 1 + 2 * 8, 0 + 6 * 8, 3 + 0 * 8,
 
   91     1 + 7 * 8, 3 + 2 * 8, 2 + 7 * 8, 4 + 2 * 8,
 
   92     3 + 7 * 8, 5 + 2 * 8, 4 + 7 * 8, 5 + 4 * 8,
 
   93     6 + 3 * 8, 6 + 5 * 8, 7 + 3 * 8, 7 + 7 * 8,
 
   98     0 + 0 * 8, 1 + 1 * 8, 1 + 2 * 8, 2 + 2 * 8,
 
   99     4 + 1 * 8, 0 + 5 * 8, 3 + 3 * 8, 7 + 0 * 8,
 
  100     3 + 4 * 8, 1 + 7 * 8, 5 + 3 * 8, 6 + 3 * 8,
 
  101     2 + 7 * 8, 6 + 4 * 8, 5 + 6 * 8, 7 + 5 * 8,
 
  102     1 + 0 * 8, 2 + 0 * 8, 0 + 3 * 8, 3 + 1 * 8,
 
  103     3 + 2 * 8, 0 + 6 * 8, 4 + 2 * 8, 6 + 1 * 8,
 
  104     2 + 5 * 8, 2 + 6 * 8, 6 + 2 * 8, 5 + 4 * 8,
 
  105     3 + 7 * 8, 7 + 3 * 8, 4 + 7 * 8, 7 + 6 * 8,
 
  106     0 + 1 * 8, 3 + 0 * 8, 0 + 4 * 8, 4 + 0 * 8,
 
  107     2 + 3 * 8, 1 + 5 * 8, 5 + 1 * 8, 5 + 2 * 8,
 
  108     1 + 6 * 8, 3 + 5 * 8, 7 + 1 * 8, 4 + 5 * 8,
 
  109     4 + 6 * 8, 7 + 4 * 8, 5 + 7 * 8, 6 + 7 * 8,
 
  110     0 + 2 * 8, 2 + 1 * 8, 1 + 3 * 8, 5 + 0 * 8,
 
  111     1 + 4 * 8, 2 + 4 * 8, 6 + 0 * 8, 4 + 3 * 8,
 
  112     0 + 7 * 8, 4 + 4 * 8, 7 + 2 * 8, 3 + 6 * 8,
 
  113     5 + 5 * 8, 6 + 5 * 8, 6 + 6 * 8, 7 + 7 * 8,
 
  122         if (
h->DPB[
i].f->buf[0] && !
h->DPB[
i].reference &&
 
  123             (remove_current || &
h->DPB[
i] != 
h->cur_pic_ptr)) {
 
  140                    h->mb_width * 16 * 3 * 
sizeof(uint8_t) * 2);
 
  142                    h->mb_width * 16 * 3 * 
sizeof(uint8_t) * 2);
 
  163     const int big_mb_num    = 
h->mb_stride * (
h->mb_height + 1) + 1;
 
  164     const int mb_array_size = 
h->mb_stride * 
h->mb_height;
 
  165     const int b4_stride     = 
h->mb_width * 4 + 1;
 
  166     const int b4_array_size = b4_stride * 
h->mb_height * 4;
 
  170                                                    sizeof(uint32_t), 0);
 
  175     if (!
h->qscale_table_pool || !
h->mb_type_pool || !
h->motion_val_pool ||
 
  176         !
h->ref_index_pool) {
 
  212     if (
h->decode_error_flags_pool) {
 
  220         int h_chroma_shift, v_chroma_shift;
 
  222                                          &h_chroma_shift, &v_chroma_shift);
 
  232     if (!
h->qscale_table_pool) {
 
  246     for (
i = 0; 
i < 2; 
i++) {
 
  272         if (!
h->DPB[
i].f->buf[0])
 
  279 #define IN_RANGE(a, b, size) (((void*)(a) >= (void*)(b)) && ((void*)(a) < (void*)((b) + (size)))) 
  281 #define REBASE_PICTURE(pic, new_ctx, old_ctx)             \ 
  282     (((pic) && (pic) >= (old_ctx)->DPB &&                       \ 
  283       (pic) < (old_ctx)->DPB + H264_MAX_PICTURE_COUNT) ?          \ 
  284      &(new_ctx)->DPB[(pic) - (old_ctx)->DPB] : NULL) 
  291     for (
i = 0; 
i < count; 
i++) {
 
  305     for (
int p = 0; p < 
desc->nb_components; p++) {
 
  307         int is_chroma = p == 1 || p == 2;
 
  310         if (
desc->comp[0].depth >= 9) {
 
  311             ((uint16_t*)dst)[0] = 
c[p];
 
  314             for (
int y = 1; y < 
height; y++) {
 
  319             for (
int y = 0; y < 
height; y++) {
 
  320                 memset(dst, 
c[p], bytes);
 
  333     int inited = 
h->context_initialized, err = 0;
 
  340     if (inited && !h1->ps.sps)
 
  344         (
h->width                 != h1->width                 ||
 
  345          h->height                != h1->height                ||
 
  346          h->mb_width              != h1->mb_width              ||
 
  347          h->mb_height             != h1->mb_height             ||
 
  349          h->ps.sps->bit_depth_luma    != h1->ps.sps->bit_depth_luma    ||
 
  350          h->ps.sps->chroma_format_idc != h1->ps.sps->chroma_format_idc ||
 
  351          h->ps.sps->vui.matrix_coeffs != h1->ps.sps->vui.matrix_coeffs)) {
 
  356     memcpy(
h->block_offset, h1->block_offset, 
sizeof(
h->block_offset));
 
  365     h->ps.sps = h1->ps.sps;
 
  367     if (need_reinit || !inited) {
 
  368         h->width     = h1->width;
 
  369         h->height    = h1->height;
 
  370         h->mb_height = h1->mb_height;
 
  371         h->mb_width  = h1->mb_width;
 
  372         h->mb_num    = h1->mb_num;
 
  373         h->mb_stride = h1->mb_stride;
 
  374         h->b_stride  = h1->b_stride;
 
  375         h->x264_build = h1->x264_build;
 
  377         if (
h->context_initialized || h1->context_initialized) {
 
  385         memcpy(
h->block_offset, h1->block_offset, 
sizeof(
h->block_offset));
 
  388     h->width_from_caller    = h1->width_from_caller;
 
  389     h->height_from_caller   = h1->height_from_caller;
 
  390     h->coded_picture_number = h1->coded_picture_number;
 
  391     h->first_field          = h1->first_field;
 
  392     h->picture_structure    = h1->picture_structure;
 
  393     h->mb_aff_frame         = h1->mb_aff_frame;
 
  394     h->droppable            = h1->droppable;
 
  407     h->enable_er       = h1->enable_er;
 
  408     h->workaround_bugs = h1->workaround_bugs;
 
  409     h->droppable       = h1->droppable;
 
  412     h->is_avc = h1->is_avc;
 
  413     h->nal_length_size = h1->nal_length_size;
 
  415     memcpy(&
h->poc,        &h1->poc,        
sizeof(
h->poc));
 
  417     memcpy(
h->short_ref,   h1->short_ref,   
sizeof(
h->short_ref));
 
  418     memcpy(
h->long_ref,    h1->long_ref,    
sizeof(
h->long_ref));
 
  419     memcpy(
h->delayed_pic, h1->delayed_pic, 
sizeof(
h->delayed_pic));
 
  420     memcpy(
h->last_pocs,   h1->last_pocs,   
sizeof(
h->last_pocs));
 
  422     h->next_output_pic   = h1->next_output_pic;
 
  423     h->next_outputed_poc = h1->next_outputed_poc;
 
  424     h->poc_offset        = h1->poc_offset;
 
  426     memcpy(
h->mmco, h1->mmco, 
sizeof(
h->mmco));
 
  427     h->nb_mmco         = h1->nb_mmco;
 
  428     h->mmco_reset      = h1->mmco_reset;
 
  429     h->explicit_ref_marking = h1->explicit_ref_marking;
 
  430     h->long_ref_count  = h1->long_ref_count;
 
  431     h->short_ref_count = h1->short_ref_count;
 
  438     h->frame_recovered       = h1->frame_recovered;
 
  444     h->sei.common.unregistered.x264_build = h1->sei.common.unregistered.x264_build;
 
  445     h->sei.common.mastering_display = h1->sei.common.mastering_display;
 
  446     h->sei.common.content_light = h1->sei.common.content_light;
 
  453         h->poc.prev_poc_msb = 
h->poc.poc_msb;
 
  454         h->poc.prev_poc_lsb = 
h->poc.poc_lsb;
 
  456     h->poc.prev_frame_num_offset = 
h->poc.frame_num_offset;
 
  457     h->poc.prev_frame_num        = 
h->poc.frame_num;
 
  459     h->recovery_frame        = h1->recovery_frame;
 
  460     h->non_gray              = h1->non_gray;
 
  481     const int pixel_shift = 
h->pixel_shift;
 
  489     h->cur_pic_ptr = 
NULL;
 
  498     pic->
reference              = 
h->droppable ? 0 : 
h->picture_structure;
 
  519     pic->
needs_fg = 
h->sei.common.film_grain_characteristics.present && !
h->avctx->hwaccel &&
 
  525     h->cur_pic_ptr = pic;
 
  527     if (CONFIG_ERROR_RESILIENCE) {
 
  534     for (
i = 0; 
i < 
h->nb_slice_ctx; 
i++) {
 
  535         h->slice_ctx[
i].linesize   = 
h->cur_pic_ptr->f->linesize[0];
 
  536         h->slice_ctx[
i].uvlinesize = 
h->cur_pic_ptr->f->linesize[1];
 
  539     if (CONFIG_ERROR_RESILIENCE && 
h->enable_er) {
 
  545     for (
i = 0; 
i < 16; 
i++) {
 
  549     for (
i = 0; 
i < 16; 
i++) {
 
  550         h->block_offset[16 + 
i]      =
 
  552         h->block_offset[48 + 16 + 
i] =
 
  560     h->cur_pic_ptr->reference = 0;
 
  562     h->cur_pic_ptr->field_poc[0] = 
h->cur_pic_ptr->field_poc[1] = INT_MAX;
 
  564     h->next_output_pic = 
NULL;
 
  566     h->postpone_filter = 0;
 
  568     h->mb_aff_frame = 
h->ps.sps->mb_aff && (
h->picture_structure == 
PICT_FRAME);
 
  570     if (
h->sei.common.unregistered.x264_build >= 0)
 
  571         h->x264_build = 
h->sei.common.unregistered.x264_build;
 
  573     assert(
h->cur_pic_ptr->long_ref == 0);
 
  579                                               const uint8_t *src_y,
 
  580                                               const uint8_t *src_cb, 
const uint8_t *src_cr,
 
  581                                               int linesize, 
int uvlinesize,
 
  586     const int pixel_shift = 
h->pixel_shift;
 
  591     src_cb -= uvlinesize;
 
  592     src_cr -= uvlinesize;
 
  598                 AV_COPY128(top_border, src_y + 15 * linesize);
 
  600                     AV_COPY128(top_border + 16, src_y + 15 * linesize + 16);
 
  604                             AV_COPY128(top_border + 32, src_cb + 15 * uvlinesize);
 
  605                             AV_COPY128(top_border + 48, src_cb + 15 * uvlinesize + 16);
 
  606                             AV_COPY128(top_border + 64, src_cr + 15 * uvlinesize);
 
  607                             AV_COPY128(top_border + 80, src_cr + 15 * uvlinesize + 16);
 
  609                             AV_COPY128(top_border + 16, src_cb + 15 * uvlinesize);
 
  610                             AV_COPY128(top_border + 32, src_cr + 15 * uvlinesize);
 
  612                     } 
else if (chroma422) {
 
  614                             AV_COPY128(top_border + 32, src_cb + 15 * uvlinesize);
 
  615                             AV_COPY128(top_border + 48, src_cr + 15 * uvlinesize);
 
  617                             AV_COPY64(top_border + 16, src_cb + 15 * uvlinesize);
 
  618                             AV_COPY64(top_border + 24, src_cr + 15 * uvlinesize);
 
  622                             AV_COPY128(top_border + 32, src_cb + 7 * uvlinesize);
 
  623                             AV_COPY128(top_border + 48, src_cr + 7 * uvlinesize);
 
  625                             AV_COPY64(top_border + 16, src_cb + 7 * uvlinesize);
 
  626                             AV_COPY64(top_border + 24, src_cr + 7 * uvlinesize);
 
  640     AV_COPY128(top_border, src_y + 16 * linesize);
 
  642         AV_COPY128(top_border + 16, src_y + 16 * linesize + 16);
 
  647                 AV_COPY128(top_border + 32, src_cb + 16 * linesize);
 
  648                 AV_COPY128(top_border + 48, src_cb + 16 * linesize + 16);
 
  649                 AV_COPY128(top_border + 64, src_cr + 16 * linesize);
 
  650                 AV_COPY128(top_border + 80, src_cr + 16 * linesize + 16);
 
  652                 AV_COPY128(top_border + 16, src_cb + 16 * linesize);
 
  653                 AV_COPY128(top_border + 32, src_cr + 16 * linesize);
 
  655         } 
else if (chroma422) {
 
  657                 AV_COPY128(top_border + 32, src_cb + 16 * uvlinesize);
 
  658                 AV_COPY128(top_border + 48, src_cr + 16 * uvlinesize);
 
  660                 AV_COPY64(top_border + 16, src_cb + 16 * uvlinesize);
 
  661                 AV_COPY64(top_border + 24, src_cr + 16 * uvlinesize);
 
  665                 AV_COPY128(top_border + 32, src_cb + 8 * uvlinesize);
 
  666                 AV_COPY128(top_border + 48, src_cr + 8 * uvlinesize);
 
  668                 AV_COPY64(top_border + 16, src_cb + 8 * uvlinesize);
 
  669                 AV_COPY64(top_border + 24, src_cr + 8 * uvlinesize);
 
  682     int ref0, ref1, 
i, cur_poc, ref_start, ref_count0, ref_count1;
 
  684     for (
i = 0; 
i < 2; 
i++) {
 
  691             cur_poc = 
h->cur_pic_ptr->poc;
 
  693             cur_poc = 
h->cur_pic_ptr->field_poc[
h->picture_structure - 1];
 
  705         cur_poc    = 
h->cur_pic_ptr->field_poc[
field];
 
  716     for (ref0 = ref_start; ref0 < ref_count0; ref0++) {
 
  718         for (ref1 = ref_start; ref1 < ref_count1; ref1++) {
 
  725                     int tx = (16384 + (
FFABS(
td) >> 1)) / 
td;
 
  726                     int dist_scale_factor = (
tb * tx + 32) >> 8;
 
  727                     if (dist_scale_factor >= -64 && dist_scale_factor <= 128)
 
  728                         w = 64 - dist_scale_factor;
 
  747     for (
i = 0; 
i < 16; 
i++) {
 
  748 #define TRANSPOSE(x) ((x) >> 2) | (((x) << 2) & 0xF) 
  753     for (
i = 0; 
i < 64; 
i++) {
 
  754 #define TRANSPOSE(x) ((x) >> 3) | (((x) & 7) << 3) 
  761     if (
h->ps.sps->transform_bypass) { 
 
  765         memcpy(
h->field_scan_q0           , 
field_scan              , 
sizeof(
h->field_scan_q0          ));
 
  766         memcpy(
h->field_scan8x8_q0        , 
field_scan8x8           , 
sizeof(
h->field_scan8x8_q0       ));
 
  769         memcpy(
h->zigzag_scan_q0          , 
h->zigzag_scan          , 
sizeof(
h->zigzag_scan_q0         ));
 
  770         memcpy(
h->zigzag_scan8x8_q0       , 
h->zigzag_scan8x8       , 
sizeof(
h->zigzag_scan8x8_q0      ));
 
  771         memcpy(
h->zigzag_scan8x8_cavlc_q0 , 
h->zigzag_scan8x8_cavlc , 
sizeof(
h->zigzag_scan8x8_cavlc_q0));
 
  772         memcpy(
h->field_scan_q0           , 
h->field_scan           , 
sizeof(
h->field_scan_q0          ));
 
  773         memcpy(
h->field_scan8x8_q0        , 
h->field_scan8x8        , 
sizeof(
h->field_scan8x8_q0       ));
 
  774         memcpy(
h->field_scan8x8_cavlc_q0  , 
h->field_scan8x8_cavlc  , 
sizeof(
h->field_scan8x8_cavlc_q0 ));
 
  780 #define HWACCEL_MAX (CONFIG_H264_DXVA2_HWACCEL + \ 
  781                      (CONFIG_H264_D3D11VA_HWACCEL * 2) + \ 
  782                      CONFIG_H264_D3D12VA_HWACCEL + \ 
  783                      CONFIG_H264_NVDEC_HWACCEL + \ 
  784                      CONFIG_H264_VAAPI_HWACCEL + \ 
  785                      CONFIG_H264_VIDEOTOOLBOX_HWACCEL + \ 
  786                      CONFIG_H264_VDPAU_HWACCEL + \ 
  787                      CONFIG_H264_VULKAN_HWACCEL) 
  790     switch (
h->ps.sps->bit_depth_luma) {
 
  803 #if CONFIG_H264_VIDEOTOOLBOX_HWACCEL 
  807 #if CONFIG_H264_VULKAN_HWACCEL 
  818 #if CONFIG_H264_VAAPI_HWACCEL 
  828 #if CONFIG_H264_VULKAN_HWACCEL 
  853 #if CONFIG_H264_VDPAU_HWACCEL 
  856 #if CONFIG_H264_VULKAN_HWACCEL 
  859 #if CONFIG_H264_NVDEC_HWACCEL 
  862 #if CONFIG_H264_VIDEOTOOLBOX_HWACCEL 
  879 #if CONFIG_H264_DXVA2_HWACCEL 
  882 #if CONFIG_H264_D3D11VA_HWACCEL 
  886 #if CONFIG_H264_D3D12VA_HWACCEL 
  889 #if CONFIG_H264_VAAPI_HWACCEL 
  900                "Unsupported bit depth %d\n", 
h->ps.sps->bit_depth_luma);
 
  907         if (
pix_fmts[
i] == 
h->avctx->pix_fmt && !force_callback)
 
  916     int cr = 
sps->crop_right;
 
  917     int cl = 
sps->crop_left;
 
  918     int ct = 
sps->crop_top;
 
  919     int cb = 
sps->crop_bottom;
 
  926     if (
h->width_from_caller > 0 && 
h->height_from_caller > 0     &&
 
  927         !
sps->crop_top && !
sps->crop_left                         &&
 
  930         h->width_from_caller  <= 
width &&
 
  931         h->height_from_caller <= 
height) {
 
  932         width  = 
h->width_from_caller;
 
  933         height = 
h->height_from_caller;
 
  939         h->width_from_caller  = 0;
 
  940         h->height_from_caller = 0;
 
  943     h->avctx->coded_width  = 
h->width;
 
  944     h->avctx->coded_height = 
h->height;
 
  965                                      &
h->chroma_x_shift, &
h->chroma_y_shift);
 
  967     if (
sps->timing_info_present_flag) {
 
  969         if (
h->x264_build < 44
U)
 
  971         av_reduce(&
h->avctx->framerate.den, &
h->avctx->framerate.num,
 
  972                   sps->num_units_in_tick * 2, den, 1 << 30);
 
  978     h->prev_interlaced_frame = 1;
 
  987     if (
sps->bit_depth_luma < 8 || 
sps->bit_depth_luma > 14 ||
 
  988         sps->bit_depth_luma == 11 || 
sps->bit_depth_luma == 13
 
  991                sps->bit_depth_luma);
 
  996     h->cur_bit_depth_luma         =
 
  997     h->avctx->bits_per_raw_sample = 
sps->bit_depth_luma;
 
  998     h->cur_chroma_format_idc      = 
sps->chroma_format_idc;
 
  999     h->pixel_shift                = 
sps->bit_depth_luma > 8;
 
 1000     h->chroma_format_idc          = 
sps->chroma_format_idc;
 
 1001     h->bit_depth_luma             = 
sps->bit_depth_luma;
 
 1004                     sps->chroma_format_idc);
 
 1008                       sps->chroma_format_idc);
 
 1014         for (
i = 0; 
i < 
h->nb_slice_ctx; 
i++) {
 
 1019             sl->
mvd_table[0]       = 
h->mvd_table[0]       + 
i * 8 * 2 * 
h->mb_stride;
 
 1020             sl->
mvd_table[1]       = 
h->mvd_table[1]       + 
i * 8 * 2 * 
h->mb_stride;
 
 1026     h->context_initialized = 1;
 
 1031     h->context_initialized = 0;
 
 1049     int needs_reinit = 0, must_reinit, 
ret;
 
 1054     if (
h->ps.sps != 
h->ps.pps->sps) {
 
 1055         h->ps.sps = 
h->ps.pps->sps;
 
 1057         if (
h->mb_width  != 
h->ps.sps->mb_width ||
 
 1058             h->mb_height != 
h->ps.sps->mb_height ||
 
 1059             h->cur_bit_depth_luma    != 
h->ps.sps->bit_depth_luma ||
 
 1060             h->cur_chroma_format_idc != 
h->ps.sps->chroma_format_idc
 
 1064         if (
h->bit_depth_luma    != 
h->ps.sps->bit_depth_luma ||
 
 1065             h->chroma_format_idc != 
h->ps.sps->chroma_format_idc)
 
 1070     must_reinit = (
h->context_initialized &&
 
 1071                     (   16*
sps->mb_width != 
h->avctx->coded_width
 
 1072                      || 16*
sps->mb_height != 
h->avctx->coded_height
 
 1073                      || 
h->cur_bit_depth_luma    != 
sps->bit_depth_luma
 
 1074                      || 
h->cur_chroma_format_idc != 
sps->chroma_format_idc
 
 1075                      || 
h->mb_width  != 
sps->mb_width
 
 1076                      || 
h->mb_height != 
sps->mb_height
 
 1082     if (first_slice && 
av_cmp_q(
sps->vui.sar, 
h->avctx->sample_aspect_ratio))
 
 1085     if (!
h->setup_finished) {
 
 1087         h->avctx->level   = 
sps->level_idc;
 
 1088         h->avctx->refs    = 
sps->ref_frame_count;
 
 1090         h->mb_width  = 
sps->mb_width;
 
 1091         h->mb_height = 
sps->mb_height;
 
 1092         h->mb_num    = 
h->mb_width * 
h->mb_height;
 
 1093         h->mb_stride = 
h->mb_width + 1;
 
 1095         h->b_stride = 
h->mb_width * 4;
 
 1097         h->chroma_y_shift = 
sps->chroma_format_idc <= 1; 
 
 1099         h->width  = 16 * 
h->mb_width;
 
 1100         h->height = 16 * 
h->mb_height;
 
 1104         if (
sps->vui.video_signal_type_present_flag) {
 
 1107             if (
sps->vui.colour_description_present_flag) {
 
 1108                 if (
h->avctx->colorspace != 
sps->vui.matrix_coeffs)
 
 1110                 h->avctx->color_primaries = 
sps->vui.colour_primaries;
 
 1111                 h->avctx->color_trc       = 
sps->vui.transfer_characteristics;
 
 1112                 h->avctx->colorspace      = 
sps->vui.matrix_coeffs;
 
 1116         if (
h->sei.common.alternative_transfer.present &&
 
 1119             h->avctx->color_trc = 
h->sei.common.alternative_transfer.preferred_transfer_characteristics;
 
 1122     h->avctx->chroma_sample_location = 
sps->vui.chroma_location;
 
 1124     if (!
h->context_initialized || must_reinit || needs_reinit) {
 
 1125         int flush_changes = 
h->context_initialized;
 
 1126         h->context_initialized = 0;
 
 1127         if (sl != 
h->slice_ctx) {
 
 1129                    "changing width %d -> %d / height %d -> %d on " 
 1131                    h->width, 
h->avctx->coded_width,
 
 1132                    h->height, 
h->avctx->coded_height,
 
 1133                    h->current_slice + 1);
 
 1144         h->avctx->pix_fmt = 
ret;
 
 1151                    "h264_slice_header_init() failed\n");
 
 1164     int interlaced_frame = 0, top_field_first = 0;
 
 1168     out->repeat_pict      = 0;
 
 1173     if (
h->sei.picture_timing.present) {
 
 1180             h->sei.picture_timing.present = 0;
 
 1184     if (
sps->pic_struct_present_flag && 
h->sei.picture_timing.present) {
 
 1186         switch (
pt->pic_struct) {
 
 1191             interlaced_frame = 1;
 
 1196                 interlaced_frame = 1;
 
 1199                 interlaced_frame = !!
h->prev_interlaced_frame;
 
 1206             out->repeat_pict = 1;
 
 1209             out->repeat_pict = 2;
 
 1212             out->repeat_pict = 4;
 
 1216         if ((
pt->ct_type & 3) &&
 
 1218             interlaced_frame = ((
pt->ct_type & (1 << 1)) != 0);
 
 1223     h->prev_interlaced_frame = interlaced_frame;
 
 1229         if (
sps->pic_struct_present_flag && 
h->sei.picture_timing.present) {
 
 1234                 top_field_first = 1;
 
 1235         } 
else if (interlaced_frame) {
 
 1238             top_field_first = 1;
 
 1247                                 &
sps->vui, 
sps->bit_depth_luma, 
sps->bit_depth_chroma,
 
 1248                                 cur->
poc + (
unsigned)(
h->poc_offset << 5));
 
 1252     if (
h->sei.picture_timing.timecode_cnt > 0) {
 
 1257                                      sizeof(uint32_t)*4, &tcside);
 
 1262             tc_sd = (uint32_t*)tcside->
data;
 
 1263             tc_sd[0] = 
h->sei.picture_timing.timecode_cnt;
 
 1265             for (
int i = 0; 
i < tc_sd[0]; 
i++) {
 
 1266                 int drop = 
h->sei.picture_timing.timecode[
i].dropframe;
 
 1267                 int   hh = 
h->sei.picture_timing.timecode[
i].hours;
 
 1268                 int   mm = 
h->sei.picture_timing.timecode[
i].minutes;
 
 1269                 int   ss = 
h->sei.picture_timing.timecode[
i].seconds;
 
 1270                 int   ff = 
h->sei.picture_timing.timecode[
i].frame;
 
 1277         h->sei.picture_timing.timecode_cnt = 0;
 
 1288     int i, pics, out_of_order, out_idx;
 
 1293     if (
sps->bitstream_restriction_flag ||
 
 1295         h->avctx->has_b_frames = 
FFMAX(
h->avctx->has_b_frames, 
sps->num_reorder_frames);
 
 1298     for (
i = 0; 1; 
i++) {
 
 1301                 h->last_pocs[
i-1] = cur->
poc;
 
 1304             h->last_pocs[
i-1]= 
h->last_pocs[
i];
 
 1310         out_of_order = 
FFMAX(out_of_order, 1);
 
 1314             h->last_pocs[
i] = INT_MIN;
 
 1315         h->last_pocs[0] = cur->
poc;
 
 1317     } 
else if(
h->avctx->has_b_frames < out_of_order && !
sps->bitstream_restriction_flag){
 
 1319         av_log(
h->avctx, loglevel, 
"Increasing reorder buffer to %d\n", out_of_order);
 
 1320         h->avctx->has_b_frames = out_of_order;
 
 1324     while (
h->delayed_pic[pics])
 
 1329     h->delayed_pic[pics++] = cur;
 
 1333     out     = 
h->delayed_pic[0];
 
 1335     for (
i = 1; 
h->delayed_pic[
i] &&
 
 1337                 !
h->delayed_pic[
i]->mmco_reset;
 
 1339         if (
h->delayed_pic[
i]->poc < 
out->poc) {
 
 1340             out     = 
h->delayed_pic[
i];
 
 1343     if (
h->avctx->has_b_frames == 0 &&
 
 1345         h->next_outputed_poc = INT_MIN;
 
 1346     out_of_order = 
out->poc < 
h->next_outputed_poc;
 
 1348     if (out_of_order || pics > 
h->avctx->has_b_frames) {
 
 1350         for (
i = out_idx; 
h->delayed_pic[
i]; 
i++)
 
 1351             h->delayed_pic[
i] = 
h->delayed_pic[
i + 1];
 
 1353     if (!out_of_order && pics > 
h->avctx->has_b_frames) {
 
 1354         h->next_output_pic = 
out;
 
 1355         if (out_idx == 0 && 
h->delayed_pic[0] && ((
h->delayed_pic[0]->f->flags & 
AV_FRAME_FLAG_KEY) || 
h->delayed_pic[0]->mmco_reset)) {
 
 1356             h->next_outputed_poc = INT_MIN;
 
 1358             h->next_outputed_poc = 
out->poc;
 
 1362         h->frame_recovered |= 
out->recovered;
 
 1366         if (!
out->recovered) {
 
 1369                 h->next_output_pic = 
NULL;
 
 1386                             const H2645NAL *nal, 
int first_slice)
 
 1391     int last_pic_structure, last_pic_droppable, 
ret;
 
 1399     if (
sps->bitstream_restriction_flag &&
 
 1400         h->avctx->has_b_frames < 
sps->num_reorder_frames) {
 
 1401         h->avctx->has_b_frames = 
sps->num_reorder_frames;
 
 1404     last_pic_droppable   = 
h->droppable;
 
 1405     last_pic_structure   = 
h->picture_structure;
 
 1406     h->droppable         = (nal->
ref_idc == 0);
 
 1417     else if (
h->picture_intra_only)
 
 1422     if (
h->poc.frame_num != 
h->poc.prev_frame_num) {
 
 1423         int unwrap_prev_frame_num = 
h->poc.prev_frame_num;
 
 1424         int max_frame_num         = 1 << 
sps->log2_max_frame_num;
 
 1426         if (unwrap_prev_frame_num > 
h->poc.frame_num)
 
 1427             unwrap_prev_frame_num -= max_frame_num;
 
 1429         if ((
h->poc.frame_num - unwrap_prev_frame_num) > 
sps->ref_frame_count) {
 
 1430             unwrap_prev_frame_num = (
h->poc.frame_num - 
sps->ref_frame_count) - 1;
 
 1431             if (unwrap_prev_frame_num < 0)
 
 1432                 unwrap_prev_frame_num += max_frame_num;
 
 1434             h->poc.prev_frame_num = unwrap_prev_frame_num;
 
 1443     if (
h->first_field) {
 
 1450         if (
h->cur_pic_ptr->tf.owner[last_field] == 
h->avctx) {
 
 1455         if (!
FIELD_PICTURE(
h) || 
h->picture_structure == last_pic_structure) {
 
 1463             if (
h->cur_pic_ptr->frame_num != 
h->poc.frame_num) {
 
 1479                            "Invalid field mode combination %d/%d\n",
 
 1480                            last_pic_structure, 
h->picture_structure);
 
 1481                     h->picture_structure = last_pic_structure;
 
 1482                     h->droppable         = last_pic_droppable;
 
 1484                 } 
else if (last_pic_droppable != 
h->droppable) {
 
 1486                                           "Found reference and non-reference fields in the same frame, which");
 
 1487                     h->picture_structure = last_pic_structure;
 
 1488                     h->droppable         = last_pic_droppable;
 
 1495     while (
h->poc.frame_num != 
h->poc.prev_frame_num && !
h->first_field &&
 
 1496            h->poc.frame_num != (
h->poc.prev_frame_num + 1) % (1 << 
sps->log2_max_frame_num)) {
 
 1499                h->poc.frame_num, 
h->poc.prev_frame_num);
 
 1500         if (!
sps->gaps_in_frame_num_allowed_flag)
 
 1502                 h->last_pocs[
i] = INT_MIN;
 
 1509         h->poc.prev_frame_num++;
 
 1510         h->poc.prev_frame_num        %= 1 << 
sps->log2_max_frame_num;
 
 1511         h->cur_pic_ptr->frame_num = 
h->poc.prev_frame_num;
 
 1512         h->cur_pic_ptr->invalid_gap = !
sps->gaps_in_frame_num_allowed_flag;
 
 1516         h->explicit_ref_marking = 0;
 
 1527         if (
h->short_ref_count) {
 
 1529                 1<<(
h->ps.sps->bit_depth_luma-1),
 
 1530                 1<<(
h->ps.sps->bit_depth_chroma-1),
 
 1531                 1<<(
h->ps.sps->bit_depth_chroma-1),
 
 1536                 h->short_ref[0]->f->width == prev->
f->
width &&
 
 1537                 h->short_ref[0]->f->height == prev->
f->
height &&
 
 1538                 h->short_ref[0]->f->format == prev->
f->
format) {
 
 1543                 h->short_ref[0]->tf.f = 
h->short_ref[0]->f;
 
 1547                 h->short_ref[0]->poc = prev->
poc + 2
U;
 
 1548                 h->short_ref[0]->gray = prev->
gray;
 
 1550                 if (
h->short_ref[0]->field_picture)
 
 1552             } 
else if (!
h->frame_recovered) {
 
 1553                 if (!
h->avctx->hwaccel)
 
 1555                 h->short_ref[0]->gray = 1;
 
 1557             h->short_ref[0]->frame_num = 
h->poc.prev_frame_num;
 
 1564     if (
h->first_field) {
 
 1570         if (!
FIELD_PICTURE(
h) || 
h->picture_structure == last_pic_structure) {
 
 1573             h->missing_fields ++;
 
 1574             h->cur_pic_ptr = 
NULL;
 
 1577             h->missing_fields = 0;
 
 1578             if (
h->cur_pic_ptr->frame_num != 
h->poc.frame_num) {
 
 1585                 h->cur_pic_ptr = 
NULL;
 
 1591                 h->cur_pic_ptr = 
NULL;
 
 1610         h->cur_pic_ptr->tf.owner[
field] = 
h->avctx;
 
 1616             memset(
h->slice_table + 
i*
h->mb_stride, -1, (
h->mb_stride - (
i+1==
h->mb_height)) * 
sizeof(*
h->slice_table));
 
 1618         memset(
h->slice_table, -1,
 
 1619             (
h->mb_height * 
h->mb_stride - 1) * 
sizeof(*
h->slice_table));
 
 1623                      h->ps.sps, &
h->poc, 
h->picture_structure, nal->
ref_idc);
 
 1633     if (
h->sei.recovery_point.recovery_frame_cnt >= 0) {
 
 1634         const int sei_recovery_frame_cnt = 
h->sei.recovery_point.recovery_frame_cnt;
 
 1637             h->valid_recovery_point = 1;
 
 1639         if (   
h->recovery_frame < 0
 
 1640             || 
av_mod_uintp2(
h->recovery_frame - 
h->poc.frame_num, 
h->ps.sps->log2_max_frame_num) > sei_recovery_frame_cnt) {
 
 1641             h->recovery_frame = 
av_mod_uintp2(
h->poc.frame_num + sei_recovery_frame_cnt, 
h->ps.sps->log2_max_frame_num);
 
 1643             if (!
h->valid_recovery_point)
 
 1644                 h->recovery_frame = 
h->poc.frame_num;
 
 1657     if (
h->recovery_frame == 
h->poc.frame_num && nal->
ref_idc) {
 
 1658         h->recovery_frame = -1;
 
 1663     h->cur_pic_ptr->recovered |= 
h->frame_recovered;
 
 1690     unsigned int slice_type, 
tmp, 
i;
 
 1691     int field_pic_flag, bottom_field_flag;
 
 1692     int first_slice = sl == 
h->slice_ctx && !
h->current_slice;
 
 1693     int picture_structure;
 
 1701     if (slice_type > 9) {
 
 1703                "slice type %d too large at %d\n",
 
 1707     if (slice_type > 4) {
 
 1728     if (!
h->ps.pps_list[sl->
pps_id]) {
 
 1730                "non-existing PPS %u referenced\n",
 
 1748     if (
sps->frame_mbs_only_flag) {
 
 1752             av_log(
h->avctx, 
AV_LOG_ERROR, 
"This stream was generated by a broken encoder, invalid 8x8 inference\n");
 
 1756         if (field_pic_flag) {
 
 1776         if (idr_pic_id < 65536) {
 
 1784     if (
sps->poc_type == 0) {
 
 1787         if (
pps->pic_order_present == 1 && picture_structure == 
PICT_FRAME)
 
 1792     if (
sps->poc_type == 1 && !
sps->delta_pic_order_always_zero_flag) {
 
 1795         if (
pps->pic_order_present == 1 && picture_structure == 
PICT_FRAME)
 
 1800     if (
pps->redundant_pic_cnt_present)
 
 1808                                   picture_structure, 
h->avctx);
 
 1821     for (
i = 0; 
i < 2; 
i++) {
 
 1826         (
pps->weighted_bipred_idc == 1 &&
 
 1830                                   picture_structure, 
h->avctx);
 
 1853     if (
tmp > 51 + 6 * (
sps->bit_depth_luma - 8)) {
 
 1870     if (
pps->deblocking_filter_parameters_present) {
 
 1874                    "deblocking_filter_idc %u out of range\n", 
tmp);
 
 1884             if (slice_alpha_c0_offset_div2 >  6 ||
 
 1885                 slice_alpha_c0_offset_div2 < -6 ||
 
 1886                 slice_beta_offset_div2 >  6     ||
 
 1887                 slice_beta_offset_div2 < -6) {
 
 1889                        "deblocking filter parameters %d %d out of range\n",
 
 1890                        slice_alpha_c0_offset_div2, slice_beta_offset_div2);
 
 1930     if (
h->ps.pps->weighted_bipred_idc == 2 &&
 
 1941     if (!
h->setup_finished)
 
 1961             h->postpone_filter = 1;
 
 1967                           h->ps.pps->chroma_qp_index_offset[0],
 
 1968                           h->ps.pps->chroma_qp_index_offset[1]) +
 
 1969                    6 * (
h->ps.sps->bit_depth_luma - 8);
 
 1982     for (j = 0; j < 2; j++) {
 
 1985         for (
i = 0; 
i < 16; 
i++) {
 
 1987             if (j < sl->list_count && i < sl->ref_count[j] &&
 
 1991                 for (k = 0; k < 
h->short_ref_count; k++)
 
 1992                     if (
h->short_ref[k]->f->buf[0]->buffer == buf) {
 
 1996                 for (k = 0; k < 
h->long_ref_count; k++)
 
 1997                     if (
h->long_ref[k] && 
h->long_ref[k]->f->buf[0]->buffer == buf) {
 
 1998                         id_list[
i] = 
h->short_ref_count + k;
 
 2006         for (
i = 0; 
i < 16; 
i++)
 
 2009         ref2frm[18 + 1] = -1;
 
 2010         for (
i = 16; 
i < 48; 
i++)
 
 2011             ref2frm[
i + 4] = 4 * id_list[(
i - 16) >> 1] +
 
 2016         h->cur_pic_ptr->gray = 0;
 
 2025         h->cur_pic_ptr->gray = 
gray;
 
 2030                "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",
 
 2038                h->cur_pic_ptr->field_poc[0],
 
 2039                h->cur_pic_ptr->field_poc[1],
 
 2055     int first_slice = sl == 
h->slice_ctx && !
h->current_slice;
 
 2071         if (
h->setup_finished) {
 
 2078         if (
h->current_slice) {
 
 2081             if (
h->nb_slice_ctx_queued) {
 
 2088                 memcpy(&tmp_ctx, 
h->slice_ctx, 
sizeof(tmp_ctx));
 
 2089                 memcpy(
h->slice_ctx, sl, 
sizeof(tmp_ctx));
 
 2090                 memcpy(sl, &tmp_ctx, 
sizeof(tmp_ctx));
 
 2103                 h->cur_pic_ptr = 
NULL;
 
 2110         if (!
h->first_field) {
 
 2111             if (
h->cur_pic_ptr && !
h->droppable) {
 
 2115             h->cur_pic_ptr = 
NULL;
 
 2119     if (!
h->current_slice)
 
 2122     if (
h->current_slice == 0 && !
h->first_field) {
 
 2136         if (
h->ps.pps->sps_id != 
pps->sps_id ||
 
 2137             h->ps.pps->transform_8x8_mode != 
pps->transform_8x8_mode 
 
 2142         if (
h->ps.sps != 
pps->sps) {
 
 2144                "SPS changed in the middle of the frame\n");
 
 2149     if (
h->current_slice == 0) {
 
 2155             h->droppable         != (nal->
ref_idc == 0)) {
 
 2157                    "Changing field mode (%d -> %d) between slices is not allowed\n",
 
 2160         } 
else if (!
h->cur_pic_ptr) {
 
 2162                    "unset cur_pic_ptr on slice %d\n",
 
 2163                    h->current_slice + 1);
 
 2172     h->nb_slice_ctx_queued++;
 
 2197                                                       int mb_type, 
int top_xy,
 
 2201                                                       int mb_xy, 
int list)
 
 2203     int b_stride = 
h->b_stride;
 
 2208             const int b_xy  = 
h->mb2b_xy[top_xy] + 3 * b_stride;
 
 2209             const int b8_xy = 4 * top_xy + 2;
 
 2212             ref_cache[0 - 1 * 8] =
 
 2213             ref_cache[1 - 1 * 8] = ref2frm[
h->cur_pic.ref_index[
list][b8_xy + 0]];
 
 2214             ref_cache[2 - 1 * 8] =
 
 2215             ref_cache[3 - 1 * 8] = ref2frm[
h->cur_pic.ref_index[
list][b8_xy + 1]];
 
 2223                 const int b_xy  = 
h->mb2b_xy[left_xy[
LTOP]] + 3;
 
 2224                 const int b8_xy = 4 * left_xy[
LTOP] + 1;
 
 2226                 AV_COPY32(mv_dst - 1 +  0, 
h->cur_pic.motion_val[
list][b_xy + b_stride * 0]);
 
 2227                 AV_COPY32(mv_dst - 1 +  8, 
h->cur_pic.motion_val[
list][b_xy + b_stride * 1]);
 
 2228                 AV_COPY32(mv_dst - 1 + 16, 
h->cur_pic.motion_val[
list][b_xy + b_stride * 2]);
 
 2229                 AV_COPY32(mv_dst - 1 + 24, 
h->cur_pic.motion_val[
list][b_xy + b_stride * 3]);
 
 2231                 ref_cache[-1 +  8] = ref2frm[
h->cur_pic.ref_index[
list][b8_xy + 2 * 0]];
 
 2232                 ref_cache[-1 + 16] =
 
 2233                 ref_cache[-1 + 24] = ref2frm[
h->cur_pic.ref_index[
list][b8_xy + 2 * 1]];
 
 2241                 ref_cache[-1 + 16] =
 
 2257         const int8_t *
ref = &
h->cur_pic.ref_index[
list][4 * mb_xy];
 
 2259         uint32_t ref01 = (
pack16to32(ref2frm[
ref[0]], ref2frm[
ref[1]]) & 0x00FF00FF) * 0x0101;
 
 2260         uint32_t ref23 = (
pack16to32(ref2frm[
ref[2]], ref2frm[
ref[3]]) & 0x00FF00FF) * 0x0101;
 
 2261         AV_WN32A(&ref_cache[0 * 8], ref01);
 
 2262         AV_WN32A(&ref_cache[1 * 8], ref01);
 
 2263         AV_WN32A(&ref_cache[2 * 8], ref23);
 
 2264         AV_WN32A(&ref_cache[3 * 8], ref23);
 
 2268         int16_t(*mv_src)[2] = &
h->cur_pic.motion_val[
list][4 * sl->
mb_x + 4 * sl->
mb_y * b_stride];
 
 2269         AV_COPY128(mv_dst + 8 * 0, mv_src + 0 * b_stride);
 
 2270         AV_COPY128(mv_dst + 8 * 1, mv_src + 1 * b_stride);
 
 2271         AV_COPY128(mv_dst + 8 * 2, mv_src + 2 * b_stride);
 
 2272         AV_COPY128(mv_dst + 8 * 3, mv_src + 3 * b_stride);
 
 2281     const int mb_xy = sl->
mb_xy;
 
 2287     top_xy = mb_xy - (
h->mb_stride << 
MB_FIELD(sl));
 
 2289     left_xy[
LBOT] = left_xy[
LTOP] = mb_xy - 1;
 
 2291         const int left_mb_field_flag = 
IS_INTERLACED(
h->cur_pic.mb_type[mb_xy - 1]);
 
 2294             if (left_mb_field_flag != curr_mb_field_flag)
 
 2295                 left_xy[
LTOP] -= 
h->mb_stride;
 
 2297             if (curr_mb_field_flag)
 
 2298                 top_xy += 
h->mb_stride &
 
 2299                           (((
h->cur_pic.mb_type[top_xy] >> 7) & 1) - 1);
 
 2300             if (left_mb_field_flag != curr_mb_field_flag)
 
 2301                 left_xy[
LBOT] += 
h->mb_stride;
 
 2313         int qp        = 
h->cur_pic.qscale_table[mb_xy];
 
 2314         if (qp <= qp_thresh &&
 
 2315             (left_xy[
LTOP] < 0 ||
 
 2316              ((qp + 
h->cur_pic.qscale_table[left_xy[
LTOP]] + 1) >> 1) <= qp_thresh) &&
 
 2318              ((qp + 
h->cur_pic.qscale_table[top_xy] + 1) >> 1) <= qp_thresh)) {
 
 2321             if ((left_xy[
LTOP] < 0 ||
 
 2322                  ((qp + 
h->cur_pic.qscale_table[left_xy[
LBOT]] + 1) >> 1) <= qp_thresh) &&
 
 2323                 (top_xy < 
h->mb_stride ||
 
 2324                  ((qp + 
h->cur_pic.qscale_table[top_xy - 
h->mb_stride] + 1) >> 1) <= qp_thresh))
 
 2329     top_type        = 
h->cur_pic.mb_type[top_xy];
 
 2330     left_type[
LTOP] = 
h->cur_pic.mb_type[left_xy[
LTOP]];
 
 2331     left_type[
LBOT] = 
h->cur_pic.mb_type[left_xy[
LBOT]];
 
 2336             left_type[
LTOP] = left_type[
LBOT] = 0;
 
 2338         if (
h->slice_table[top_xy] == 0xFFFF)
 
 2340         if (
h->slice_table[left_xy[
LBOT]] == 0xFFFF)
 
 2341             left_type[
LTOP] = left_type[
LBOT] = 0;
 
 2351                              top_type, left_type, mb_xy, 0);
 
 2354                                  top_type, left_type, mb_xy, 1);
 
 2356     nnz       = 
h->non_zero_count[mb_xy];
 
 2358     AV_COPY32(&nnz_cache[4 + 8 * 1], &nnz[0]);
 
 2359     AV_COPY32(&nnz_cache[4 + 8 * 2], &nnz[4]);
 
 2360     AV_COPY32(&nnz_cache[4 + 8 * 3], &nnz[8]);
 
 2361     AV_COPY32(&nnz_cache[4 + 8 * 4], &nnz[12]);
 
 2362     sl->
cbp = 
h->cbp_table[mb_xy];
 
 2365         nnz = 
h->non_zero_count[top_xy];
 
 2366         AV_COPY32(&nnz_cache[4 + 8 * 0], &nnz[3 * 4]);
 
 2369     if (left_type[
LTOP]) {
 
 2370         nnz = 
h->non_zero_count[left_xy[
LTOP]];
 
 2371         nnz_cache[3 + 8 * 1] = nnz[3 + 0 * 4];
 
 2372         nnz_cache[3 + 8 * 2] = nnz[3 + 1 * 4];
 
 2373         nnz_cache[3 + 8 * 3] = nnz[3 + 2 * 4];
 
 2374         nnz_cache[3 + 8 * 4] = nnz[3 + 3 * 4];
 
 2379     if (!
CABAC(
h) && 
h->ps.pps->transform_8x8_mode) {
 
 2381             nnz_cache[4 + 8 * 0] =
 
 2382             nnz_cache[5 + 8 * 0] = (
h->cbp_table[top_xy] & 0x4000) >> 12;
 
 2383             nnz_cache[6 + 8 * 0] =
 
 2384             nnz_cache[7 + 8 * 0] = (
h->cbp_table[top_xy] & 0x8000) >> 12;
 
 2387             nnz_cache[3 + 8 * 1] =
 
 2388             nnz_cache[3 + 8 * 2] = (
h->cbp_table[left_xy[
LTOP]] & 0x2000) >> 12; 
 
 2391             nnz_cache[3 + 8 * 3] =
 
 2392             nnz_cache[3 + 8 * 4] = (
h->cbp_table[left_xy[
LBOT]] & 0x8000) >> 12; 
 
 2396             nnz_cache[
scan8[0]] =
 
 2397             nnz_cache[
scan8[1]] =
 
 2398             nnz_cache[
scan8[2]] =
 
 2399             nnz_cache[
scan8[3]] = (sl->
cbp & 0x1000) >> 12;
 
 2401             nnz_cache[
scan8[0 + 4]] =
 
 2402             nnz_cache[
scan8[1 + 4]] =
 
 2403             nnz_cache[
scan8[2 + 4]] =
 
 2404             nnz_cache[
scan8[3 + 4]] = (sl->
cbp & 0x2000) >> 12;
 
 2406             nnz_cache[
scan8[0 + 8]] =
 
 2407             nnz_cache[
scan8[1 + 8]] =
 
 2408             nnz_cache[
scan8[2 + 8]] =
 
 2409             nnz_cache[
scan8[3 + 8]] = (sl->
cbp & 0x4000) >> 12;
 
 2411             nnz_cache[
scan8[0 + 12]] =
 
 2412             nnz_cache[
scan8[1 + 12]] =
 
 2413             nnz_cache[
scan8[2 + 12]] =
 
 2414             nnz_cache[
scan8[3 + 12]] = (sl->
cbp & 0x8000) >> 12;
 
 2423     uint8_t *dest_y, *dest_cb, *dest_cr;
 
 2424     int linesize, uvlinesize, mb_x, mb_y;
 
 2427     const int pixel_shift    = 
h->pixel_shift;
 
 2428     const int block_h        = 16 >> 
h->chroma_y_shift;
 
 2430     if (
h->postpone_filter)
 
 2434         for (mb_x = start_x; mb_x < end_x; mb_x++)
 
 2435             for (mb_y = end_mb_y - 
FRAME_MBAFF(
h); mb_y <= end_mb_y; mb_y++) {
 
 2437                 mb_xy         = sl->
mb_xy = mb_x + mb_y * 
h->mb_stride;
 
 2438                 mb_type       = 
h->cur_pic.mb_type[mb_xy];
 
 2446                 dest_y  = 
h->cur_pic.f->data[0] +
 
 2447                           ((mb_x << pixel_shift) + mb_y * sl->
linesize) * 16;
 
 2448                 dest_cb = 
h->cur_pic.f->data[1] +
 
 2449                           (mb_x << pixel_shift) * (8 << 
CHROMA444(
h)) +
 
 2451                 dest_cr = 
h->cur_pic.f->data[2] +
 
 2452                           (mb_x << pixel_shift) * (8 << 
CHROMA444(
h)) +
 
 2477                                       linesize, uvlinesize);
 
 2480                                            dest_cr, linesize, uvlinesize);
 
 2493     const int mb_xy = sl->
mb_x + sl->
mb_y * 
h->mb_stride;
 
 2494     int mb_type     = (
h->slice_table[mb_xy - 1] == sl->
slice_num) ?
 
 2495                       h->cur_pic.mb_type[mb_xy - 1] :
 
 2496                       (
h->slice_table[mb_xy - 
h->mb_stride] == sl->
slice_num) ?
 
 2497                       h->cur_pic.mb_type[mb_xy - 
h->mb_stride] : 0;
 
 2512         if ((top + 
height) >= pic_height)
 
 2513             height += deblock_border;
 
 2514         top -= deblock_border;
 
 2517     if (top >= pic_height || (top + 
height) < 0)
 
 2528     if (
h->droppable || 
h->er.error_occurred)
 
 2536                          int startx, 
int starty,
 
 2537                          int endx, 
int endy, 
int status)
 
 2542     if (CONFIG_ERROR_RESILIENCE) {
 
 2551     int lf_x_start = sl->
mb_x;
 
 2555     sl->
linesize   = 
h->cur_pic_ptr->f->linesize[0];
 
 2566     if (
h->postpone_filter)
 
 2582     if (
h->ps.pps->cabac) {
 
 2626                 if (sl->
mb_x >= lf_x_start)
 
 2642             if (++sl->
mb_x >= 
h->mb_width) {
 
 2644                 sl->
mb_x = lf_x_start = 0;
 
 2654             if (eos || sl->
mb_y >= 
h->mb_height) {
 
 2655                 ff_tlog(
h->avctx, 
"slice end %d %d\n",
 
 2659                 if (sl->
mb_x > lf_x_start)
 
 2693                        "error while decoding MB %d %d\n", sl->
mb_x, sl->
mb_y);
 
 2699             if (++sl->
mb_x >= 
h->mb_width) {
 
 2701                 sl->
mb_x = lf_x_start = 0;
 
 2709                 if (sl->
mb_y >= 
h->mb_height) {
 
 2710                     ff_tlog(
h->avctx, 
"slice end %d %d\n",
 
 2729                 ff_tlog(
h->avctx, 
"slice end %d %d\n",
 
 2735                     if (sl->
mb_x > lf_x_start)
 
 2763     int context_count = 
h->nb_slice_ctx_queued;
 
 2767     h->slice_ctx[0].next_slice_idx = INT_MAX;
 
 2769     if (
h->avctx->hwaccel || context_count < 1)
 
 2772     av_assert0(context_count && 
h->slice_ctx[context_count - 1].mb_y < 
h->mb_height);
 
 2774     if (context_count == 1) {
 
 2776         h->slice_ctx[0].next_slice_idx = 
h->mb_width * 
h->mb_height;
 
 2777         h->postpone_filter = 0;
 
 2780         h->mb_y = 
h->slice_ctx[0].mb_y;
 
 2785         for (
i = 0; 
i < context_count; 
i++) {
 
 2786             int next_slice_idx = 
h->mb_width * 
h->mb_height;
 
 2789             sl                 = &
h->slice_ctx[
i];
 
 2792             slice_idx = sl->
mb_y * 
h->mb_width + sl->
mb_x;
 
 2793             for (j = 0; j < context_count; j++) {
 
 2795                 int        slice_idx2 = sl2->
mb_y * 
h->mb_width + sl2->
mb_x;
 
 2797                 if (
i == j || slice_idx2 < slice_idx)
 
 2799                 next_slice_idx = 
FFMIN(next_slice_idx, slice_idx2);
 
 2805                        NULL, context_count, 
sizeof(
h->slice_ctx[0]));
 
 2808         sl                   = &
h->slice_ctx[context_count - 1];
 
 2811         if (
h->postpone_filter) {
 
 2812             h->postpone_filter = 0;
 
 2814             for (
i = 0; 
i < context_count; 
i++) {
 
 2817                 sl = &
h->slice_ctx[
i];
 
 2819                 x_end = (sl->
mb_y >= 
h->mb_height) ? 
h->mb_width : sl->
mb_x;
 
 2824                                 j == y_end - 1 ? x_end : 
h->mb_width);
 
 2831     h->nb_slice_ctx_queued = 0;