diff options
author | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2012-04-09 14:21:01 +0200 |
---|---|---|
committer | Reimar Döffinger <Reimar.Doeffinger@gmx.de> | 2012-04-09 17:21:34 +0200 |
commit | 438f3ef8214ddc3bc3f2c25328c34065df48d4e6 (patch) | |
tree | 282027f43329c3938b572abaccf7373c1a719ec4 /libavcodec | |
parent | 1d130328ed5d536b5d93bc5cbf710fffbdbcf136 (diff) | |
download | ffmpeg-438f3ef8214ddc3bc3f2c25328c34065df48d4e6.tar.gz |
RV20: try keeping aspect during resolution changes.
Resolution changes are usually only used to scale with
network bandwidth, the (full) resolution specified in the
RM header really is authoritative.
While I am not sure this is the best solution, it is a
conservative approach that still should fix the most
common cases.
In particular, it fixes aspect with the sample from trac
issue #785 (in MPlayer, ffplay seems to just ignore
sample aspect changes in mid-playback).
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/rv10.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 78b81e97ca..f4ce1a38c9 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -371,10 +371,19 @@ static int rv20_decode_picture_header(RVDecContext *rv) new_h= s->orig_height; } if(new_w != s->width || new_h != s->height){ + AVRational old_aspect = s->avctx->sample_aspect_ratio; av_log(s->avctx, AV_LOG_DEBUG, "attempting to change resolution to %dx%d\n", new_w, new_h); if (av_image_check_size(new_w, new_h, 0, s->avctx) < 0) return -1; ff_MPV_common_end(s); + + // attempt to keep aspect during typical resolution switches + if (!old_aspect.num) + old_aspect = (AVRational){1, 1}; + if (2 * new_w * s->height == new_h * s->width) + s->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){2, 1}); + if (new_w * s->height == 2 * new_h * s->width) + s->avctx->sample_aspect_ratio = av_mul_q(old_aspect, (AVRational){1, 2}); avcodec_set_dimensions(s->avctx, new_w, new_h); s->width = new_w; s->height = new_h; |