[FFmpeg-devel] MPEG TS encoding problem on change from stereo to mono, pay for fix

Stefano Sabatini stefano.sabatini-lala
Tue Dec 7 23:55:39 CET 2010


On date Sunday 2010-12-05 18:15:07 +0100, Stefano Sabatini encoded:
> On date Thursday 2010-12-02 08:32:33 +0100, Reimar D?ffinger encoded:
> > On Thu, Dec 02, 2010 at 01:38:33AM +0100, Michael Niedermayer wrote:
> > > On Wed, Dec 01, 2010 at 06:20:18PM +0100, Reimar D?ffinger wrote:
> > > > On Wed, Dec 01, 2010 at 05:00:19PM +0100, Michael Niedermayer wrote:
> > > > > On Wed, Dec 01, 2010 at 09:14:03AM +0100, Reimar D?ffinger wrote:
> > > > > > On Wed, Dec 01, 2010 at 04:10:49AM +0100, Michael Niedermayer wrote:
> > > > > > > On Wed, Nov 24, 2010 at 12:10:47AM +0100, Stefano Sabatini wrote:
> > > > > > > > @@ -776,7 +779,7 @@ static void do_audio_out(AVFormatContext *s,
> > > > > > > >      int64_t audio_out_size, audio_buf_size;
> > > > > > > >      int64_t allocated_for_size= size;
> > > > > > > >  
> > > > > > > > -    int size_out, frame_bytes, ret;
> > > > > > > > +    int size_out, frame_bytes, ret, resample_changed;
> > > > > > > >      AVCodecContext *enc= ost->st->codec;
> > > > > > > >      AVCodecContext *dec= ist->st->codec;
> > > > > > > >      int osize= av_get_bits_per_sample_fmt(enc->sample_fmt)/8;
> > > > > > > > @@ -810,7 +813,28 @@ need_realloc:
> > > > > > > 
> > > > > > > 
> > > > > > > >      if (enc->channels != dec->channels)
> > > > > > >            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > > > > > > >          ost->audio_resample = 1;
> > > > > > > >  
> > > > > > > > -    if (ost->audio_resample && !ost->resample) {
> > > > > > > > +    resample_changed = ost->resample_sample_fmt  != dec->sample_fmt ||
> > > > > > > > +                       ost->resample_channels    != dec->channels   ||
> > > > > > > 
> > > > > > > this looks redundant
> > > > > > 
> > > > > > Huh? One checks whether decoder output and encoder input differ,
> > > > > > the other one checks whether the decoder output format changed...
> > > > > 
> > > > > they can differ and still not change?
> > > > 
> > > > I don't understand what is unclear here.
> > > 
> > > its not unclear, i just thought it would be simpler to drop the enc != dec
> > > check and use the expected resampler input != dec for it by initially setting
> > > it to the enc value
> > > but i did not investigate this further at all it was just a thought from taking
> > > a quick look
> > 
> > Ah, ok. I don't know, it is possible it might be more confusing since we
> > need to check whether we need a resampler at all anyway.
> > I don't know.
> 
> The present code is buggy, channel change and format/sample are
> treated differently, if the number of channels changes then
> ost->resample_ctx is used for the conversion, if sample/rate changes
> ost->reformat_ctx is used, I have no idea why we have this distinction
> but if I try to make the resample_ctx handle the sample/rate
> resampling I get a regression in fate-acodec-pcm.
> 
> So I suggest to apply the patch in the present form, I don't volunteer
> to fix this convoluted logic (which is possibly due to the sucky audio
> API).
> -- 
> FFmpeg = Fostering & Frightening Murdering Plastic Evangelical Game

> From a5903bed2287631db909bac7710e8cda77f0d029 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> Date: Mon, 22 Nov 2010 01:42:11 +0100
> Subject: [PATCH] Fix encoding when the input audio format/rate/channels changes during
>  transcoding.
> 
> Fix issue #2292.

Ping. I'll apply in two days if I see no comments.

Further work should be addressed to the audio API revamp (so please
have a look to the various audio conversion API threads).
-- 
FFmpeg = Formidable and Fierce Minimalistic Pitiful Enlightening Guide



More information about the ffmpeg-devel mailing list