]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mpeg12dec.c
x86/hevc_mc: remove an unnecessary pxor
[ffmpeg] / libavcodec / mpeg12dec.c
index 27bb6e0809401cb5b0d9e36d2e7ef6a1235bf302..3b769dfb7705c640f3c084c45720d46619d820d0 100644 (file)
@@ -56,6 +56,8 @@ typedef struct Mpeg1Context {
     int has_stereo3d;
     uint8_t *a53_caption;
     int a53_caption_size;
+    uint8_t afd;
+    int has_afd;
     int slice_count;
     int save_aspect_info;
     int save_width, save_height, save_progressive_seq;
@@ -1659,6 +1661,18 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
             *stereo = s1->stereo3d;
             s1->has_stereo3d = 0;
         }
+
+        if (s1->has_afd) {
+            AVFrameSideData *sd =
+                av_frame_new_side_data(s->current_picture_ptr->f,
+                                       AV_FRAME_DATA_AFD, 1);
+            if (!sd)
+                return AVERROR(ENOMEM);
+
+            *sd->data   = s1->afd;
+            s1->has_afd = 0;
+        }
+
         if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME))
             ff_thread_finish_setup(avctx);
     } else { // second field
@@ -1884,6 +1898,10 @@ static int mpeg_decode_slice(MpegEncContext *s, int mb_y,
                 } else
                     goto eos;
             }
+            // There are some files out there which are missing the last slice
+            // in cases where the slice is completely outside the visible
+            // area, we detect this here instead of running into the end expecting
+            // more data
             if (s->mb_y >= ((s->height + 15) >> 4) &&
                 s->progressive_frame &&
                 !s->progressive_sequence &&
@@ -2260,6 +2278,7 @@ static void mpeg_decode_user_data(AVCodecContext *avctx,
 {
     Mpeg1Context *s = avctx->priv_data;
     const uint8_t *buf_end = p + buf_size;
+    Mpeg1Context *s1 = avctx->priv_data;
 
     if (buf_size > 29){
         int i;
@@ -2286,7 +2305,11 @@ static void mpeg_decode_user_data(AVCodecContext *avctx,
         if (flags & 0x40) {
             if (buf_end - p < 1)
                 return;
+#if FF_API_AFD
             avctx->dtg_active_format = p[0] & 0x0f;
+#endif /* FF_API_AFD */
+            s1->has_afd = 1;
+            s1->afd     = p[0] & 0x0f;
         }
     } else if (buf_end - p >= 6 &&
                p[0] == 'J' && p[1] == 'P' && p[2] == '3' && p[3] == 'D' &&
@@ -2298,7 +2321,6 @@ static void mpeg_decode_user_data(AVCodecContext *avctx,
             S3D_video_format_type == 0x04 ||
             S3D_video_format_type == 0x08 ||
             S3D_video_format_type == 0x23) {
-            Mpeg1Context *s1   = avctx->priv_data;
 
             s1->has_stereo3d = 1;