[FFmpeg-devel] [PATCH] Check av_dup_packet() return code
wm4
nfxjfg at googlemail.com
Mon Feb 8 12:46:11 CET 2016
On Mon, 8 Feb 2016 00:33:15 +0100
Michael Niedermayer <michael at niedermayer.cc> wrote:
> On Wed, Feb 03, 2016 at 11:27:00PM +0100, Andreas Cadhalpun wrote:
> > On 03.02.2016 19:05, Michael Niedermayer wrote:
> > > Fixes: CID1338320
> > >
> > > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > > ---
> > > libavcodec/frame_thread_encoder.c | 4 +++-
> > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/libavcodec/frame_thread_encoder.c b/libavcodec/frame_thread_encoder.c
> > > index 04c9a0e..27ae356 100644
> > > --- a/libavcodec/frame_thread_encoder.c
> > > +++ b/libavcodec/frame_thread_encoder.c
> > > @@ -89,7 +89,9 @@ static void * attribute_align_arg worker(void *v){
> > > pthread_mutex_unlock(&c->buffer_mutex);
> > > av_frame_free(&frame);
> > > if(got_packet) {
> > > - av_dup_packet(pkt);
> > > + int ret2 = av_dup_packet(pkt);
> > > + if (ret >= 0 && ret2 < 0)
> > > + ret = ret2;
> > > } else {
> > > pkt->data = NULL;
> > > pkt->size = 0;
> > >
> >
> > Checking the return code this way is probably OK, but maybe you can also replace the
> > deprecated av_dup_packet with av_packet_ref while at it?
>
> what exactly do you suggest ?
>
> av_packet_ref() creates a reference, av_dup_packet() turns "reusable"
> packets into ref counted ones
> av_dup_packet() does nothing if the packet is already a ref counted
> one.
>
> i can not see a efficient and clean way to replace av_dup_packet()
> by av_packet_ref()
>
> if its ref counted already nothing needs to be done, if its not
> ref counted i would have to litterally reimplement av_dup_packet()
> and i dont even have a testcase for that, all cases seem to return
> ref counted packets
>
> i can remove av_dup_packet and put an assert there assuming that
> all packets will always be already ref counted (this might be true
> currently, i dont know, i also dont know if we always want this to
> be true in the future)
>
> I dont really want to always run av_packet_ref() over it just to
> unref it in the next line, which probably would work too
>
> [...]
It's deprecated?
More information about the ffmpeg-devel
mailing list