[FFmpeg-devel] [PATCH v2 6/9] cbs_av1: Implement parser entrypoint

James Almer jamrial at gmail.com
Tue Apr 2 21:54:11 EEST 2019


On 4/1/2019 8:39 PM, Mark Thompson wrote:
> +static int cbs_av1_parse_obu(CodedBitstreamContext *ctx,
> +                             void *priv, int obu_type,
> +                             const uint8_t *data, size_t data_size)
> +{
> +    CodedBitstreamUnit unit;
> +    int err;
> +
> +    // These OBU types will not affect parsing.
> +    if (obu_type == AV1_OBU_METADATA  ||
> +        obu_type == AV1_OBU_TILE_LIST ||
> +        obu_type == AV1_OBU_PADDING)
> +        return 0;
> +
> +    unit = (CodedBitstreamUnit) {
> +        .type      = obu_type,
> +        .data      = (uint8_t*)data,
> +        .data_size = data_size,
> +    };
> +
> +    err = cbs_av1_read_unit(ctx, &unit);
> +    if (err >= 0 && priv) {
> +        AV1RawOBU *obu = unit.content;
> +        switch (obu->header.obu_type) {
> +        case AV1_OBU_FRAME_HEADER:
> +        case AV1_OBU_REDUNDANT_FRAME_HEADER:
> +            memcpy(priv, &obu->obu.frame_header,
> +                   sizeof(obu->obu.frame_header));
> +            break;
> +        case AV1_OBU_FRAME:
> +            memcpy(priv, &obu->obu.frame.header,
> +                   sizeof(obu->obu.frame.header));
> +            break;
> +        }

You should check that it's the frame with show_frame == 1 or
show_existing_frame == 1 before copying, otherwise this depends on
Temporal Units with several frames having the visible one at the end.
I don't think the spec enforces ordering in that regard.


More information about the ffmpeg-devel mailing list