[FFmpeg-devel] [PATCH] avcodec/libdav1d: fix setting AVFrame reordered_opaque

Andrey Semashev andrey.semashev at gmail.com
Fri Oct 18 01:48:32 EEST 2019


Please, ignore this patch.

On 2019-10-18 01:44, James Almer wrote:
> On 10/17/2019 7:34 PM, Andrey Semashev wrote:
>> Actually reorder the values.
>>
>> Should effectively fix ticket #8300.
> 
> Not sure why you decided to send a modified patch by another dev, and
> with the author name changed, but that's not ok.
> 
>> ---
>>   libavcodec/libdav1d.c | 26 +++++++++++++++++++++++++-
>>   1 file changed, 25 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
>> index 8aa248e6cd..774e741db8 100644
>> --- a/libavcodec/libdav1d.c
>> +++ b/libavcodec/libdav1d.c
>> @@ -25,6 +25,7 @@
>>   #include "libavutil/mastering_display_metadata.h"
>>   #include "libavutil/imgutils.h"
>>   #include "libavutil/opt.h"
>> +#include "libavutil/mem.h"
>>   
>>   #include "avcodec.h"
>>   #include "decode.h"
>> @@ -164,6 +165,10 @@ static void libdav1d_data_free(const uint8_t *data, void *opaque) {
>>       av_buffer_unref(&buf);
>>   }
>>   
>> +static void libdav1d_user_data_free(const uint8_t *data, void *opaque) {
>> +    av_free(data);
> 
> This will generate a warning about dropped const qualifier.
> 
>> +}
>> +
>>   static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
>>   {
>>       Libdav1dContext *dav1d = c->priv_data;
>> @@ -179,6 +184,8 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
>>               return res;
>>   
>>           if (pkt.size) {
>> +            int64_t *reordered_opaque;
>> +
>>               res = dav1d_data_wrap(data, pkt.data, pkt.size, libdav1d_data_free, pkt.buf);
>>               if (res < 0) {
>>                   av_packet_unref(&pkt);
>> @@ -191,6 +198,22 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
>>   
>>               pkt.buf = NULL;
>>               av_packet_unref(&pkt);
>> +
>> +            reordered_opaque = av_malloc(sizeof(int64_t));
>> +
>> +            if (!reordered_opaque) {
>> +                dav1d_data_unref(data);
>> +                return AVERROR(ENOMEM);
>> +            }
>> +
>> +            *reordered_opaque = c->reordered_opaque;
>> +            res = dav1d_data_wrap_user_data(data, (const uint8_t *)reordered_opaque,
>> +                                            libdav1d_user_data_free, NULL);
>> +            if (res < 0) {
>> +                av_free(reordered_opaque);
>> +                dav1d_data_unref(data);
>> +                return res;
>> +            }
> 
> As i said, i don't want this done unconditionally. It's not going to be
> used in 99% of cases.
> 
>>           }
>>       }
>>   
>> @@ -260,7 +283,8 @@ static int libdav1d_receive_frame(AVCodecContext *c, AVFrame *frame)
>>       else
>>           frame->format = c->pix_fmt = pix_fmt[p->p.layout][p->seq_hdr->hbd];
>>   
>> -    frame->reordered_opaque = c->reordered_opaque;
>> +    if (p->m.user_data.data)
>> +        frame->reordered_opaque = *(int64_t *)p->m.user_data.data;
>>   
>>       // match timestamps and packet size
>>       frame->pts = frame->best_effort_timestamp = p->m.timestamp;
>>
> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
> 



More information about the ffmpeg-devel mailing list