[FFmpeg-devel] [PATCH] avcodec/internal: move packet related functions to their own header

James Almer jamrial at gmail.com
Mon Jun 1 15:59:45 EEST 2020


On 6/1/2020 6:41 AM, Anton Khirnov wrote:
> Quoting James Almer (2020-05-30 18:44:26)
>> Signed-off-by: James Almer <jamrial at gmail.com>
>> ---
>> I included the new header directly in internal.h because the alternative was
>> including it in a hundred  or so files that call ff_alloc_packet2().
>>
>> If that's nonetheless prefered, i can go ahead with it.
> 
> I would prefer that, but won't force you or anyone to do such tedious
> work. So do as you like.
> 
>>
>>  libavcodec/internal.h        | 35 +-------------------
>>  libavcodec/packet_internal.h | 63 ++++++++++++++++++++++++++++++++++++
>>  2 files changed, 64 insertions(+), 34 deletions(-)
>>  create mode 100644 libavcodec/packet_internal.h
>>
>> diff --git a/libavcodec/internal.h b/libavcodec/internal.h
>> index 0e3415d69b..fa5052723b 100644
>> --- a/libavcodec/internal.h
>> +++ b/libavcodec/internal.h
>> @@ -32,6 +32,7 @@
>>  #include "libavutil/pixfmt.h"
>>  #include "avcodec.h"
>>  #include "config.h"
>> +#include "packet_internal.h"
>>  
>>  /**
>>   * The codec does not modify any global variables in the init function,
>> @@ -222,36 +223,6 @@ void ff_color_frame(AVFrame *frame, const int color[4]);
>>   */
>>  #define FF_MAX_EXTRADATA_SIZE ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE)
>>  
>> -/**
>> - * Check AVPacket size and/or allocate data.
>> - *
>> - * Encoders supporting AVCodec.encode2() can use this as a convenience to
>> - * ensure the output packet data is large enough, whether provided by the user
>> - * or allocated in this function.
>> - *
>> - * @param avctx   the AVCodecContext of the encoder
>> - * @param avpkt   the AVPacket
>> - *                If avpkt->data is already set, avpkt->size is checked
>> - *                to ensure it is large enough.
>> - *                If avpkt->data is NULL, a new buffer is allocated.
>> - *                avpkt->size is set to the specified size.
>> - *                All other AVPacket fields will be reset with av_init_packet().
>> - * @param size    the minimum required packet size
>> - * @param min_size This is a hint to the allocation algorithm, which indicates
>> - *                to what minimal size the caller might later shrink the packet
>> - *                to. Encoders often allocate packets which are larger than the
>> - *                amount of data that is written into them as the exact amount is
>> - *                not known at the time of allocation. min_size represents the
>> - *                size a packet might be shrunk to by the caller. Can be set to
>> - *                0. setting this roughly correctly allows the allocation code
>> - *                to choose between several allocation strategies to improve
>> - *                speed slightly.
>> - * @return        non negative on success, negative error code on failure
>> - */
>> -int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size);
> 
> I would consider this function encoder-related rather than
> packet-related, since it potentially modifies AVCodecContext state.

Ok, will see about moving this one to encode.h as part of the encoding
code rewriting set instead.

Thanks.


More information about the ffmpeg-devel mailing list