[FFmpeg-devel] [PATCH]ffmpeg: Do not set too large bits_per_raw_sample

Michael Niedermayer michael at niedermayer.cc
Wed Aug 17 18:39:06 EEST 2016


On Tue, Jul 05, 2016 at 11:51:58AM +0200, Carl Eugen Hoyos wrote:
> On Tuesday 05 July 2016 12:36:53 am Michael Niedermayer wrote:
> > On Sun, May 01, 2016 at 05:11:08PM +0200, Carl Eugen Hoyos wrote:
> > > Hi!
> > >
> > > Attached patch stops setting bits_per_raw_sample if it makes no sense as
> > > for example in the wmall24 -> pcm_s16 case:
> > >     Stream #0:0: Audio: pcm_s16le, 96000 Hz, stereo, s16 (24 bit), 3072
> > > kb/s
> > >
> > > Mostly tested with audio.
> > >
> > > Please comment, Carl Eugen
> > >
> > >  ffmpeg.c |    7 ++++++-
> > >  1 file changed, 6 insertions(+), 1 deletion(-)
> > > 1a672d3fd9fe8e65d2ad9a4271fe5260a888e28a  patchrawsample.diff
> > > diff --git a/ffmpeg.c b/ffmpeg.c
> > > index adc3ff7..86bc518 100644
> > > --- a/ffmpeg.c
> > > +++ b/ffmpeg.c
> > > @@ -2859,7 +2859,6 @@ static int transcode_init(void)
> > >              dec_ctx = ist->dec_ctx;
> > >
> > >              ost->st->disposition          = ist->st->disposition;
> > > -            enc_ctx->bits_per_raw_sample    =
> > > dec_ctx->bits_per_raw_sample; enc_ctx->chroma_sample_location =
> > > dec_ctx->chroma_sample_location; } else {
> > >              for (j=0; j<oc->nb_streams; j++) {
> > > @@ -3100,6 +3099,9 @@ static int transcode_init(void)
> > >              switch (enc_ctx->codec_type) {
> > >              case AVMEDIA_TYPE_AUDIO:
> > >                  enc_ctx->sample_fmt     =
> > > ost->filter->filter->inputs[0]->format; +                if (dec_ctx)
> > > +                    enc_ctx->bits_per_raw_sample =
> > > FFMIN(dec_ctx->bits_per_raw_sample, +                                    
> > >                     av_get_bytes_per_sample(enc_ctx->sample_fmt) << 3);
> > > enc_ctx->sample_rate    = ost->filter->filter->inputs[0]->sample_rate;
> > > enc_ctx->channel_layout = ost->filter->filter->inputs[0]->channel_layout;
> > > enc_ctx->channels       =
> > > avfilter_link_get_channels(ost->filter->filter->inputs[0]); @@ -3140,6
> > > +3142,9 @@ static int transcode_init(void)
> > >                             "Use -pix_fmt yuv420p for compatibility with
> > > outdated media players.\n",
> > > av_get_pix_fmt_name(ost->filter->filter->inputs[0]->format));
> > > enc_ctx->pix_fmt = ost->filter->filter->inputs[0]->format; +             
> > >   if (dec_ctx)
> > > +                    enc_ctx->bits_per_raw_sample =
> > > FFMIN(dec_ctx->bits_per_raw_sample, +                                    
> > >                    
> > > av_pix_fmt_desc_get(enc_ctx->pix_fmt)->comp[0].depth);
> >
> > these 2 are missing the stream copy case above
> 
> New patch attached.
> 
> Thank you, Carl Eugen

>  ffmpeg.c |    8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> fdc6c80180ce86fd7767306018660292217060ee  0001-ffmpeg-Do-not-set-too-large-bits_per_raw_sample.patch
> From fc564ed83ddf55b9ae783044ad0884803d27d9a7 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <cehoyos at ag.or.at>
> Date: Tue, 5 Jul 2016 11:50:00 +0200
> Subject: [PATCH] ffmpeg: Do not set too large bits_per_raw_sample.

LGTM

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160817/eb30f232/attachment.sig>


More information about the ffmpeg-devel mailing list