mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-08 13:22:53 +02:00
avcodec/av1_metadata_bsf: Use separate contexts for reading/writing
Based on code from 235a5734e0
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
db7dfb4a79
commit
c91be9de4c
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user