[FFmpeg-devel] [PATCH v2] avcodec: add AV1 frame split bitstream filter

James Almer jamrial at gmail.com
Mon Mar 25 18:42:42 EET 2019


On 3/25/2019 12:29 PM, James Almer wrote:
> +        ret = ff_cbs_read_packet(s->cbc, td, s->buffer_pkt);
> +        if (ret < 0) {
> +            av_log(ctx, AV_LOG_ERROR, "Failed to parse temporal unit.\n");
> +            return ret;

> +    if (split) {
> +        AV1RawFrameHeader *frame = NULL;
> +        int cur_frame_type = -1, size = 0;
> +
> +        for (i = s->cur_frame_idx; i < td->nb_units; i++) {
> +            CodedBitstreamUnit *unit = &td->units[i];
> +
> +            size += unit->data_size;
> +            if (unit->type == AV1_OBU_FRAME) {
> +                AV1RawOBU *obu = unit->content;
> +
> +                if (frame) {
> +                    ret = AVERROR_INVALIDDATA;
> +                    goto fail;

> +            } else if (unit->type == AV1_OBU_FRAME_HEADER) {
> +                AV1RawOBU *obu = unit->content;
> +
> +                if (frame) {
> +                    ret = AVERROR_INVALIDDATA;
> +                    goto fail;

> +            } else if (unit->type == AV1_OBU_TILE_GROUP) {
> +                AV1RawOBU *obu = unit->content;
> +                AV1RawTileGroup *group = &obu->obu.tile_group;
> +
> +                if (!frame || cur_frame_type != AV1_OBU_FRAME_HEADER) {
> +                    ret = AVERROR_INVALIDDATA;
> +                    goto fail;

I'm not sure if we should abort and discard the packet in these cases,
or just pass it through.

In all these the Temporal Unit is invalid in some form (Orphaned Tile
Group OBUs, Frame Headers showing up when the Tile Groups from a
previous Frame Header were expected, etc), but maybe it should be left
to the decoder to decide what to do with them.

> +fail:
> +    if (ret < 0)
> +        av_packet_unref(out);
> +    av_packet_unref(s->buffer_pkt);
> +    ff_cbs_fragment_reset(s->cbc, td);
> +
> +    return ret;
> +}


More information about the ffmpeg-devel mailing list