aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2019-11-17 21:08:56 -0300
committerJames Almer <jamrial@gmail.com>2020-01-06 11:56:04 -0300
commit1ad341851968bd41980531e4c00fb9592399cfcd (patch)
treee63d743a538057844f8e175812e389039a18604a
parent8ad03481f3c7b7108548a9f568cae21e9fd1bddf (diff)
downloadffmpeg-1ad341851968bd41980531e4c00fb9592399cfcd.tar.gz
avcodec/cbs_av1: keep separate reference frame state for reading and writing
In scearios where a Temporal Unit is written right after reading it using the same CBS context (av1_metadata, av1_frame_merge, etc), the reference frame state used by the writer must not be the state that's the result of the reader having already parsed the current frame in question. This fixes writing Switch frames, and frames using short ref signaling. Signed-off-by: James Almer <jamrial@gmail.com> (cherry picked from commit 4e2bef6a82b356772a5919c51c9be1530268bd79)
-rw-r--r--libavcodec/cbs_av1.c4
-rw-r--r--libavcodec/cbs_av1.h4
2 files changed, 7 insertions, 1 deletions
diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
index 80628c72ba..c680b34f17 100644
--- a/libavcodec/cbs_av1.c
+++ b/libavcodec/cbs_av1.c
@@ -978,6 +978,8 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
priv->spatial_id = 0;
}
+ priv->ref = (AV1ReferenceFrameState *)&priv->read_ref;
+
switch (obu->header.obu_type) {
case AV1_OBU_SEQUENCE_HEADER:
{
@@ -1114,6 +1116,8 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
td = NULL;
start_pos = put_bits_count(pbc);
+ priv->ref = (AV1ReferenceFrameState *)&priv->write_ref;
+
switch (obu->header.obu_type) {
case AV1_OBU_SEQUENCE_HEADER:
{
diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
index 0546623bea..144d1ebbf7 100644
--- a/libavcodec/cbs_av1.h
+++ b/libavcodec/cbs_av1.h
@@ -421,7 +421,9 @@ typedef struct CodedBitstreamAV1Context {
int tile_cols;
int tile_rows;
- AV1ReferenceFrameState ref[AV1_NUM_REF_FRAMES];
+ AV1ReferenceFrameState *ref;
+ AV1ReferenceFrameState read_ref[AV1_NUM_REF_FRAMES];
+ AV1ReferenceFrameState write_ref[AV1_NUM_REF_FRAMES];
// Write buffer.
uint8_t *write_buffer;