[FFmpeg-devel] [PATCH] Do not override pix_fmt in rawdec.c

Michael Niedermayer michaelni
Wed Jun 9 15:38:19 CEST 2010


On Wed, Jun 09, 2010 at 11:38:14AM +0200, Tomas H?rdin wrote:
> On Mon, 2010-06-07 at 22:23 +0200, Michael Niedermayer wrote:
> > >  avcodec.h |    5 ++++-
> > >  rawdec.c  |    2 ++
> > >  2 files changed, 6 insertions(+), 1 deletion(-)
> > > d44a164fed7c1a5cd69f362d521ef66aad6f42b2  rawdec_pix_fmt2.patch
> > > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > > index a6f6b04..d0aa162 100644
> > > --- a/libavcodec/avcodec.h
> > > +++ b/libavcodec/avcodec.h
> > > @@ -1120,8 +1120,11 @@ typedef struct AVCodecContext {
> > >  
> > >      /**
> > >       * Pixel format, see PIX_FMT_xxx.
> > > +     * May be set by the demuxer, especially when demuxing rawvideo.
> > > +     * Some demuxers use bits_per_coded_sample or codec_tag for this purpose instead.
> > 
> > > +     * Some codecs may override this value. The rawvideo decoder will not.
> > 
> > i really would like to avoid adding special cases
> > 
> > 
> > >       * - encoding: Set by user.
> > > -     * - decoding: Set by libavcodec.
> > > +     * - decoding: Set by user and/or libavcodec.
> > 
> > i would say
> > Set by user if known, overridden by libavcodec if known
> 
> OK. I changed the explanation a bit as well. Patch attached. I also
> reran the regtests against latest SVN, which worked fine.
> 
> For future reference, I searched for all files where both
> CODEC_ID_RAWVIDEO and bits_per_coded_sample are used in a video context.
> This in order to hopefully simplify rawdec.c later.
> 
> AVI: avidec.c, riff.c
> MOV: mov.c, movenc.c
> Others: utils.c, nsvdec.c, vwfcap.c, rawdec.c
> Soon: mxf.c, mxfdec.c
> 
> /Tomas

>  avcodec.h |    4 +++-
>  rawdec.c  |    2 ++
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 08923a4cccf43a6a6853a1794b17fef2dffa623e  rawdec_pix_fmt3.patch
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 5e77fb3..ffc2e07 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -1121,8 +1121,10 @@ typedef struct AVCodecContext {
>  
>      /**
>       * Pixel format, see PIX_FMT_xxx.
> +     * May be set by the demuxer if known from headers.
> +     * May be overriden by the decoder if it knows better.
>       * - encoding: Set by user.
> -     * - decoding: Set by libavcodec.
> +     * - decoding: Set by user if known, overridden by libavcodec if known
>       */
>      enum PixelFormat pix_fmt;

ok


>  
> diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
> index ab13bdc..69b72d1 100644
> --- a/libavcodec/rawdec.c
> +++ b/libavcodec/rawdec.c
> @@ -73,12 +73,14 @@ static av_cold int raw_init_decoder(AVCodecContext *avctx)
>  {
>      RawVideoContext *context = avctx->priv_data;
>  
> +    if (avctx->pix_fmt == PIX_FMT_NONE) {
>      if (avctx->codec_tag == MKTAG('r','a','w',' '))
>          avctx->pix_fmt = find_pix_fmt(pix_fmt_bps_mov, avctx->bits_per_coded_sample);
>      else if (avctx->codec_tag)
>          avctx->pix_fmt = find_pix_fmt(ff_raw_pix_fmt_tags, avctx->codec_tag);
>      else if (avctx->bits_per_coded_sample)
>          avctx->pix_fmt = find_pix_fmt(pix_fmt_bps_avi, avctx->bits_per_coded_sample);
> +    }

i think this skips too much, considering the new documentation

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

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- 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/20100609/949152ff/attachment.pgp>



More information about the ffmpeg-devel mailing list