[FFmpeg-devel] [PATCH 1/2 v2] avdevice/decklink_dec: remove av_dup_packet() usage
James Almer
jamrial at gmail.com
Mon Oct 2 21:17:04 EEST 2017
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 at 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 at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
More information about the ffmpeg-devel
mailing list