[FFmpeg-devel] [patch] mjpeg restart marker parsing

Michael Niedermayer michaelni
Mon Mar 29 23:06:02 CEST 2010


On Mon, Mar 29, 2010 at 01:16:31AM -0700, tom harper wrote:
> updated patch addresses previous comments - end of buffer should be EOI,
> which will return error because it is not a restart marker.  this change
> will also allow for out of order restart markers, which should just rotate
> in order ac. to spec.

>  mjpegdec.c |   19 +++++++++++++++++--
>  mjpegdec.h |    1 +
>  2 files changed, 18 insertions(+), 2 deletions(-)
> 0fb5ce5274823080983f9435b5b64728c88ea0a8  ffmpeg_mjpeg_restart_marker_patch.diff
> Index: mjpegdec.c
> ===================================================================
> --- mjpegdec.c	(revision 19751)
> +++ mjpegdec.c	(working copy)
> @@ -764,7 +764,7 @@
>  }
>  
>  static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, int Al){
> -    int i, mb_x, mb_y;
> +    int i, mb_x, mb_y, marker;
>      uint8_t* data[MAX_COMPONENTS];
>      int linesize[MAX_COMPONENTS];
>  
> @@ -831,7 +831,21 @@
>  
>              if (s->restart_interval && !--s->restart_count) {
>                  align_get_bits(&s->gb);
> -                skip_bits(&s->gb, 16); /* skip RSTn */

> +                marker = 0xFF;

useless


> +                /* remove stuffing bits */
> +                do {
> +                    marker = get_bits(&s->gb, 8);
> +                } while (marker == 0xFF);
> +                if (marker != (s->next_restart_marker+RST0))
> +                {
> +                    if ((marker >= RST0) && (marker <= RST7))
> +                        av_log(s->avctx, AV_LOG_WARNING, "unexpected restart marker %d vs %d\n",marker,s->next_restart_marker+RST0);
> +                    else {
> +                        av_log(s->avctx, AV_LOG_ERROR, "unexpected marker found where restart marker expected %d vs %d\n",marker,s->next_restart_marker+RST0);
> +                        return -1;
> +                    }

so why do you check against next_restart_marker at all?

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you really think that XML is the answer, then you definitly missunderstood
the question -- Attila Kinali
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100329/3b1cb336/attachment.pgp>



More information about the ffmpeg-devel mailing list