[FFmpeg-devel] [PATCH] Fix distortion problem in MPEG1/2 video

Hee Suk Jung heesuk.jung at lge.com
Sat Nov 17 06:05:27 CET 2012


>From b67e7001765b9008d1edf09e445f9dbd331c33a2 Mon Sep 17 00:00:00 2001
From: Heesuk Jung <heesuk.jung at lge.com>
Date: Sat, 17 Nov 2012 13:52:50 +0900
Subject: [PATCH] Fix distortion problem in MPEG1/2 video

In some MPEG1/2 AVI files, there are video distortion problem in bottom of screen.
(I just test files by ffplay)

1. MPEG1 video problematic file link
 - https://docs.google.com/open?id=0B6r7ZfWFIypCMkltZHJDY0pQN1U
2. MPEG2 video problematic file link
 - https://docs.google.com/open?id=0B6r7ZfWFIypCM0ZremxpbXc1N3c

Suggests to use AVSTREAM_PARSE_FULL option in prblematic cases.
---
 libavformat/avidec.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/libavformat/avidec.c b/libavformat/avidec.c
index 0314b4d..3c411f7 100644
--- a/libavformat/avidec.c
+++ b/libavformat/avidec.c
@@ -635,7 +635,17 @@ static int avi_read_header(AVFormatContext *s)
                     st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
                     st->codec->codec_tag = tag1;
                     st->codec->codec_id = ff_codec_get_id(ff_codec_bmp_tags, tag1);
-                    st->need_parsing = AVSTREAM_PARSE_HEADERS; // This is needed to get the pict type which is
necessary for generating correct pts.
+                    switch (st->codec->codec_id) {
+                    case AV_CODEC_ID_MPEG1VIDEO:
+                        st->need_parsing = AVSTREAM_PARSE_FULL;
+                        break;
+                    case AV_CODEC_ID_MPEG2VIDEO:
+                        st->need_parsing = AVSTREAM_PARSE_FULL;
+                        break;
+                    default:
+                        st->need_parsing = AVSTREAM_PARSE_HEADERS; // This is needed to get the pict type which is
necessary for generating correct pts.
+                        break;
+                    }

                     if(st->codec->codec_tag==0 && st->codec->height > 0 && st->codec->extradata_size < 1U<<30){
                         st->codec->extradata_size+= 9;
--
1.8.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-distortion-problem-in-MPEG1-2-video.patch
Type: application/octet-stream
Size: 2008 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121117/17214765/attachment.obj>


More information about the ffmpeg-devel mailing list