[FFmpeg-cvslog] avcodec/mpeg12dec: Fix chroma location
Michael Niedermayer
git at videolan.org
Fri May 22 15:46:49 CEST 2015
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Fri May 22 15:08:58 2015 +0200| [d09321b68e8373435aa98801929c0a5714efd104] | committer: Michael Niedermayer
avcodec/mpeg12dec: Fix chroma location
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d09321b68e8373435aa98801929c0a5714efd104
---
libavcodec/mpeg12dec.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index ea7386c..1ca6c9d 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1141,10 +1141,6 @@ static av_cold int mpeg_decode_init(AVCodecContext *avctx)
s->repeat_field = 0;
s->mpeg_enc_ctx.codec_id = avctx->codec->id;
avctx->color_range = AVCOL_RANGE_MPEG;
- if (avctx->codec->id == AV_CODEC_ID_MPEG1VIDEO)
- avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
- else
- avctx->chroma_sample_location = AVCHROMA_LOC_LEFT;
return 0;
}
@@ -1366,6 +1362,8 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
// MPEG-1 fps
avctx->framerate = ff_mpeg12_frame_rate_tab[s->frame_rate_index];
avctx->ticks_per_frame = 1;
+
+ avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
} else { // MPEG-2
// MPEG-2 fps
av_reduce(&s->avctx->framerate.num,
@@ -1374,6 +1372,12 @@ static int mpeg_decode_postinit(AVCodecContext *avctx)
ff_mpeg12_frame_rate_tab[s->frame_rate_index].den * s1->frame_rate_ext.den,
1 << 30);
avctx->ticks_per_frame = 2;
+
+ switch (s->chroma_format) {
+ case 1: avctx->chroma_sample_location = AVCHROMA_LOC_LEFT; break;
+ case 2:
+ case 3: avctx->chroma_sample_location = AVCHROMA_LOC_TOPLEFT; break;
+ }
} // MPEG-2
avctx->pix_fmt = mpeg_get_pixelformat(avctx);
More information about the ffmpeg-cvslog
mailing list