[FFmpeg-devel] [PATCH]lavc/amrwbdec: Use av_samples_set_silence()

James Almer jamrial at gmail.com
Sun Apr 5 18:14:39 EEST 2020


On 4/5/2020 12:06 PM, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch simplifies a funtion in the amrwb decoder, as suggested by James.
> 
> Please comment, Carl Eugen

> From 91d50f466728d7d0680882f6f63217f39808c2af Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <ceffmpeg at gmail.com>
> Date: Sun, 5 Apr 2020 17:04:44 +0200
> Subject: [PATCH] lavc/amrwbdec: Use av_samples_set_silence().
> 
> Suggested-by: James Almer
> ---
>  libavcodec/amrwbdec.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
> index b488a5d3c7..1d4f00e717 100644
> --- a/libavcodec/amrwbdec.c
> +++ b/libavcodec/amrwbdec.c
> @@ -1122,8 +1122,7 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data,
>      expected_fr_size = ((cf_sizes_wb[ctx->fr_cur_mode] + 7) >> 3) + 1;
>  
>      if (ctx->fr_cur_mode == NO_DATA) {
> -        for (i = 0; i < frame->nb_samples; i++)
> -            buf_out[i] = 0.f;
> +        av_samples_set_silence(&buf_out, 0, frame->nb_samples, 1, AV_SAMPLE_FMT_FLT);

Should be frame->data (or frame->extended_data), not &buf_out. The
function expects an uint8_t**, not float**.

LGTM otherwise.

>          *got_frame_ptr = 1;
>          return expected_fr_size;
>      }
> -- 
> 2.24.1
> 


More information about the ffmpeg-devel mailing list