[FFmpeg-devel] [PATCH]lavc/amrwbdec: Do not ignore NO_DATA frames
James Almer
jamrial at gmail.com
Sun Apr 5 18:10:25 EEST 2020
On 4/5/2020 12:07 PM, Carl Eugen Hoyos wrote:
> Am So., 5. Apr. 2020 um 16:45 Uhr schrieb James Almer <jamrial at gmail.com>:
>>
>> On 1/30/2019 10:47 AM, Carl Eugen Hoyos wrote:
>>> 2019-01-29 22:47 GMT+01:00, Carl Eugen Hoyos <ceffmpeg at gmail.com>:
>>>> Hi!
>>>>
>>>> Attached patch fixes decoding NO_DATA amr-wb frames.
>>>
>>> Now with patch.
>>>
>>> Carl Eugen
>>
>>> From 0a8c318c49ec358ad646ed601588154cf7d7da37 Mon Sep 17 00:00:00 2001
>>> From: Carl Eugen Hoyos <ceffmpeg at gmail.com>
>>> Date: Tue, 29 Jan 2019 22:46:37 +0100
>>> Subject: [PATCH] lavc/amrwbdec: Do not ignore NO_DATA frames.
>>>
>>> Fixes the actual output duration of the sample in ticket #7113.
>>> ---
>>> libavcodec/amrwbdata.h | 2 +-
>>> libavcodec/amrwbdec.c | 9 ++++++++-
>>> 2 files changed, 9 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/libavcodec/amrwbdata.h b/libavcodec/amrwbdata.h
>>> index 8a8cbfd..95c0aaa 100644
>>> --- a/libavcodec/amrwbdata.h
>>> +++ b/libavcodec/amrwbdata.h
>>> @@ -1884,7 +1884,7 @@ static const float lpf_7_coef[31] = { // low pass, 7kHz cutoff
>>> /** Core frame sizes in each mode */
>>> static const uint16_t cf_sizes_wb[] = {
>>> 132, 177, 253, 285, 317, 365, 397, 461, 477,
>>> - 40 /// SID/comfort noise frame
>>> + 40, 0, 0, 0, 0, 0, 0
>>> };
>>>
>>> #endif /* AVCODEC_AMRWBDATA_H */
>>> diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
>>> index 47fe7eb..b488a5d 100644
>>> --- a/libavcodec/amrwbdec.c
>>> +++ b/libavcodec/amrwbdec.c
>>> @@ -1119,12 +1119,19 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data,
>>> buf_out = (float *)frame->data[0];
>>>
>>> header_size = decode_mime_header(ctx, buf);
>>> + 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;
>>
>> You can use av_samples_set_silence() for this.
>
> (Is memset(0) valid for floats?)
I would hope so, considering this function is used in half a dozen
filters, and the core encoding lavc code...
>
> Patch sent, thank you!
>
> Carl Eugen
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>
More information about the ffmpeg-devel
mailing list