Commit 4e2bef6a authored by James Almer's avatar James Almer

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: 's avatarJames Almer <jamrial@gmail.com>
parent 6c2f8663
......@@ -939,6 +939,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:
{
......@@ -1081,6 +1083,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:
{
......
......@@ -441,7 +441,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];
} CodedBitstreamAV1Context;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment