]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/av1_parser.c
avcodec: Move all AVCodecParser.split functions to remove_extradata_bsf
[ffmpeg] / libavcodec / av1_parser.c
index 1b9868d364bb66c7c702f799eaf25792a645c163..b6c8004ee3d814632bf4eb7804ec1042f02c8ccc 100644 (file)
@@ -20,7 +20,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "av1_parse.h"
+#include "libavutil/avassert.h"
 #include "cbs.h"
 #include "cbs_av1.h"
 #include "internal.h"
@@ -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");
         }
@@ -110,7 +110,7 @@ static int av1_parser_parse(AVCodecParserContext *ctx,
         if (obu->header.spatial_id > 0)
             continue;
 
-        if (!frame->show_frame)
+        if (!frame->show_frame && !frame->show_existing_frame)
             continue;
 
         ctx->width  = frame->frame_width_minus_1 + 1;
@@ -155,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];
 
@@ -165,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}));
 
@@ -199,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;
@@ -213,33 +205,10 @@ static void av1_parser_close(AVCodecParserContext *ctx)
     ff_cbs_close(&s->cbc);
 }
 
-static int av1_parser_split(AVCodecContext *avctx,
-                            const uint8_t *buf, int buf_size)
-{
-    AV1OBU obu;
-    const uint8_t *ptr = buf, *end = buf + buf_size;
-
-    while (ptr < end) {
-        int len = ff_av1_extract_obu(&obu, ptr, buf_size, avctx);
-        if (len < 0)
-            break;
-
-        if (obu.type == AV1_OBU_FRAME_HEADER ||
-            obu.type == AV1_OBU_FRAME) {
-            return ptr - buf;
-        }
-        ptr      += len;
-        buf_size -= len;
-    }
-
-    return 0;
-}
-
-AVCodecParser ff_av1_parser = {
+const AVCodecParser ff_av1_parser = {
     .codec_ids      = { AV_CODEC_ID_AV1 },
     .priv_data_size = sizeof(AV1ParseContext),
     .parser_init    = av1_parser_init,
     .parser_close   = av1_parser_close,
     .parser_parse   = av1_parser_parse,
-    .split          = av1_parser_split,
 };