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

Michael Niedermayer michaelni
Wed Dec 1 04:10:49 CET 2010


On Wed, Nov 24, 2010 at 12:10:47AM +0100, Stefano Sabatini wrote:
> On date Tuesday 2010-11-23 08:19:08 +0100, Reimar D?ffinger encoded:
> > On Mon, Nov 22, 2010 at 10:27:37AM +0100, Stefano Sabatini wrote:
> > > -    if (ost->audio_resample && !ost->resample) {
> > > +    resample_changed = ost->resample_sample_fmt  != dec->sample_fmt ||
> > > +                       ost->resample_channels    != dec->channels   ||
> > > +                       ost->resample_sample_rate != dec->sample_rate;
> > > +
> > > +    if (ost->audio_resample && !ost->resample || resample_changed) {
> > 
> > Doesn't gcc complain with a warning that it wants some extra () here?
> > Also I think this is not quite right, at the very least you'll keep
> > a resampling context around even if input and output are the same now
> > if they weren't before. I'm not sure if it will actually be used, but
> > I think it will, too.
> 
> See your point, updated.
> -- 
> FFmpeg = Frightening & Fantastic Mythic Puristic Easy Gangster

>  ffmpeg.c |   32 ++++++++++++++++++++++++++++++--
>  1 file changed, 30 insertions(+), 2 deletions(-)
> 8301839cce9ec2d9c2bbbcee1759acff9f872eb5  0001-Fix-encoding-when-the-input-audio-format-rate-channe.patch
> From 0bcec33a96f6398d1554ec2199e44b824a1e5bc0 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.
> ---
>  ffmpeg.c |   32 ++++++++++++++++++++++++++++++--
>  1 files changed, 30 insertions(+), 2 deletions(-)
> 
> diff --git a/ffmpeg.c b/ffmpeg.c
> index e58e7b5..0c2c5a0 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c

> @@ -295,6 +295,9 @@ typedef struct AVOutputStream {
>      /* audio only */
>      int audio_resample;
>      ReSampleContext *resample; /* for audio resampling */
> +    int resample_sample_fmt;
> +    int resample_channels;
> +    int resample_sample_rate;
>      int reformat_pair;
>      AVAudioConvert *reformat_ctx;
>      AVFifoBuffer *fifo;     /* for compression: one audio fifo per codec */

why is this needed?


> @@ -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


[...]
-- 
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://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101201/7db73311/attachment.pgp>



More information about the ffmpeg-devel mailing list