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

Reimar Döffinger Reimar.Doeffinger
Wed Dec 1 18:20:18 CET 2010


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.
There's a format the decoder outputs (1).
There's a format that the resampler expects as output (2).
There's a format that the resampler outputs (3).
There's a format that the encoder expects (4).

One checks whether channel count differs between (1)
and (4) and the other check is if they differ between
(1) and (2). There is no relation between those.

> btw, it might make more sense to have some function like sws_getCachedContext()

That as basically the original suggestion, but doing it properly
is quite a mess and overkill for just this use-case, at least
it seemed like it.
Of course I don't mind it if someone wants, but a half-working
public API function is not ok.



More information about the ffmpeg-devel mailing list