[FFmpeg-devel] [PATCH+RFC] AVFrame for audio
Justin Ruggles
justin.ruggles
Sun Oct 31 19:58:11 CET 2010
Hi,
Justin Ruggles wrote:
> Michael Niedermayer wrote:
>
>> On Thu, Oct 28, 2010 at 06:58:11PM -0400, Justin Ruggles wrote:
>>> Michael Niedermayer wrote:
>>>
>>>> On Wed, Oct 27, 2010 at 10:13:10PM -0400, Justin Ruggles wrote:
>>>>> Michael Niedermayer wrote:
>>>>> doc/APIchanges | 9 ++
>>>>> libavcodec/avcodec.h | 100 ++++++++++++++++++++++++++++++--
>>>>> libavcodec/pcm.c | 41 +++++++++++--
>>>>> libavcodec/utils.c | 157 ++++++++++++++++++++++++++++++++++++++++++++-------
>>>>> 4 files changed, 275 insertions(+), 32 deletions(-)
>>>>> 39eb7fb791089c0822e3f87d3226b49131563a72 avcodec_decode_audio4.patch
>>>>> diff --git a/doc/APIchanges b/doc/APIchanges
>>>>> index 4155d32..a39d9fd 100644
>>>>> --- a/doc/APIchanges
>>>>> +++ b/doc/APIchanges
>>>>> @@ -13,6 +13,15 @@ libavutil: 2009-03-08
>>>>>
>>>>> API changes, most recent first:
>>>>>
>>>>> +2010-XX-XX - rXXXXX - lavc 52.92.0 - AVFrame and avcodec_decode_audio
>>>>> + Add nb_samples field to AVFrame.
>>>>> + Add user_buffer, user_buffer_size, and user_buffer_in_use fields to AVCodecContext.
>>>>> + Deprecate AVCODEC_MAX_AUDIO_FRAME_SIZE.
>>>>> + Deprecate avcodec_decode_audio3() in favor of avcodec_decode_audio4().
>>>>> + avcodec_decode_audio4() writes output samples to an AVFrame, which gives the
>>>>> + audio decoders the ability to use get/release/reget_buffer() to get an
>>>>> + output buffer.
>>>>> +
>>>>> 2010-10-10 - r25441 - lavfi 1.49.0 - AVFilterLink.time_base
>>>>> Add time_base field to AVFilterLink.
>>>>>
>>>>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>>>>> index 4bddbaa..1aa1c8c 100644
>>>>> --- a/libavcodec/avcodec.h
>>>>> +++ b/libavcodec/avcodec.h
>>>>> @@ -31,7 +31,7 @@
>>>>> #include "libavutil/cpu.h"
>>>>>
>>>>> #define LIBAVCODEC_VERSION_MAJOR 52
>>>>> -#define LIBAVCODEC_VERSION_MINOR 92
>>>>> +#define LIBAVCODEC_VERSION_MINOR 93
>>>>> #define LIBAVCODEC_VERSION_MICRO 0
>>>>>
>>>>> #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
>>>>> @@ -467,8 +467,10 @@ enum SampleFormat {
>>>>> CH_FRONT_LEFT_OF_CENTER|CH_FRONT_RIGHT_OF_CENTER)
>>>>> #define CH_LAYOUT_STEREO_DOWNMIX (CH_STEREO_LEFT|CH_STEREO_RIGHT)
>>>>>
>>>>> +#if FF_API_AUDIO_OLD
>>>>> /* in bytes */
>>>>> #define AVCODEC_MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
>>>>> +#endif
>>>>>
>>>>> /**
>>>>> * Required number of additionally allocated bytes at the end of the input bitstream for decoding.
>>>>> @@ -988,7 +990,13 @@ typedef struct AVPanScan{
>>>>> * - decoding: Set by libavcodec\
>>>>> */\
>>>>> void *hwaccel_picture_private;\
>>>>> -
>>>>> +\
>>>>> + /**\
>>>>> + * number of audio samples (per channel) described by this frame\
>>>>> + * - encoding: Set by user.\
>>>>> + * - decoding: Set by libavcodec.\
>>>>> + */\
>>>>> + int nb_samples;\
>>>>>
>>>>> #define FF_QSCALE_TYPE_MPEG1 0
>>>>> #define FF_QSCALE_TYPE_MPEG2 1
>>>>> @@ -2744,6 +2752,33 @@ typedef struct AVCodecContext {
>>>>> * - decoding: unused
>>>>> */
>>>>> int lpc_passes;
>>>>> +
>>>>> + /**
>>>>> + * User-allocated audio decoder output buffer & buffer size
>>>>> + * If user_buffer is non-NULL and is large enough,
>>>>> + * avcodec_default_get_buffer() may user it as an internal buffer instead
>>>>> + * of allocating its own. This only works with decoders that support
>>>>> + * CODEC_CAP_DR1. If the decoder uses this buffer, it will set the value
>>>>> + * to NULL.
>>>>> + *
>>>>> + * @note The user may not use this field when using avcodec_decode_audio3()
>>>>> + * or avcodec_decode_audio2().
>>>> I dont see why we need such special casing. *samples could be passed in the new
>>>> api like it is in the old
>>> The old API already has the samples buffer passed directly. Why should
>>> the old API be changed to accept user_buffer as an alternative to
>>> *samples? Do they have to match? If not, which takes priority? This
>>> would require added documentation to an old API. That seems more
>>> complexity than necessary when the ability to supply a direct buffer is
>>> already there.
>> you misunderstand
>> why is the new api having it passed over AVCodecContext and the old over an
>> function argument (in the sense why dont you change the new api to also take
>> a argument for that?) maybe i miss something but this seems to be simpler
>
> Ah, thanks for clarifying.
>
> The new API doesn't need it. The old API needs it in order to avoid
> memcpy. In the new API, if the user wants a direct buffer, she can
> override get/release_buffer().
>
> So how about documenting user_buffer/_size for internal libavcodec use
> only? We only really need it for backwards compatibility. The fields
> and related code could also be deprecated along with
> avcodec_decode_audio3() so when the function goes away, so does the
> compatibility code.
In case this is ok, here is a patch+RFC for it.
-Justin
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: avcodec_decode_audio4.patch
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20101031/93865860/attachment.txt>
More information about the ffmpeg-devel
mailing list