Browse code

In dv decoder, set sample aspect aspect ratio, fix issue #1612

Originally committed as revision 25232 to svn://svn.ffmpeg.org/ffmpeg/trunk

Baptiste Coudurier authored on 2010/09/28 06:31:29
Showing 1 changed files
... ...
@@ -1081,6 +1081,8 @@ static int dvvideo_decode_frame(AVCodecContext *avctx,
1081 1081
     const uint8_t *buf = avpkt->data;
1082 1082
     int buf_size = avpkt->size;
1083 1083
     DVVideoContext *s = avctx->priv_data;
1084
+    const uint8_t* vsc_pack;
1085
+    int apt, is16_9;
1084 1086
 
1085 1087
     s->sys = ff_dv_frame_profile(s->sys, buf, buf_size);
1086 1088
     if (!s->sys || buf_size < s->sys->frame_size || dv_init_dynamic_tables(s->sys)) {
... ...
@@ -1114,6 +1116,14 @@ static int dvvideo_decode_frame(AVCodecContext *avctx,
1114 1114
     *data_size = sizeof(AVFrame);
1115 1115
     *(AVFrame*)data = s->picture;
1116 1116
 
1117
+    /* Determine the codec's sample_aspect ratio from the packet */
1118
+    vsc_pack = buf + 80*5 + 48 + 5;
1119
+    if ( *vsc_pack == dv_video_control ) {
1120
+        apt = buf[4] & 0x07;
1121
+        is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 || (!apt && (vsc_pack[2] & 0x07) == 0x07)));
1122
+        avctx->sample_aspect_ratio = s->sys->sar[is16_9];
1123
+    }
1124
+
1117 1125
     return s->sys->frame_size;
1118 1126
 }
1119 1127
 #endif /* CONFIG_DVVIDEO_DECODER */