[FFmpeg-devel] [PATCH] lavfi: store and propagate number of channels information in audio buffer properties

Michael Niedermayer michaelni at gmx.at
Sun Nov 11 04:46:13 CET 2012


On Tue, Jul 31, 2012 at 01:13:14AM +0200, Michael Niedermayer wrote:
> On Mon, Jul 30, 2012 at 04:11:56PM +0200, Stefano Sabatini wrote:
> > The channels field is required since the channel layout is not always
> > available.
> > ---
> >  libavfilter/af_ashowinfo.c |    3 ++-
> >  libavfilter/avcodec.c      |    2 ++
> >  libavfilter/avfilter.h     |    1 +
> >  3 files changed, 5 insertions(+), 1 deletions(-)
> > 
> > diff --git a/libavfilter/af_ashowinfo.c b/libavfilter/af_ashowinfo.c
> > index 0d4bbb2..65f18f5 100644
> > --- a/libavfilter/af_ashowinfo.c
> > +++ b/libavfilter/af_ashowinfo.c
> > @@ -66,12 +66,13 @@ static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *samplesref)
> >  
> >      av_log(ctx, AV_LOG_INFO,
> >             "n:%d pts:%s pts_time:%s pos:%"PRId64" "
> > -           "fmt:%s chlayout:%s nb_samples:%d rate:%d "
> > +           "fmt:%s channels:%d chlayout:%s nb_samples:%d rate:%d "
> >             "checksum:%08X plane_checksum[%08X",
> >             showinfo->frame,
> >             av_ts2str(samplesref->pts), av_ts2timestr(samplesref->pts, &inlink->time_base),
> >             samplesref->pos,
> >             av_get_sample_fmt_name(samplesref->format),
> > +           samplesref->audio->channels,
> >             chlayout_str,
> >             samplesref->audio->nb_samples,
> >             samplesref->audio->sample_rate,
> > diff --git a/libavfilter/avcodec.c b/libavfilter/avcodec.c
> > index f452303..8d61fbc 100644
> > --- a/libavfilter/avcodec.c
> > +++ b/libavfilter/avcodec.c
> > @@ -46,6 +46,7 @@ int avfilter_copy_frame_props(AVFilterBufferRef *dst, const AVFrame *src)
> >      case AVMEDIA_TYPE_AUDIO:
> >          dst->audio->sample_rate         = src->sample_rate;
> >          dst->audio->channel_layout      = src->channel_layout;
> > +        dst->audio->channels            = src->channels;
> >          break;
> >      default:
> >          return AVERROR(EINVAL);
> > @@ -137,6 +138,7 @@ int avfilter_copy_buf_props(AVFrame *dst, const AVFilterBufferRef *src)
> >          dst->nb_samples          = src->audio->nb_samples;
> >          av_frame_set_sample_rate   (dst, src->audio->sample_rate);
> >          av_frame_set_channel_layout(dst, src->audio->channel_layout);
> > +        av_frame_set_channels      (dst, src->audio->channels);
> >          break;
> >      default:
> >          return AVERROR(EINVAL);
> > diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
> > index 91820dd..c9ef7db 100644
> > --- a/libavfilter/avfilter.h
> > +++ b/libavfilter/avfilter.h
> > @@ -110,6 +110,7 @@ typedef struct AVFilterBuffer {
> >   */
> >  typedef struct AVFilterBufferRefAudioProps {
> >      uint64_t channel_layout;    ///< channel layout of audio buffer
> > +    int channels;               ///< number of channels
> >      int nb_samples;             ///< number of audio samples per channel
> >      int sample_rate;            ///< audio buffer sample rate
> >  } AVFilterBufferRefAudioProps;
> 
> i think at the end of the struct is a safer
> and minor should be bumped
> 
> otherwise LGTM

ping

ive today fixed a security issue that a design based on this patch
would have never made possible. Also currently we cannot transcode
files with more than 8 channels, and to transcode a file without a
layout that can be represented in the layout mask a random standard
layout must be assigned to it, that is just wrong and also might
produce damaged files containing incorrect layouts.

so this patch should not be left rotting ...

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Observe your enemies, for they first find out your faults. -- Antisthenes
-------------- 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/20121111/383d3a2b/attachment.asc>


More information about the ffmpeg-devel mailing list