[libav-devel] [PATCH] jpegdec: actually search for and parse RSTn

Reinhard Tartler siretart at tauware.de
Sat Jul 23 17:14:29 CEST 2011


On Sat, Jul 23, 2011 at 14:44:36 (CEST), Kostya wrote:

> On Fri, Jul 22, 2011 at 07:53:44PM +0200, Reinhard Tartler wrote:
>> From: Michael Niedermayer <michaelni at gmx.at>
>> 
>> Fixes http://ffmpeg.org/trac/ffmpeg/ticket/267
>
> Please replace it with a description of a problem (from that ticket, for
> example). Our project is not high-quality and thus still demands sensible
> commit messages.

Okay, what about this message then:

jpegdec: actually search for and parse RSTn

Fixes decoding of MJPEG files produced by some UVC Logitec web cameras,
such as "Notebook Pro" and "HD C910".

References:
http://trac.videolan.org/vlc/ticket/4215
http://ffmpeg.org/trac/ffmpeg/ticket/267

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit 7b8ed831eb8432d202dad16dedc1758b018bb1fa)


>> ---
>>  libavcodec/mjpegdec.c |    7 +++++--
>>  1 files changed, 5 insertions(+), 2 deletions(-)
>> 
>> diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
>> index b28fdf8..a1588df 100644
>> --- a/libavcodec/mjpegdec.c
>> +++ b/libavcodec/mjpegdec.c
>> @@ -879,9 +879,12 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, i
>>                  }
>>              }
>>  
>> -            if (s->restart_interval && !--s->restart_count) {
>> +            if (s->restart_interval && show_bits(&s->gb, 8) == 0xFF){/* skip RSTn */
>                                             a space wouldn't hurt here ^

Will add it.

>> +                --s->restart_count;
>>                  align_get_bits(&s->gb);
>> -                skip_bits(&s->gb, 16); /* skip RSTn */
>> +                while(show_bits(&s->gb, 8) == 0xFF)
>> +                    skip_bits(&s->gb, 8);
>> +                skip_bits(&s->gb, 8);
>>                  for (i=0; i<nb_components; i++) /* reset dc */
>>                      s->last_dc[i] = 1024;
>>              }
>> --
>
> After looking at the spec the patch seems passable, Appendix E of the JPEG
> spec says "Note that optional X’FF’ fill bytes which may precede any marker
> shall be discarded before determining which marker is present."
> _______________________________________________
> libav-devel mailing list
> libav-devel at libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel

-- 
Gruesse/greetings,
Reinhard Tartler, KeyID 945348A4


More information about the libav-devel mailing list