aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJanne Grunau <janne-libav@jannau.net>2014-02-13 10:39:08 +0100
committerJanne Grunau <janne-libav@jannau.net>2014-02-13 13:03:01 +0100
commit73eca738acd0770c4c415cba55371e984d27b03f (patch)
tree56cfa8b2f9a2f8b2be5be5e0d46483bfca2088a9
parentd261719319a505e1716e8b52fc955bef0503ff96 (diff)
downloadffmpeg-73eca738acd0770c4c415cba55371e984d27b03f.tar.gz
mpeg12dec: do not add stereo3D side data to a non-existing frame
User data is usually coded before slice data. That means the frame the user data belongs to is not available while parsing the user data. The stereo3D side data has to use the same indirection over the private context as pan scan information and A53 captions. Bug-Id:632
-rw-r--r--libavcodec/mpeg12dec.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 149d5f49ef..cb713fdf50 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -46,6 +46,8 @@ typedef struct Mpeg1Context {
int mpeg_enc_ctx_allocated; /* true if decoding context allocated */
int repeat_field; /* true if we must repeat the field */
AVPanScan pan_scan; /* some temporary storage for the panscan */
+ AVStereo3D stereo3d;
+ int has_stereo3d;
uint8_t *a53_caption;
int a53_caption_size;
int slice_count;
@@ -1614,6 +1616,15 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
memcpy(sd->data, s1->a53_caption, s1->a53_caption_size);
av_freep(&s1->a53_caption);
}
+
+ if (s1->has_stereo3d) {
+ AVStereo3D *stereo = av_stereo3d_create_side_data(&s->current_picture_ptr->f);
+ if (!stereo)
+ return AVERROR(ENOMEM);
+
+ *stereo = s1->stereo3d;
+ s1->has_stereo3d = 0;
+ }
if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME))
ff_thread_finish_setup(avctx);
} else { // second field
@@ -2231,24 +2242,21 @@ static void mpeg_decode_user_data(AVCodecContext *avctx,
S3D_video_format_type == 0x08 ||
S3D_video_format_type == 0x23) {
Mpeg1Context *s1 = avctx->priv_data;
- MpegEncContext *s = &s1->mpeg_enc_ctx;
- AVStereo3D *stereo =
- av_stereo3d_create_side_data(&s->current_picture_ptr->f);
- if (!stereo)
- return;
+
+ s1->has_stereo3d = 1;
switch (S3D_video_format_type) {
case 0x03:
- stereo->type = AV_STEREO3D_SIDEBYSIDE;
+ s1->stereo3d.type = AV_STEREO3D_SIDEBYSIDE;
break;
case 0x04:
- stereo->type = AV_STEREO3D_TOPBOTTOM;
+ s1->stereo3d.type = AV_STEREO3D_TOPBOTTOM;
break;
case 0x08:
- stereo->type = AV_STEREO3D_2D;
+ s1->stereo3d.type = AV_STEREO3D_2D;
break;
case 0x23:
- stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
+ s1->stereo3d.type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
break;
}
}