[MPlayer-dev-eng] [PATCH] ae_lavc: set nBlockAlign like libavformat

Reimar Döffinger Reimar.Doeffinger at gmx.de
Fri Sep 23 20:18:10 CEST 2011


On Sun, Aug 28, 2011 at 08:22:42PM +0200, Nicolas George wrote:
> Le decadi 10 fructidor, an CCXIX, Reimar Döffinger a écrit :
> > The muxer mostly takes the values as they come from the demuxer, sight
> > unseen.
> > This works with the mkv demuxer that keeps the dwScale/dwRate as they
> > are, based on bitrate.
> > For demuxer lavf I guess there are two ways to fix it: Also keeping
> > dwScale/dwRate (will break other things) or by using the same logic
> > as you suggest for ae_lavc - but then that IMO should not be duplicated
> > but go into some shared file.
> 
> For stream copy from demux_lavf, the base problem is the same (AVI has a
> mess of fields with overlapping semantic that are used chaotically by
> various implementations) but the exact problem is different: the culprit
> here is dwSampleSize, not nBlockAlign.
> 
> You can see how ffmpeg handles the problem in ffmpeg.c near lines 2275 (and
> do not be fooled, icodec->block_align is dwSampleSize, not nBlockAlign).
> 
> The attached patch does the same thing to mencoder.c. It fixes stream copy
> for the sample case I made, with AC3. I am downloading the sample from bug
> #1958 you mentioned yesterday (AC3) to see if it fixes it.
> 
> The MP3 case does not work very well, there is a different problem there,
> with a lot of "1 duplicate frame" that should not be there. But there is a
> lot I do not understand in the AV-sync system of mencoder (I spent half the
> day trying to understand why ae_lame causes three frames to be skipped while
> ae_lavc does not, in vain).
> 
> This is not perfect, but it is still an improvement.
> 
> I also attach a slightly updated version of the patch for ae_lavc.
> 
> Regards,
> 
> -- 
>   Nicolas George

> From f56edf73f5e38e88d7b0750dacbfd7796e825304 Mon Sep 17 00:00:00 2001
> From: Nicolas George <nicolas.george at normalesup.org>
> Date: Sun, 28 Aug 2011 19:46:39 +0200
> Subject: [PATCH 3/3] mencoder: set dwSampleSize to 0 for MP3 and AC3 stream
>  copy.
> 
> This fixes stream copy from demuxers that set dwSampleSize, especially lavf.
> The hack is similar to the one in ffmpeg.c near line 2275.
> ---
>  libmpdemux/demuxer.c |    1 +
>  mencoder.c           |    3 +++
>  2 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c
> index d3f0395..8e3043c 100644
> --- a/libmpdemux/demuxer.c
> +++ b/libmpdemux/demuxer.c
> @@ -17,6 +17,7 @@
>   * with MPlayer; if not, write to the Free Software Foundation, Inc.,
>   * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
>   */
> +#include <execinfo.h>
>  
>  #include <stdio.h>
>  #include <stdlib.h>

That does not belong in that I guess.
But otherwise since A-V sync seems quite broken currently, could
you just go ahead and apply these?
I won't be able to come up with anything much better I expect.

> diff --git a/mencoder.c b/mencoder.c
> index 9efeb75..65a8c8d 100644
> --- a/mencoder.c
> +++ b/mencoder.c
> @@ -1098,6 +1098,9 @@ case ACODEC_COPY:
>  	mux_a->h.dwScale=mux_a->h.dwSampleSize;
>  	mux_a->h.dwRate=mux_a->wf->nAvgBytesPerSec;
>      }
> +    if ((mux_a->wf->wFormatTag ==   0x55 /* MP3 */ && mux_a->h.dwSampleSize == 1) ||
> +        (mux_a->wf->wFormatTag == 0x2000 /* AC3 */))

Hm, those have a lot more possible tags, this should really look up the
codecs.conf entry or some such I'd say.


More information about the MPlayer-dev-eng mailing list