Quoting Andreas Unterweger (2015-01-25 12:32:44)
>  From 692ad7618c1cd0584f40e1fb08409844dd1cba11 Mon Sep 17 00:00:00 2001
> From: Andreas Unterweger <[email protected]>
> Date: Sun, 25 Jan 2015 12:17:22 +0100
> Subject: [PATCH 1/3] Fixed a sample format bug causing crashes when using the
>   internal AAC encoder
> 
> ---
>   doc/examples/transcode_aac.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c
> index 6206afe..6feb76c 100644
> --- a/doc/examples/transcode_aac.c
> +++ b/doc/examples/transcode_aac.c
> @@ -40,11 +40,11 @@
>   #include "libavresample/avresample.h"
>   
>   /** The output bit rate in kbit/s */
> -#define OUTPUT_BIT_RATE 48000
> +#define OUTPUT_BIT_RATE 96000
>   /** The number of output channels */
>   #define OUTPUT_CHANNELS 2
>   /** The audio sample output format */
> -#define OUTPUT_SAMPLE_FORMAT AV_SAMPLE_FMT_S16
> +#define OUTPUT_SAMPLE_FORMAT AV_SAMPLE_FMT_FLTP
>   
>   /**
>    * Convert an error code into a text message.
> @@ -178,9 +178,12 @@ static int open_output_file(const char *filename,
>       (*output_codec_context)->channels       = OUTPUT_CHANNELS;
>       (*output_codec_context)->channel_layout = 
> av_get_default_channel_layout(OUTPUT_CHANNELS);
>       (*output_codec_context)->sample_rate    = 
> input_codec_context->sample_rate;
> -    (*output_codec_context)->sample_fmt     = AV_SAMPLE_FMT_S16;
> +    (*output_codec_context)->sample_fmt     = OUTPUT_SAMPLE_FORMAT;
>       (*output_codec_context)->bit_rate       = OUTPUT_BIT_RATE;
>   
> +    /** Allow the use of the experimental AAC encoder */
> +    (*output_codec_context)->strict_std_compliance = 
> FF_COMPLIANCE_EXPERIMENTAL;
> +
>       /**
>        * Some container formats (like MP4) require global headers to be 
> present
>        * Mark the encoder so that it behaves accordingly.
> -- 
> 1.9.1
> 

At least for me, this does not crash. It properly terminates with an
error message.

Also, while this patch makes the example work with the internal encoder,
it will stop working with other AAC encoders that only support integer
input. The proper thing to do is pick a supported format from 
AVCodec.sample_fmts.

-- 
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to