From 9e500efdbe0deeff1602500ebc229a0a6b6bb1a2 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 28 Apr 2014 16:08:33 -0400 Subject: Add av_image_check_sar() and use it to validate SAR --- libavcodec/dvdec.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'libavcodec/dvdec.c') diff --git a/libavcodec/dvdec.c b/libavcodec/dvdec.c index f354b9e0e8..89f5821b00 100644 --- a/libavcodec/dvdec.c +++ b/libavcodec/dvdec.c @@ -36,6 +36,7 @@ */ #include "libavutil/internal.h" +#include "libavutil/imgutils.h" #include "libavutil/pixdesc.h" #include "avcodec.h" #include "internal.h" @@ -347,6 +348,14 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, if (ret < 0) return ret; + /* Determine the codec's sample_aspect ratio from the packet */ + vsc_pack = buf + 80*5 + 48 + 5; + if ( *vsc_pack == dv_video_control ) { + apt = buf[4] & 0x07; + is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 || (!apt && (vsc_pack[2] & 0x07) == 0x07))); + ff_set_sar(avctx, s->sys->sar[is16_9]); + } + if (ff_get_buffer(avctx, s->frame, 0) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); return -1; @@ -363,14 +372,6 @@ static int dvvideo_decode_frame(AVCodecContext *avctx, /* return image */ *got_frame = 1; - /* Determine the codec's sample_aspect ratio from the packet */ - vsc_pack = buf + 80*5 + 48 + 5; - if ( *vsc_pack == dv_video_control ) { - apt = buf[4] & 0x07; - is16_9 = (vsc_pack && ((vsc_pack[2] & 0x07) == 0x02 || (!apt && (vsc_pack[2] & 0x07) == 0x07))); - avctx->sample_aspect_ratio = s->sys->sar[is16_9]; - } - return s->sys->frame_size; } -- cgit v1.2.3