X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fav1_parser.c;h=6a76ffb7bc35a1ae9ce1148bce9f4f85cf2a48dd;hb=4390573c44a47e0bed4790a45934006df7ee1e2f;hp=cd426a2b0f7839eac4a1c30b812370df758e18f7;hpb=1bdbc50bf4379d3993b47b8510045e4d236de555;p=ffmpeg diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c index cd426a2b0f7..6a76ffb7bc3 100644 --- a/libavcodec/av1_parser.c +++ b/libavcodec/av1_parser.c @@ -73,7 +73,7 @@ static int av1_parser_parse(AVCodecParserContext *ctx, if (avctx->extradata_size && !s->parsed_extradata) { s->parsed_extradata = 1; - ret = ff_cbs_read(s->cbc, td, avctx->extradata, avctx->extradata_size); + ret = ff_cbs_read_extradata_from_codec(s->cbc, td, avctx); if (ret < 0) { av_log(avctx, AV_LOG_WARNING, "Failed to parse extradata.\n"); } @@ -99,7 +99,6 @@ static int av1_parser_parse(AVCodecParserContext *ctx, CodedBitstreamUnit *unit = &td->units[i]; AV1RawOBU *obu = unit->content; AV1RawFrameHeader *frame; - int frame_type; if (unit->type == AV1_OBU_FRAME) frame = &obu->obu.frame.header; @@ -111,30 +110,15 @@ static int av1_parser_parse(AVCodecParserContext *ctx, if (obu->header.spatial_id > 0) continue; - if (frame->show_existing_frame) { - AV1ReferenceFrameState *ref = &av1->ref[frame->frame_to_show_map_idx]; - - if (!ref->valid) { - av_log(avctx, AV_LOG_ERROR, "Invalid reference frame\n"); - goto end; - } - - ctx->width = ref->frame_width; - ctx->height = ref->frame_height; - frame_type = ref->frame_type; - - ctx->key_frame = 0; - } else if (!frame->show_frame) { + if (!frame->show_frame && !frame->show_existing_frame) continue; - } else { - ctx->width = av1->frame_width; - ctx->height = av1->frame_height; - frame_type = frame->frame_type; - ctx->key_frame = frame_type == AV1_FRAME_KEY; - } + ctx->width = frame->frame_width_minus_1 + 1; + ctx->height = frame->frame_height_minus_1 + 1; - switch (frame_type) { + ctx->key_frame = frame->frame_type == AV1_FRAME_KEY && !frame->show_existing_frame; + + switch (frame->frame_type) { case AV1_FRAME_KEY: case AV1_FRAME_INTRA_ONLY: ctx->pict_type = AV_PICTURE_TYPE_I; @@ -171,8 +155,6 @@ static int av1_parser_parse(AVCodecParserContext *ctx, color->transfer_characteristics == AVCOL_TRC_IEC61966_2_1) ctx->format = pix_fmts_rgb[color->high_bitdepth + color->twelve_bit]; - avctx->pix_fmt = ctx->format; - avctx->profile = seq->seq_profile; avctx->level = seq->seq_level_idx[0]; @@ -181,12 +163,6 @@ static int av1_parser_parse(AVCodecParserContext *ctx, avctx->color_trc = (enum AVColorTransferCharacteristic) color->transfer_characteristics; avctx->color_range = color->color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; - if (ctx->width != avctx->width || ctx->height != avctx->height) { - ret = ff_set_dimensions(avctx, ctx->width, ctx->height); - if (ret < 0) - goto end; - } - if (avctx->framerate.num) avctx->time_base = av_inv_q(av_mul_q(avctx->framerate, (AVRational){avctx->ticks_per_frame, 1})); @@ -215,7 +191,7 @@ static av_cold int av1_parser_init(AVCodecParserContext *ctx) if (ret < 0) return ret; - s->cbc->decompose_unit_types = (CodedBitstreamUnitType *)decompose_unit_types; + s->cbc->decompose_unit_types = decompose_unit_types; s->cbc->nb_decompose_unit_types = FF_ARRAY_ELEMS(decompose_unit_types); return 0;