On Sat, Jul 22, 2017 at 10:13 AM, Anton Khirnov <[email protected]> wrote:

> Quoting Vittorio Giovara (2017-06-29 00:10:48)
> > From: Anton Khirnov <[email protected]>
> >
> > Signed-off-by: Vittorio Giovara <[email protected]>
> > ---
> >  libavcodec/decode.c | 67 ++++++++++++++++++++++++++++------------
> >  libavcodec/encode.c |  9 ++++++
> >  libavutil/frame.c   | 88 ++++++++++++++++++++++++++++++
> +++++++++++++++++------
> >  libavutil/frame.h   | 12 +++++++-
> >  4 files changed, 146 insertions(+), 30 deletions(-)
> >
> > diff --git a/libavcodec/decode.c b/libavcodec/decode.c
> > index a49cd77e51..b0d6b9fb33 100644
> > --- a/libavcodec/decode.c
> > +++ b/libavcodec/decode.c
> > @@ -132,7 +132,7 @@ static int unrefcount_frame(AVCodecInternal *avci,
> AVFrame *frame)
> >      memcpy(frame->data,     avci->to_free->data,
>  sizeof(frame->data));
> >      memcpy(frame->linesize, avci->to_free->linesize,
> sizeof(frame->linesize));
> >      if (avci->to_free->extended_data != avci->to_free->data) {
> > -        int planes = av_get_channel_layout_nb_channels(avci->to_free->
> channel_layout);
> > +        int planes = avci->to_free->ch_layout.nb_channels;
> >          int size   = planes * sizeof(*frame->extended_data);
> >
> >          if (!size) {
> > @@ -153,9 +153,19 @@ static int unrefcount_frame(AVCodecInternal *avci,
> AVFrame *frame)
> >      frame->format         = avci->to_free->format;
> >      frame->width          = avci->to_free->width;
> >      frame->height         = avci->to_free->height;
> > +#if FF_API_OLD_CHANNEL_LAYOUT
> > +FF_DISABLE_DEPRECATION_WARNINGS
> >      frame->channel_layout = avci->to_free->channel_layout;
> > +FF_ENABLE_DEPRECATION_WARNINGS
> > +#endif
> >      frame->nb_samples     = avci->to_free->nb_samples;
> >
> > +    ret = av_channel_layout_copy(&frame->ch_layout,
> &avci->to_free->ch_layout);
> > +    if (ret < 0) {
> > +        av_frame_unref(frame);
> > +        return ret;
> > +    }
> > +
> >      return 0;
> >  }
> >
> > @@ -887,10 +897,20 @@ static int update_frame_pool(AVCodecContext
> *avctx, AVFrame *frame)
> >          break;
> >          }
> >      case AVMEDIA_TYPE_AUDIO: {
> > -        int ch     = av_get_channel_layout_nb_channels(frame->channel_
> layout);
> > +        int ch     = frame->ch_layout.nb_channels;
> >          int planar = av_sample_fmt_is_planar(frame->format);
> >          int planes = planar ? ch : 1;
> >
> > +#if FF_API_OLD_CHANNEL_LAYOUT
> > +FF_DISABLE_DEPRECATION_WARNINGS
> > +        if (!ch && frame->channel_layout) {
> > +            av_channel_layout_from_mask(&frame->ch_layout,
> frame->channel_layout);
> > +            ch     = frame->ch_layout.nb_channels;
> > +            planes = planar ? ch : 1;
> > +        }
> > +FF_ENABLE_DEPRECATION_WARNINGS
> > +#endif
>
> What is this for? This code is the internal get_buffer2()
> implementation, so the new channel layout API should always be used.
>

Yes this chunk is unneeded I'll drop it.


> > +
> >          if (pool->format == frame->format && pool->planes == planes &&
> >              pool->channels == ch && frame->nb_samples == pool->samples)
> >              return 0;
> > @@ -1111,28 +1131,35 @@ int ff_get_buffer(AVCodecContext *avctx, AVFrame
> *frame, int flags)
> >              frame->sample_rate    = avctx->sample_rate;
> >          if (frame->format < 0)
> >              frame->format         = avctx->sample_fmt;
> > +        if (!frame->ch_layout.nb_channels) {
> > +            if (avctx->channel_layout)
> > +                av_channel_layout_from_mask(&frame->ch_layout,
> avctx->channel_layout);
> > +            else
> > +                av_channel_layout_default(&frame->ch_layout,
> avctx->channels);
> > +        }
>
> Same, why the deprecated API use.
>

This chunk is actually needed because some decoders don't set the channel
layout fully before ff_get_buffer.
Besides this use is going to be dropped in a later patch, as the
AVCodecContext is fully ported to the new API.
-- 
Vittorio
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to