[FFmpeg-devel] [PATCH 1/6] avcodec/avpacket: add av_packet_make_ref()
Michael Niedermayer
michael at niedermayer.cc
Mon Mar 26 01:42:49 EEST 2018
On Sun, Mar 25, 2018 at 03:17:19PM -0300, James Almer wrote:
> On 3/25/2018 2:54 PM, Mark Thompson wrote:
> > On 25/03/18 05:03, James Almer wrote:
> >> It works as a drop in replacement for the deprecated av_dup_packet(),
> >> to ensure a packet is reference counted.
> >>
> >> Signed-off-by: James Almer <jamrial at gmail.com>
> >> ---
> >> Better name welcome.
> >>
> >> libavcodec/avcodec.h | 18 +++++++++++++++++-
> >> libavcodec/avpacket.c | 18 ++++++++++++++++++
> >> 2 files changed, 35 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> >> index 495242faf0..eb3fe4e428 100644
> >> --- a/libavcodec/avcodec.h
> >> +++ b/libavcodec/avcodec.h
> >> @@ -4360,7 +4360,7 @@ int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size);
> >> * @warning This is a hack - the packet memory allocation stuff is broken. The
> >> * packet is allocated if it was not really allocated.
> >> *
> >> - * @deprecated Use av_packet_ref
> >> + * @deprecated Use av_packet_ref or av_packet_make_ref
> >> */
> >> attribute_deprecated
> >> int av_dup_packet(AVPacket *pkt);
> >> @@ -4531,6 +4531,22 @@ void av_packet_move_ref(AVPacket *dst, AVPacket *src);
> >> */
> >> int av_packet_copy_props(AVPacket *dst, const AVPacket *src);
> >>
> >> +/**
> >> + * Ensure the data described by a given packet is reference counted.
> >> + *
> >> + * @note This function does no ensure that the reference will be writable.
> >
> > "does not ensure"
>
> Fixed.
>
> >
> >> + * Use av_packet_make_writable instead for that purpose.
> >> + *
> >> + * @see av_packet_ref
> >> + * @see av_packet_make_writable
> >> + *
> >> + * @param pkt packet whose data should be made reference counted.
> >> + *
> >> + * @return 0 on success, a negative AVERROR on error. On failure, the
> >> + * packet is unchanged.
> >> + */
> >> +int av_packet_make_ref(AVPacket *pkt);
> >
> > "make_ref" seems pretty confusing as a name - it sounds like it will always make a new reference somehow.
> >
> > Given the first line of the description, "ensure_refcounted"?
>
> av_packet_ensure_refcounted() seems a tad too long, IMO, especially for
> a function doing something as simple as this one as replacement for one
> called av_dup_packet().
>
> But if others agree I'll go with it.
maybe av_packet_make_refcounted() would be better than av_packet_ensure_refcounted()
as it is more similar to av_packet_make_writable()
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180326/066e182f/attachment.sig>
More information about the ffmpeg-devel
mailing list