]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/av1dec: add cur_frame.spatial_id and temporal_id to AV1Frame
authorJames Almer <jamrial@gmail.com>
Fri, 16 Oct 2020 16:34:31 +0000 (13:34 -0300)
committerJames Almer <jamrial@gmail.com>
Fri, 16 Oct 2020 16:34:31 +0000 (13:34 -0300)
Will be used by hwaccels, which have access to a frame's AV1RawFrameHeader but not
its AV1RawOBUHeader.

Signed-off-by: James Almer <jamrial@gmail.com>
libavcodec/av1dec.c
libavcodec/av1dec.h

index 6d00754fcb82001508ac41cc402fd9fd6f161533..a0a279d65bc154dedabdf518e1363c3e044deb41 100644 (file)
@@ -343,6 +343,7 @@ static void av1_frame_unref(AVCodecContext *avctx, AV1Frame *f)
     ff_thread_release_buffer(avctx, &f->tf);
     av_buffer_unref(&f->hwaccel_priv_buf);
     f->hwaccel_picture_private = NULL;
+    f->spatial_id = f->temporal_id = 0;
 }
 
 static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *src)
@@ -360,6 +361,8 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *s
         dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data;
     }
 
+    dst->spatial_id = src->spatial_id;
+    dst->temporal_id = src->temporal_id;
     dst->loop_filter_delta_enabled = src->loop_filter_delta_enabled;
     memcpy(dst->loop_filter_ref_deltas,
            src->loop_filter_ref_deltas,
@@ -670,6 +673,7 @@ static int av1_decode_frame(AVCodecContext *avctx, void *frame,
     for (int i = 0; i < s->current_obu.nb_units; i++) {
         CodedBitstreamUnit *unit = &s->current_obu.units[i];
         AV1RawOBU *obu = unit->content;
+        const AV1RawOBUHeader *header = &obu->header;
         av_log(avctx, AV_LOG_DEBUG, "Obu idx:%d, obu type:%d.\n", i, unit->type);
 
         switch (unit->type) {
@@ -766,6 +770,9 @@ static int av1_decode_frame(AVCodecContext *avctx, void *frame,
                 goto end;
             }
 
+            s->cur_frame.spatial_id  = header->spatial_id;
+            s->cur_frame.temporal_id = header->temporal_id;
+
             if (avctx->hwaccel) {
                 ret = avctx->hwaccel->start_frame(avctx, unit->data,
                                                   unit->data_size);
index 3604870299794573a18017cc9e197322862e6fb1..63c958ca53dd2188905e26c8d21f7b47fc020a00 100644 (file)
@@ -36,6 +36,9 @@ typedef struct AV1Frame {
     AVBufferRef *hwaccel_priv_buf;
     void *hwaccel_picture_private;
 
+    int temporal_id;
+    int spatial_id;
+
     uint8_t loop_filter_delta_enabled;
     int8_t  loop_filter_ref_deltas[AV1_NUM_REF_FRAMES];
     int8_t  loop_filter_mode_deltas[2];