]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mpeg12.c
Fix nv12/nv21 handling. linesize for plane 1 should account for both chroma
[ffmpeg] / libavcodec / mpeg12.c
index 48c7899f7c628191bb26cdfed16bcc0bd62aceef..f226602004e09fc6fdb5680a2d439577c6a5ecb6 100644 (file)
@@ -30,7 +30,6 @@
 #include "avcodec.h"
 #include "dsputil.h"
 #include "mpegvideo.h"
-#include "mpegvideo_common.h"
 
 #include "mpeg12.h"
 #include "mpeg12data.h"
@@ -1715,19 +1714,6 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y,
 
     s->mb_x=0;
 
-    if (avctx->hwaccel) {
-        const uint8_t *buf_end, *buf_start = *buf - 4; /* include start_code */
-        int start_code = -1;
-        buf_end = ff_find_start_code(buf_start + 2, *buf + buf_size, &start_code);
-        if (buf_end < *buf + buf_size)
-            buf_end -= 4;
-        s->mb_y = mb_y;
-        if (avctx->hwaccel->decode_slice(avctx, buf_start, buf_end - buf_start) < 0)
-            return DECODE_SLICE_ERROR;
-        *buf = buf_end;
-        return DECODE_SLICE_OK;
-    }
-
     for(;;) {
         int code = get_vlc2(&s->gb, mbincr_vlc.table, MBINCR_VLC_BITS, 2);
         if (code < 0){
@@ -1749,6 +1735,19 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y,
         return -1;
     }
 
+    if (avctx->hwaccel) {
+        const uint8_t *buf_end, *buf_start = *buf - 4; /* include start_code */
+        int start_code = -1;
+        buf_end = ff_find_start_code(buf_start + 2, *buf + buf_size, &start_code);
+        if (buf_end < *buf + buf_size)
+            buf_end -= 4;
+        s->mb_y = mb_y;
+        if (avctx->hwaccel->decode_slice(avctx, buf_start, buf_end - buf_start) < 0)
+            return DECODE_SLICE_ERROR;
+        *buf = buf_end;
+        return DECODE_SLICE_OK;
+    }
+
     s->resync_mb_x= s->mb_x;
     s->resync_mb_y= s->mb_y= mb_y;
     s->mb_skip_run= 0;
@@ -1819,7 +1818,7 @@ static int mpeg_decode_slice(Mpeg1Context *s1, int mb_y,
             s->mb_y++;
 
             if(s->mb_y<<field_pic >= s->mb_height){
-                int left= s->gb.size_in_bits - get_bits_count(&s->gb);
+                int left= get_bits_left(&s->gb);
                 int is_d10= s->chroma_format==2 && s->pict_type==FF_I_TYPE && avctx->profile==0 && avctx->level==5
                             && s->intra_dc_precision == 2 && s->q_scale_type == 1 && s->alternate_scan == 0
                             && s->progressive_frame == 0 /* vbv_delay == 0xBBB || 0xE10*/;
@@ -2310,7 +2309,7 @@ static int decode_chunks(AVCodecContext *avctx,
                 if(avctx->thread_count > 1){
                     int i;
 
-                    avctx->execute(avctx, slice_decode_thread,  (void**)&(s2->thread_context[0]), NULL, s->slice_count, sizeof(void*));
+                    avctx->execute(avctx, slice_decode_thread,  &s2->thread_context[0], NULL, s->slice_count, sizeof(void*));
                     for(i=0; i<s->slice_count; i++)
                         s2->error_count += s2->thread_context[i]->error_count;
                 }
@@ -2373,7 +2372,7 @@ static int decode_chunks(AVCodecContext *avctx,
                         /* Allocate a dummy frame */
                         i= ff_find_unused_picture(s2, 0);
                         s2->last_picture_ptr= &s2->picture[i];
-                        if(alloc_picture(s2, s2->last_picture_ptr, 0) < 0)
+                        if(ff_alloc_picture(s2, s2->last_picture_ptr, 0) < 0)
                             return -1;
                     }
                 }