diff options
author | James Almer <jamrial@gmail.com> | 2020-07-07 22:29:46 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2020-07-16 21:49:27 -0300 |
commit | c91be9de4cf40c1bb5f9fe2117dd15e5f65b8437 (patch) | |
tree | 621a95aa03c4468c8b5fd95bd7ee9023733deeb2 | |
parent | db7dfb4a792d45c23898627951eddd90f3e41f13 (diff) | |
download | ffmpeg-c91be9de4cf40c1bb5f9fe2117dd15e5f65b8437.tar.gz |
avcodec/av1_metadata_bsf: Use separate contexts for reading/writing
Based on code from 235a5734e0
Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r-- | libavcodec/av1_metadata_bsf.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c index 3e3cbfd174..3158ba995b 100644 --- a/libavcodec/av1_metadata_bsf.c +++ b/libavcodec/av1_metadata_bsf.c @@ -33,7 +33,8 @@ enum { typedef struct AV1MetadataContext { const AVClass *class; - CodedBitstreamContext *cbc; + CodedBitstreamContext *input; + CodedBitstreamContext *output; CodedBitstreamFragment access_unit; int td; @@ -125,7 +126,7 @@ static int av1_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt) if (!side_data_size) return 0; - err = ff_cbs_read(ctx->cbc, frag, side_data, side_data_size); + err = ff_cbs_read(ctx->input, frag, side_data, side_data_size); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to read extradata from packet side data.\n"); return err; @@ -140,7 +141,7 @@ static int av1_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt) } } - err = ff_cbs_write_fragment_data(ctx->cbc, frag); + err = ff_cbs_write_fragment_data(ctx->output, frag); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side data.\n"); return err; @@ -171,7 +172,7 @@ static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) if (err < 0) goto fail; - err = ff_cbs_read_packet(ctx->cbc, frag, pkt); + err = ff_cbs_read_packet(ctx->input, frag, pkt); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n"); goto fail; @@ -216,7 +217,7 @@ static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *pkt) } } - err = ff_cbs_write_packet(ctx->cbc, pkt, frag); + err = ff_cbs_write_packet(ctx->output, pkt, frag); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n"); goto fail; @@ -239,12 +240,15 @@ static int av1_metadata_init(AVBSFContext *bsf) AV1RawOBU *obu; int err, i; - err = ff_cbs_init(&ctx->cbc, AV_CODEC_ID_AV1, bsf); + err = ff_cbs_init(&ctx->input, AV_CODEC_ID_AV1, bsf); + if (err < 0) + return err; + err = ff_cbs_init(&ctx->output, AV_CODEC_ID_AV1, bsf); if (err < 0) return err; if (bsf->par_in->extradata) { - err = ff_cbs_read_extradata(ctx->cbc, frag, bsf->par_in); + err = ff_cbs_read_extradata(ctx->input, frag, bsf->par_in); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n"); goto fail; @@ -259,7 +263,7 @@ static int av1_metadata_init(AVBSFContext *bsf) } } - err = ff_cbs_write_extradata(ctx->cbc, bsf->par_out, frag); + err = ff_cbs_write_extradata(ctx->output, bsf->par_out, frag); if (err < 0) { av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n"); goto fail; @@ -277,7 +281,8 @@ static void av1_metadata_close(AVBSFContext *bsf) AV1MetadataContext *ctx = bsf->priv_data; ff_cbs_fragment_free(&ctx->access_unit); - ff_cbs_close(&ctx->cbc); + ff_cbs_close(&ctx->input); + ff_cbs_close(&ctx->output); } #define OFFSET(x) offsetof(AV1MetadataContext, x) |