]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/h264_refs.c
Merge commit '7ebfb466aec2c4628fcd42a72b29034efcaba4bc'
[ffmpeg] / libavcodec / h264_refs.c
index 8df4c3a7f017c7761cbec4ff55b4ab972b59a6bf..5736e15b1ff6da7a06f0d0398111d020333c6b8c 100644 (file)
@@ -107,7 +107,6 @@ static int add_sorted(Picture **sorted, Picture **src, int len, int limit, int d
 }
 
 int ff_h264_fill_default_ref_list(H264Context *h){
-    MpegEncContext * const s = &h->s;
     int i, len;
 
     if(h->slice_type_nos==AV_PICTURE_TYPE_B){
@@ -116,16 +115,16 @@ int ff_h264_fill_default_ref_list(H264Context *h){
         int lens[2];
 
         if(FIELD_PICTURE)
-            cur_poc= s->current_picture_ptr->field_poc[ s->picture_structure == PICT_BOTTOM_FIELD ];
+            cur_poc= h->cur_pic_ptr->field_poc[h->picture_structure == PICT_BOTTOM_FIELD];
         else
-            cur_poc= s->current_picture_ptr->poc;
+            cur_poc= h->cur_pic_ptr->poc;
 
         for(list= 0; list<2; list++){
             len= add_sorted(sorted    , h->short_ref, h->short_ref_count, cur_poc, 1^list);
             len+=add_sorted(sorted+len, h->short_ref, h->short_ref_count, cur_poc, 0^list);
             av_assert0(len<=32);
-            len= build_def_list(h->default_ref_list[list]    , sorted     , len, 0, s->picture_structure);
-            len+=build_def_list(h->default_ref_list[list]+len, h->long_ref, 16 , 1, s->picture_structure);
+            len= build_def_list(h->default_ref_list[list]    , sorted     , len, 0, h->picture_structure);
+            len+=build_def_list(h->default_ref_list[list]+len, h->long_ref, 16 , 1, h->picture_structure);
             av_assert0(len<=32);
 
             if(len < h->ref_count[list])
@@ -139,19 +138,19 @@ int ff_h264_fill_default_ref_list(H264Context *h){
                 FFSWAP(Picture, h->default_ref_list[1][0], h->default_ref_list[1][1]);
         }
     }else{
-        len = build_def_list(h->default_ref_list[0]    , h->short_ref, h->short_ref_count, 0, s->picture_structure);
-        len+= build_def_list(h->default_ref_list[0]+len, h-> long_ref, 16                , 1, s->picture_structure);
+        len = build_def_list(h->default_ref_list[0]    , h->short_ref, h->short_ref_count, 0, h->picture_structure);
+        len+= build_def_list(h->default_ref_list[0]+len, h-> long_ref, 16                , 1, h->picture_structure);
         av_assert0(len<=32);
         if(len < h->ref_count[0])
             memset(&h->default_ref_list[0][len], 0, sizeof(Picture)*(h->ref_count[0] - len));
     }
 #ifdef TRACE
     for (i=0; i<h->ref_count[0]; i++) {
-        tprintf(h->s.avctx, "List0: %s fn:%d 0x%p\n", (h->default_ref_list[0][i].long_ref ? "LT" : "ST"), h->default_ref_list[0][i].pic_id, h->default_ref_list[0][i].f.data[0]);
+        tprintf(h->avctx, "List0: %s fn:%d 0x%p\n", (h->default_ref_list[0][i].long_ref ? "LT" : "ST"), h->default_ref_list[0][i].pic_id, h->default_ref_list[0][i].f.data[0]);
     }
     if(h->slice_type_nos==AV_PICTURE_TYPE_B){
         for (i=0; i<h->ref_count[1]; i++) {
-            tprintf(h->s.avctx, "List1: %s fn:%d 0x%p\n", (h->default_ref_list[1][i].long_ref ? "LT" : "ST"), h->default_ref_list[1][i].pic_id, h->default_ref_list[1][i].f.data[0]);
+            tprintf(h->avctx, "List1: %s fn:%d 0x%p\n", (h->default_ref_list[1][i].long_ref ? "LT" : "ST"), h->default_ref_list[1][i].pic_id, h->default_ref_list[1][i].f.data[0]);
         }
     }
 #endif
@@ -172,9 +171,7 @@ static void print_long_term(H264Context *h);
  *         described by pic_num
  */
 static int pic_num_extract(H264Context *h, int pic_num, int *structure){
-    MpegEncContext * const s = &h->s;
-
-    *structure = s->picture_structure;
+    *structure = h->picture_structure;
     if(FIELD_PICTURE){
         if (!(pic_num & 1))
             /* opposite field */
@@ -186,7 +183,6 @@ static int pic_num_extract(H264Context *h, int pic_num, int *structure){
 }
 
 int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
-    MpegEncContext * const s = &h->s;
     int list, index, pic_structure;
 
     print_short_term(h);
@@ -195,11 +191,11 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
     for(list=0; list<h->list_count; list++){
         memcpy(h->ref_list[list], h->default_ref_list[list], sizeof(Picture)*h->ref_count[list]);
 
-        if(get_bits1(&s->gb)){
+        if(get_bits1(&h->gb)){
             int pred= h->curr_pic_num;
 
             for(index=0; ; index++){
-                unsigned int reordering_of_pic_nums_idc= get_ue_golomb_31(&s->gb);
+                unsigned int reordering_of_pic_nums_idc= get_ue_golomb_31(&h->gb);
                 unsigned int pic_id;
                 int i;
                 Picture *ref = NULL;
@@ -208,17 +204,17 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
                     break;
 
                 if(index >= h->ref_count[list]){
-                    av_log(h->s.avctx, AV_LOG_ERROR, "reference count overflow\n");
+                    av_log(h->avctx, AV_LOG_ERROR, "reference count overflow\n");
                     return -1;
                 }
 
                 if(reordering_of_pic_nums_idc<3){
                     if(reordering_of_pic_nums_idc<2){
-                        const unsigned int abs_diff_pic_num= get_ue_golomb(&s->gb) + 1;
+                        const unsigned int abs_diff_pic_num= get_ue_golomb(&h->gb) + 1;
                         int frame_num;
 
                         if(abs_diff_pic_num > h->max_pic_num){
-                            av_log(h->s.avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n");
+                            av_log(h->avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n");
                             return -1;
                         }
 
@@ -242,12 +238,12 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
                             ref->pic_id= pred;
                     }else{
                         int long_idx;
-                        pic_id= get_ue_golomb(&s->gb); //long_term_pic_idx
+                        pic_id= get_ue_golomb(&h->gb); //long_term_pic_idx
 
                         long_idx= pic_num_extract(h, pic_id, &pic_structure);
 
                         if(long_idx>31){
-                            av_log(h->s.avctx, AV_LOG_ERROR, "long_term_pic_idx overflow\n");
+                            av_log(h->avctx, AV_LOG_ERROR, "long_term_pic_idx overflow\n");
                             return -1;
                         }
                         ref = h->long_ref[long_idx];
@@ -262,7 +258,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
                     }
 
                     if (i < 0) {
-                        av_log(h->s.avctx, AV_LOG_ERROR, "reference picture missing during reorder\n");
+                        av_log(h->avctx, AV_LOG_ERROR, "reference picture missing during reorder\n");
                         memset(&h->ref_list[list][index], 0, sizeof(Picture)); //FIXME
                     } else {
                         for(i=index; i+1<h->ref_count[list]; i++){
@@ -278,7 +274,7 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
                         }
                     }
                 }else{
-                    av_log(h->s.avctx, AV_LOG_ERROR, "illegal reordering_of_pic_nums_idc\n");
+                    av_log(h->avctx, AV_LOG_ERROR, "illegal reordering_of_pic_nums_idc\n");
                     return -1;
                 }
             }
@@ -287,7 +283,10 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h){
     for(list=0; list<h->list_count; list++){
         for(index= 0; index < h->ref_count[list]; index++){
             if (!h->ref_list[list][index].f.data[0]) {
-                av_log(h->s.avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref_list[list][0].poc);
+                int i;
+                av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref_list[list][0].poc);
+                for (i=0; i<FF_ARRAY_ELEMS(h->last_pocs); i++)
+                    h->last_pocs[i] = INT_MIN;
                 if (h->default_ref_list[list][0].f.data[0])
                     h->ref_list[list][index]= h->default_ref_list[list][0];
                 else
@@ -360,13 +359,12 @@ static inline int unreference_pic(H264Context *h, Picture *pic, int refmask){
  *                 frame number is found
  */
 static Picture * find_short(H264Context *h, int frame_num, int *idx){
-    MpegEncContext * const s = &h->s;
     int i;
 
     for(i=0; i<h->short_ref_count; i++){
         Picture *pic= h->short_ref[i];
-        if(s->avctx->debug&FF_DEBUG_MMCO)
-            av_log(h->s.avctx, AV_LOG_DEBUG, "%d %d %p\n", i, pic->frame_num, pic);
+        if(h->avctx->debug&FF_DEBUG_MMCO)
+            av_log(h->avctx, AV_LOG_DEBUG, "%d %d %p\n", i, pic->frame_num, pic);
         if(pic->frame_num == frame_num) {
             *idx = i;
             return pic;
@@ -393,12 +391,11 @@ static void remove_short_at_index(H264Context *h, int i){
  * @return the removed picture or NULL if an error occurs
  */
 static Picture * remove_short(H264Context *h, int frame_num, int ref_mask){
-    MpegEncContext * const s = &h->s;
     Picture *pic;
     int i;
 
-    if(s->avctx->debug&FF_DEBUG_MMCO)
-        av_log(h->s.avctx, AV_LOG_DEBUG, "remove short %d count %d\n", frame_num, h->short_ref_count);
+    if(h->avctx->debug&FF_DEBUG_MMCO)
+        av_log(h->avctx, AV_LOG_DEBUG, "remove short %d count %d\n", frame_num, h->short_ref_count);
 
     pic = find_short(h, frame_num, &i);
     if (pic){
@@ -453,11 +450,11 @@ void ff_h264_remove_all_refs(H264Context *h){
  */
 static void print_short_term(H264Context *h) {
     uint32_t i;
-    if(h->s.avctx->debug&FF_DEBUG_MMCO) {
-        av_log(h->s.avctx, AV_LOG_DEBUG, "short term list:\n");
+    if(h->avctx->debug&FF_DEBUG_MMCO) {
+        av_log(h->avctx, AV_LOG_DEBUG, "short term list:\n");
         for(i=0; i<h->short_ref_count; i++){
             Picture *pic= h->short_ref[i];
-            av_log(h->s.avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n",
+            av_log(h->avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n",
                    i, pic->frame_num, pic->poc, pic->f.data[0]);
         }
     }
@@ -468,12 +465,12 @@ static void print_short_term(H264Context *h) {
  */
 static void print_long_term(H264Context *h) {
     uint32_t i;
-    if(h->s.avctx->debug&FF_DEBUG_MMCO) {
-        av_log(h->s.avctx, AV_LOG_DEBUG, "long term list:\n");
+    if(h->avctx->debug&FF_DEBUG_MMCO) {
+        av_log(h->avctx, AV_LOG_DEBUG, "long term list:\n");
         for(i = 0; i < 16; i++){
             Picture *pic= h->long_ref[i];
             if (pic) {
-                av_log(h->s.avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n",
+                av_log(h->avctx, AV_LOG_DEBUG, "%d fn:%d poc:%d %p\n",
                        i, pic->frame_num, pic->poc, pic->f.data[0]);
             }
         }
@@ -497,14 +494,12 @@ static int check_opcodes(MMCO *mmco1, MMCO *mmco2, int n_mmcos)
 
 int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
 {
-    MpegEncContext * const s = &h->s;
     MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp;
     int mmco_index = 0, i;
 
     if (h->short_ref_count &&
         h->long_ref_count + h->short_ref_count >= h->sps.ref_frame_count &&
-        !(FIELD_PICTURE && !s->first_field &&
-          s->current_picture_ptr->f.reference)) {
+        !(FIELD_PICTURE && !h->first_field && h->cur_pic_ptr->f.reference)) {
         mmco[0].opcode = MMCO_SHORT2UNUSED;
         mmco[0].short_pic_num = h->short_ref[h->short_ref_count - 1]->frame_num;
         mmco_index = 1;
@@ -521,7 +516,7 @@ int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
     } else if (!first_slice && mmco_index >= 0 &&
                (mmco_index != h->mmco_index ||
                 (i = check_opcodes(h->mmco, mmco_temp, mmco_index)))) {
-        av_log(h->s.avctx, AV_LOG_ERROR,
+        av_log(h->avctx, AV_LOG_ERROR,
                "Inconsistent MMCO state between slices [%d, %d]\n",
                mmco_index, h->mmco_index);
         return AVERROR_INVALIDDATA;
@@ -530,18 +525,17 @@ int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
 }
 
 int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
-    MpegEncContext * const s = &h->s;
     int i, av_uninit(j);
     int current_ref_assigned=0, err=0;
     Picture *av_uninit(pic);
 
-    if((s->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0)
-        av_log(h->s.avctx, AV_LOG_DEBUG, "no mmco here\n");
+    if((h->avctx->debug&FF_DEBUG_MMCO) && mmco_count==0)
+        av_log(h->avctx, AV_LOG_DEBUG, "no mmco here\n");
 
     for(i=0; i<mmco_count; i++){
         int av_uninit(structure), av_uninit(frame_num);
-        if(s->avctx->debug&FF_DEBUG_MMCO)
-            av_log(h->s.avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_pic_num, h->mmco[i].long_arg);
+        if(h->avctx->debug&FF_DEBUG_MMCO)
+            av_log(h->avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode, h->mmco[i].short_pic_num, h->mmco[i].long_arg);
 
         if(   mmco[i].opcode == MMCO_SHORT2UNUSED
            || mmco[i].opcode == MMCO_SHORT2LONG){
@@ -550,7 +544,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
             if(!pic){
                 if(mmco[i].opcode != MMCO_SHORT2LONG || !h->long_ref[mmco[i].long_arg]
                    || h->long_ref[mmco[i].long_arg]->frame_num != frame_num) {
-                    av_log(h->s.avctx, AV_LOG_ERROR, "mmco: unref short failure\n");
+                    av_log(h->avctx, AV_LOG_ERROR, "mmco: unref short failure\n");
                     err = AVERROR_INVALIDDATA;
                 }
                 continue;
@@ -559,8 +553,8 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
 
         switch(mmco[i].opcode){
         case MMCO_SHORT2UNUSED:
-            if(s->avctx->debug&FF_DEBUG_MMCO)
-                av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n", h->mmco[i].short_pic_num, h->short_ref_count);
+            if(h->avctx->debug&FF_DEBUG_MMCO)
+                av_log(h->avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n", h->mmco[i].short_pic_num, h->short_ref_count);
             remove_short(h, frame_num, structure ^ PICT_FRAME);
             break;
         case MMCO_SHORT2LONG:
@@ -579,8 +573,8 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
             pic = h->long_ref[j];
             if (pic) {
                 remove_long(h, j, structure ^ PICT_FRAME);
-            } else if(s->avctx->debug&FF_DEBUG_MMCO)
-                av_log(h->s.avctx, AV_LOG_DEBUG, "mmco: unref long failure\n");
+            } else if(h->avctx->debug&FF_DEBUG_MMCO)
+                av_log(h->avctx, AV_LOG_DEBUG, "mmco: unref long failure\n");
             break;
         case MMCO_LONG:
                     // Comment below left from previous code as it is an interresting note.
@@ -591,15 +585,15 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
                      * and mark this field valid.
                      */
 
-            if (h->long_ref[mmco[i].long_arg] != s->current_picture_ptr) {
+            if (h->long_ref[mmco[i].long_arg] != h->cur_pic_ptr) {
                 remove_long(h, mmco[i].long_arg, 0);
 
-                h->long_ref[ mmco[i].long_arg ]= s->current_picture_ptr;
+                h->long_ref[ mmco[i].long_arg ]= h->cur_pic_ptr;
                 h->long_ref[ mmco[i].long_arg ]->long_ref=1;
                 h->long_ref_count++;
             }
 
-            s->current_picture_ptr->f.reference |= s->picture_structure;
+            h->cur_pic_ptr->f.reference |= h->picture_structure;
             current_ref_assigned=1;
             break;
         case MMCO_SET_MAX_LONG:
@@ -617,9 +611,9 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
                 remove_long(h, j, 0);
             }
             h->frame_num=
-            s->current_picture_ptr->frame_num= 0;
+            h->cur_pic_ptr->frame_num= 0;
             h->mmco_reset = 1;
-            s->current_picture_ptr->mmco_reset=1;
+            h->cur_pic_ptr->mmco_reset=1;
             for (j = 0; j < MAX_DELAYED_PIC_COUNT; j++)
                 h->last_pocs[j] = INT_MIN;
             break;
@@ -634,28 +628,28 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
          * in long_ref; trying to put it on the short list here is an
          * error in the encoded bit stream (ref: 7.4.3.3, NOTE 2 and 3).
          */
-        if (h->short_ref_count && h->short_ref[0] == s->current_picture_ptr) {
+        if (h->short_ref_count && h->short_ref[0] == h->cur_pic_ptr) {
             /* Just mark the second field valid */
-            s->current_picture_ptr->f.reference = PICT_FRAME;
-        } else if (s->current_picture_ptr->long_ref) {
-            av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term reference "
-                                             "assignment for second field "
-                                             "in complementary field pair "
-                                             "(first field is long term)\n");
+            h->cur_pic_ptr->f.reference = PICT_FRAME;
+        } else if (h->cur_pic_ptr->long_ref) {
+            av_log(h->avctx, AV_LOG_ERROR, "illegal short term reference "
+                                           "assignment for second field "
+                                           "in complementary field pair "
+                                           "(first field is long term)\n");
             err = AVERROR_INVALIDDATA;
         } else {
-            pic= remove_short(h, s->current_picture_ptr->frame_num, 0);
+            pic= remove_short(h, h->cur_pic_ptr->frame_num, 0);
             if(pic){
-                av_log(h->s.avctx, AV_LOG_ERROR, "illegal short term buffer state detected\n");
+                av_log(h->avctx, AV_LOG_ERROR, "illegal short term buffer state detected\n");
                 err = AVERROR_INVALIDDATA;
             }
 
             if(h->short_ref_count)
                 memmove(&h->short_ref[1], &h->short_ref[0], h->short_ref_count*sizeof(Picture*));
 
-            h->short_ref[0]= s->current_picture_ptr;
+            h->short_ref[0]= h->cur_pic_ptr;
             h->short_ref_count++;
-            s->current_picture_ptr->f.reference |= s->picture_structure;
+            h->cur_pic_ptr->f.reference |= h->picture_structure;
         }
     }
 
@@ -665,7 +659,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
          * stream. Need to discard one frame. Prevents overrun of the
          * short_ref and long_ref buffers.
          */
-        av_log(h->s.avctx, AV_LOG_ERROR,
+        av_log(h->avctx, AV_LOG_ERROR,
                "number of reference frames (%d+%d) exceeds max (%d; probably "
                "corrupt input), discarding one\n",
                h->long_ref_count, h->short_ref_count, h->sps.ref_frame_count);
@@ -687,25 +681,24 @@ int ff_h264_execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
     print_short_term(h);
     print_long_term(h);
 
-    if(err >= 0 && h->long_ref_count==0 && h->short_ref_count<=2 && h->pps.ref_count[0]<=1 + (s->picture_structure != PICT_FRAME) && s->current_picture_ptr->f.pict_type == AV_PICTURE_TYPE_I){
-        s->current_picture_ptr->sync |= 1;
-        if(!h->s.avctx->has_b_frames)
+    if(err >= 0 && h->long_ref_count==0 && h->short_ref_count<=2 && h->pps.ref_count[0]<=1 + (h->picture_structure != PICT_FRAME) && h->cur_pic_ptr->f.pict_type == AV_PICTURE_TYPE_I){
+        h->cur_pic_ptr->sync |= 1;
+        if(!h->avctx->has_b_frames)
             h->sync = 2;
     }
 
-    return (h->s.avctx->err_recognition & AV_EF_EXPLODE) ? err : 0;
+    return (h->avctx->err_recognition & AV_EF_EXPLODE) ? err : 0;
 }
 
 int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb,
                                    int first_slice)
 {
-    MpegEncContext * const s = &h->s;
     int i, ret;
     MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp;
     int mmco_index = 0;
 
     if (h->nal_unit_type == NAL_IDR_SLICE){ // FIXME fields
-        s->broken_link = get_bits1(gb) - 1;
+        skip_bits1(gb); // broken_link
         if (get_bits1(gb)){
             mmco[0].opcode = MMCO_LONG;
             mmco[0].long_arg = 0;
@@ -738,7 +731,7 @@ int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb,
                         (long_arg >= 16 && !(opcode == MMCO_SET_MAX_LONG &&
                                              long_arg == 16) &&
                          !(opcode == MMCO_LONG2UNUSED && FIELD_PICTURE))){
-                        av_log(h->s.avctx, AV_LOG_ERROR,
+                        av_log(h->avctx, AV_LOG_ERROR,
                                "illegal long ref in memory management control "
                                "operation %d\n", opcode);
                         return -1;
@@ -747,7 +740,7 @@ int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb,
                 }
 
                 if (opcode > (unsigned) MMCO_LONG){
-                    av_log(h->s.avctx, AV_LOG_ERROR,
+                    av_log(h->avctx, AV_LOG_ERROR,
                            "illegal memory management control operation %d\n",
                            opcode);
                     return -1;
@@ -759,7 +752,7 @@ int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb,
         } else {
             if (first_slice) {
                 ret = ff_generate_sliding_window_mmcos(h, first_slice);
-                if (ret < 0 && s->avctx->err_recognition & AV_EF_EXPLODE)
+                if (ret < 0 && h->avctx->err_recognition & AV_EF_EXPLODE)
                     return ret;
             }
             mmco_index = -1;
@@ -771,7 +764,7 @@ int ff_h264_decode_ref_pic_marking(H264Context *h, GetBitContext *gb,
     } else if (!first_slice && mmco_index >= 0 &&
                (mmco_index != h->mmco_index ||
                 (i = check_opcodes(h->mmco, mmco_temp, mmco_index)))) {
-        av_log(h->s.avctx, AV_LOG_ERROR,
+        av_log(h->avctx, AV_LOG_ERROR,
                "Inconsistent MMCO state between slices [%d, %d]\n",
                mmco_index, h->mmco_index);
         return AVERROR_INVALIDDATA;