Message ID | 20171002162638.5932-1-jamrial@gmail.com |
---|---|
State | Accepted |
Headers | show |
On Mon, 2 Oct 2017, James Almer wrote: > Signed-off-by: James Almer <jamrial@gmail.com> > --- > Untested. Tested and works. > > libavdevice/decklink_dec.cpp | 11 +++++------ > 1 file changed, 5 insertions(+), 6 deletions(-) > > diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp > index 8a14094474..d8c624aa5d 100644 > --- a/libavdevice/decklink_dec.cpp > +++ b/libavdevice/decklink_dec.cpp > @@ -458,16 +458,15 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt) > av_log(q->avctx, AV_LOG_WARNING, "Decklink input buffer overrun!\n"); > return -1; > } > - /* duplicate the packet */ > - if (av_dup_packet(pkt) < 0) { > - return -1; > - } > > - pkt1 = (AVPacketList *)av_malloc(sizeof(AVPacketList)); > + pkt1 = (AVPacketList *)av_mallocz(sizeof(AVPacketList)); > if (!pkt1) { > return -1; > } > - pkt1->pkt = *pkt; > + if (av_packet_ref(&pkt1->pkt, pkt) < 0) { > + return -1; > + } > + av_packet_unref(pkt); > pkt1->next = NULL; > > pthread_mutex_lock(&q->mutex); LGTM, thanks. Marton
On Mon, 2 Oct 2017, Marton Balint wrote: > > > On Mon, 2 Oct 2017, James Almer wrote: > >> Signed-off-by: James Almer <jamrial@gmail.com> >> --- >> Untested. > > Tested and works. > >> >> libavdevice/decklink_dec.cpp | 11 +++++------ >> 1 file changed, 5 insertions(+), 6 deletions(-) >> >> diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp >> index 8a14094474..d8c624aa5d 100644 >> --- a/libavdevice/decklink_dec.cpp >> +++ b/libavdevice/decklink_dec.cpp >> @@ -458,16 +458,15 @@ static int avpacket_queue_put(AVPacketQueue *q, > AVPacket *pkt) >> av_log(q->avctx, AV_LOG_WARNING, "Decklink input buffer > overrun!\n"); >> return -1; >> } >> - /* duplicate the packet */ >> - if (av_dup_packet(pkt) < 0) { >> - return -1; >> - } >> >> - pkt1 = (AVPacketList *)av_malloc(sizeof(AVPacketList)); >> + pkt1 = (AVPacketList *)av_mallocz(sizeof(AVPacketList)); >> if (!pkt1) { >> return -1; >> } >> - pkt1->pkt = *pkt; >> + if (av_packet_ref(&pkt1->pkt, pkt) < 0) { On second thought you should free pkt1 and unref pkt here. >> + return -1; >> + } >> + av_packet_unref(pkt); >> pkt1->next = NULL; >> >> pthread_mutex_lock(&q->mutex); > > LGTM, thanks. Otherwise LGTM :) Thanks, Marton
On 10/2/2017 2:27 PM, Marton Balint wrote: > > > On Mon, 2 Oct 2017, Marton Balint wrote: > >> >> >> On Mon, 2 Oct 2017, James Almer wrote: >> >>> Signed-off-by: James Almer <jamrial@gmail.com> >>> --- >>> Untested. >> >> Tested and works. >> >>> >>> libavdevice/decklink_dec.cpp | 11 +++++------ >>> 1 file changed, 5 insertions(+), 6 deletions(-) >>> >>> diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp >>> index 8a14094474..d8c624aa5d 100644 >>> --- a/libavdevice/decklink_dec.cpp >>> +++ b/libavdevice/decklink_dec.cpp >>> @@ -458,16 +458,15 @@ static int avpacket_queue_put(AVPacketQueue *q, >> AVPacket *pkt) >>> av_log(q->avctx, AV_LOG_WARNING, "Decklink input buffer >> overrun!\n"); >>> return -1; >>> } >>> - /* duplicate the packet */ >>> - if (av_dup_packet(pkt) < 0) { >>> - return -1; >>> - } >>> >>> - pkt1 = (AVPacketList *)av_malloc(sizeof(AVPacketList)); >>> + pkt1 = (AVPacketList *)av_mallocz(sizeof(AVPacketList)); >>> if (!pkt1) { >>> return -1; >>> } >>> - pkt1->pkt = *pkt; >>> + if (av_packet_ref(&pkt1->pkt, pkt) < 0) { > > On second thought you should free pkt1 and unref pkt here. pkt1 is a just-allocated AVPacketList. Why would i free it right after allocating it? Also, pkt is being unref'd right below. > >>> + return -1; >>> + } >>> + av_packet_unref(pkt); >>> pkt1->next = NULL; >>> >>> pthread_mutex_lock(&q->mutex); >> >> LGTM, thanks. > > Otherwise LGTM :) > > Thanks, > Marton > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
On 10/2/2017 2:47 PM, James Almer wrote: > On 10/2/2017 2:27 PM, Marton Balint wrote: >> >> >> On Mon, 2 Oct 2017, Marton Balint wrote: >> >>> >>> >>> On Mon, 2 Oct 2017, James Almer wrote: >>> >>>> Signed-off-by: James Almer <jamrial@gmail.com> >>>> --- >>>> Untested. >>> >>> Tested and works. >>> >>>> >>>> libavdevice/decklink_dec.cpp | 11 +++++------ >>>> 1 file changed, 5 insertions(+), 6 deletions(-) >>>> >>>> diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp >>>> index 8a14094474..d8c624aa5d 100644 >>>> --- a/libavdevice/decklink_dec.cpp >>>> +++ b/libavdevice/decklink_dec.cpp >>>> @@ -458,16 +458,15 @@ static int avpacket_queue_put(AVPacketQueue *q, >>> AVPacket *pkt) >>>> av_log(q->avctx, AV_LOG_WARNING, "Decklink input buffer >>> overrun!\n"); >>>> return -1; >>>> } >>>> - /* duplicate the packet */ >>>> - if (av_dup_packet(pkt) < 0) { >>>> - return -1; >>>> - } >>>> >>>> - pkt1 = (AVPacketList *)av_malloc(sizeof(AVPacketList)); >>>> + pkt1 = (AVPacketList *)av_mallocz(sizeof(AVPacketList)); >>>> if (!pkt1) { >>>> return -1; >>>> } >>>> - pkt1->pkt = *pkt; >>>> + if (av_packet_ref(&pkt1->pkt, pkt) < 0) { >> >> On second thought you should free pkt1 and unref pkt here. > > pkt1 is a just-allocated AVPacketList. Why would i free it right after > allocating it? > Also, pkt is being unref'd right below. Nevermind, just realized you were talking about the failure path. Fixed and pushed, thanks! > >> >>>> + return -1; >>>> + } >>>> + av_packet_unref(pkt); >>>> pkt1->next = NULL; >>>> >>>> pthread_mutex_lock(&q->mutex); >>> >>> LGTM, thanks. >> >> Otherwise LGTM :) >> >> Thanks, >> Marton >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp index 8a14094474..d8c624aa5d 100644 --- a/libavdevice/decklink_dec.cpp +++ b/libavdevice/decklink_dec.cpp @@ -458,16 +458,15 @@ static int avpacket_queue_put(AVPacketQueue *q, AVPacket *pkt) av_log(q->avctx, AV_LOG_WARNING, "Decklink input buffer overrun!\n"); return -1; } - /* duplicate the packet */ - if (av_dup_packet(pkt) < 0) { - return -1; - } - pkt1 = (AVPacketList *)av_malloc(sizeof(AVPacketList)); + pkt1 = (AVPacketList *)av_mallocz(sizeof(AVPacketList)); if (!pkt1) { return -1; } - pkt1->pkt = *pkt; + if (av_packet_ref(&pkt1->pkt, pkt) < 0) { + return -1; + } + av_packet_unref(pkt); pkt1->next = NULL; pthread_mutex_lock(&q->mutex);
Signed-off-by: James Almer <jamrial@gmail.com> --- Untested. libavdevice/decklink_dec.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)