[libav-devel] [PATCH 5/6] lavc: Add private API to manipulate AVPacketList

Diego Biurrun diego at biurrun.de
Mon Sep 1 12:47:28 CEST 2014


On Sun, Aug 31, 2014 at 09:24:28PM +0200, Luca Barbato wrote:
> --- a/libavcodec/avpacket.c
> +++ b/libavcodec/avpacket.c
> @@ -393,3 +394,58 @@ void av_packet_rescale_ts(AVPacket *pkt, AVRational src_tb, AVRational dst_tb)
> +
> +int ff_packet_list_put(AVPacketList **head, AVPacketList **tail,
> +                       AVPacket *pkt)
> +{
> +    AVPacketList *pl = av_mallocz(sizeof(AVPacketList));
> +    int ret;

Doesn't this warn because of mixed declarations and statements?
I suggest swapping the lines.

> --- a/libavcodec/internal.h
> +++ b/libavcodec/internal.h
> @@ -200,4 +200,40 @@ int ff_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt);
>  
> +/*
> + * Append an AVPacket to the list creating a new reference
> + * to it.
> + *
> + * @param head List head
> + * @param tail List tail
> + * @param pkt  The packet being appended
> + * @return < 0 on failure and 0 on success.
> + */
> +int ff_packet_list_put(AVPacketList **head, AVPacketList **tail,
> +                       AVPacket *pkt);
> +
> +/**
> + * Remove the oldest AVPacket in the list and return it.
> + *
> + * @note The pkt will be overwritten completely. The caller
> + *       owns the packet and must unref it by itself.
> + *
> + * @see av_packet_unref av_packet_ref
> + *
> + * @param head List head.
> + * @param tail List tail.
> + * @param pkt  Pointer to an initialized AVPacket struct
> + * @return < 0 on failure and 0 on success.
> + */
> +int ff_packet_list_get(AVPacketList **head, AVPacketList **tail,
> +                       AVPacket *pkt);
> +
> +/**
> + * Wipe the list and unref all the packets in it.
> + *
> + * @param head List head.
> + * @param tail List tail.
> + */
> +void ff_packet_list_free(AVPacketList **head, AVPacketList **tail);

Speaking of "the list" in all these descriptions is confusing, the reader
does not yet know the signature of the function.  "A list of AVPackets"
or similar would be less confusing.

Drop the periods from parameter descriptions that are not sentences, you
only have periods on some of them anyway.

> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -1254,12 +1254,6 @@ typedef struct AVFormatContext {
>  
> -typedef struct AVPacketList {
> -    AVPacket pkt;
> -    struct AVPacketList *next;
> -} AVPacketList;

API change - where is the version and deprecation dance?

Diego


More information about the libav-devel mailing list