[FFmpeg-devel] [PATCH 2/5 V2] avcodec: add an AV1 frame merge bitstream filter

James Almer jamrial at gmail.com
Tue Nov 12 03:12:47 EET 2019


On 11/11/2019 8:36 PM, James Almer wrote:
>>> +    for (i = 0; i < frag->nb_units; i++) {
>>> +        if (i && frag->units[i].type == AV1_OBU_TEMPORAL_DELIMITER) {
>>> +            av_log(bsf, AV_LOG_ERROR, "Temporal Delimiter in the middle of a packet.\n");
>>> +            err = AVERROR_INVALIDDATA;
>>> +            goto fail;
>>> +        }
>>> +        err = ff_cbs_insert_unit_content(ctx->cbc, tu, -1, frag->units[i].type,
>>> +                                         frag->units[i].content, frag->units[i].content_ref);
>> You make new references to content and then immediately thereafter
>> unref the old ones. How about adding a function that moves a unit (or
>> several units at once) from one fragment to another?
> A new function that moves units sounds good. Shouldn't be hard to
> implement either, i think.

So a unit move function would require a memcpy for the unit from one
fragment to another, a memset to 0 on the source unit, then a call to
ff_cbs_delete_unit() which memmoves the remaining units to fill the gap
created by the removed one, if any. I don't know if it's that much
better than this current implementation creating a new AVBufferRef per
unit, then wiping the whole source fragment in one go.


More information about the ffmpeg-devel mailing list