[FFmpeg-devel] [PATCH 7/8] Reject block size changes in the shorten decoder.

Michael Niedermayer michaelni at gmx.at
Sat Oct 1 02:01:35 CEST 2011


On Sat, Oct 01, 2011 at 12:43:05AM +0200, Laurent Aimar wrote:
> On Thu, Sep 29, 2011 at 10:12:19PM -0400, Justin Ruggles wrote:
> > On 09/29/2011 06:27 PM, Laurent Aimar wrote:
> > 
> > > On Thu, Sep 29, 2011 at 06:24:35PM -0400, Justin Ruggles wrote:
> > >> On 09/29/2011 06:05 PM, fenrir at elivagar.org wrote:
> > >>
> > >>> From: Laurent Aimar <fenrir at videolan.org>
> > >>>
> > >>> ---
> > >>>  libavcodec/shorten.c |    9 +++++++--
> > >>>  1 files changed, 7 insertions(+), 2 deletions(-)
> > >>>
> > >>> diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
> > >>> index b39fcbd..966584d 100644
> > >>> --- a/libavcodec/shorten.c
> > >>> +++ b/libavcodec/shorten.c
> > >>> @@ -482,9 +482,14 @@ static int shorten_decode_frame(AVCodecContext *avctx,
> > >>>              case FN_BITSHIFT:
> > >>>                  s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE);
> > >>>                  break;
> > >>> -            case FN_BLOCKSIZE:
> > >>> -                s->blocksize = get_uint(s, av_log2(s->blocksize));
> > >>> +            case FN_BLOCKSIZE: {
> > >>> +                int blocksize = get_uint(s, av_log2(s->blocksize));
> > >>> +                if (blocksize != s->blocksize) {
> > >>> +                    av_log(avctx, AV_LOG_ERROR, "block size changes are not supported\n");
> > >>> +                    return AVERROR_PATCHWELCOME;
> > >>> +                }
> > >>>                  break;
> > >>> +            }
> > >>>              case FN_QUIT:
> > >>>                  *data_size = 0;
> > >>>                  return buf_size;
> > >>
> > >>
> > >> The last frame can use a different blocksize.
> > >  Ok. Sadly the current code don't support it as is, except maybe if it
> > > is shorter. Is that the case? And if yes, do you have a sample?
> > 
> > 
> > Yes, it is shorter. I was able to create my own sample that triggered
> > this with the shorten commandline program from
> > http://www.etree.org/shnutils/shorten/
> 
> New patch attached. It now only reject increasing block size changes.
> 
> -- 
> fenrir

>  shorten.c |   10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> a2e35b38a9747ce152f6dacf642596034102e5f5  0001-Prevent-block-size-from-inreasing-in-the-shorten-dec.patch
> From 9a71177822057d0445326e8ea9d7ab4cf53ebead Mon Sep 17 00:00:00 2001
> From: Laurent Aimar <fenrir at videolan.org>
> Date: Thu, 29 Sep 2011 22:39:50 +0200
> Subject: [PATCH 01/13] Prevent block size from inreasing in the shorten decoder.
> 
> ---
>  libavcodec/shorten.c |   10 ++++++++--
>  1 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
> index f46b21f..ebc4290 100644
> --- a/libavcodec/shorten.c
> +++ b/libavcodec/shorten.c
> @@ -482,9 +482,15 @@ static int shorten_decode_frame(AVCodecContext *avctx,
>              case FN_BITSHIFT:
>                  s->bitshift = get_ur_golomb_shorten(&s->gb, BITSHIFTSIZE);
>                  break;
> -            case FN_BLOCKSIZE:
> -                s->blocksize = get_uint(s, av_log2(s->blocksize));
> +            case FN_BLOCKSIZE: {
> +                int blocksize = get_uint(s, av_log2(s->blocksize));
> +                if (blocksize > s->blocksize) {

i think get_uint() can return -1


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is what and why we do it that matters, not just one of them.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111001/90171549/attachment.asc>


More information about the ffmpeg-devel mailing list