mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-29 22:00:58 +02:00
avcodec/av1_frame_merge_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
c91be9de4c
commit
2493944e31
@ -24,7 +24,8 @@
|
||||
#include "cbs_av1.h"
|
||||
|
||||
typedef struct AV1FMergeContext {
|
||||
CodedBitstreamContext *cbc;
|
||||
CodedBitstreamContext *input;
|
||||
CodedBitstreamContext *output;
|
||||
CodedBitstreamFragment frag[2];
|
||||
AVPacket *pkt, *in;
|
||||
int idx;
|
||||
@ -54,7 +55,7 @@ static int av1_frame_merge_filter(AVBSFContext *bsf, AVPacket *out)
|
||||
return err;
|
||||
}
|
||||
|
||||
err = ff_cbs_read_packet(ctx->cbc, frag, in);
|
||||
err = ff_cbs_read_packet(ctx->input, frag, in);
|
||||
if (err < 0) {
|
||||
av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
|
||||
goto fail;
|
||||
@ -82,7 +83,7 @@ static int av1_frame_merge_filter(AVBSFContext *bsf, AVPacket *out)
|
||||
|
||||
if (tu->nb_units > 0 && frag->units[0].type == AV1_OBU_TEMPORAL_DELIMITER) {
|
||||
eof:
|
||||
err = ff_cbs_write_packet(ctx->cbc, buffer_pkt, tu);
|
||||
err = ff_cbs_write_packet(ctx->output, buffer_pkt, tu);
|
||||
if (err < 0) {
|
||||
av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
|
||||
goto fail;
|
||||
@ -120,13 +121,18 @@ fail:
|
||||
static int av1_frame_merge_init(AVBSFContext *bsf)
|
||||
{
|
||||
AV1FMergeContext *ctx = bsf->priv_data;
|
||||
int err;
|
||||
|
||||
ctx->in = av_packet_alloc();
|
||||
ctx->pkt = av_packet_alloc();
|
||||
if (!ctx->in || !ctx->pkt)
|
||||
return AVERROR(ENOMEM);
|
||||
|
||||
return 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;
|
||||
|
||||
return ff_cbs_init(&ctx->output, AV_CODEC_ID_AV1, bsf);
|
||||
}
|
||||
|
||||
static void av1_frame_merge_close(AVBSFContext *bsf)
|
||||
@ -137,7 +143,8 @@ static void av1_frame_merge_close(AVBSFContext *bsf)
|
||||
ff_cbs_fragment_free(&ctx->frag[1]);
|
||||
av_packet_free(&ctx->in);
|
||||
av_packet_free(&ctx->pkt);
|
||||
ff_cbs_close(&ctx->cbc);
|
||||
ff_cbs_close(&ctx->input);
|
||||
ff_cbs_close(&ctx->output);
|
||||
}
|
||||
|
||||
static const enum AVCodecID av1_frame_merge_codec_ids[] = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user