early-access version 1680

This commit is contained in:
pineappleEA
2021-05-13 11:45:27 +02:00
parent 1434d96e7d
commit 66ed389c6f
311 changed files with 6452 additions and 2597 deletions

View File

@@ -49,7 +49,8 @@ enum {
typedef struct H264MetadataContext {
const AVClass *class;
CodedBitstreamContext *cbc;
CodedBitstreamContext *input;
CodedBitstreamContext *output;
CodedBitstreamFragment access_unit;
int done_first_au;
@@ -289,7 +290,7 @@ static int h264_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt)
if (!side_data_size)
return 0;
err = ff_cbs_read(ctx->cbc, au, side_data, side_data_size);
err = ff_cbs_read(ctx->input, au, 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;
@@ -303,7 +304,7 @@ static int h264_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt)
}
}
err = ff_cbs_write_fragment_data(ctx->cbc, au);
err = ff_cbs_write_fragment_data(ctx->output, au);
if (err < 0) {
av_log(bsf, AV_LOG_ERROR, "Failed to write extradata into packet side data.\n");
return err;
@@ -314,7 +315,7 @@ static int h264_metadata_update_side_data(AVBSFContext *bsf, AVPacket *pkt)
return AVERROR(ENOMEM);
memcpy(side_data, au->data, au->data_size);
ff_cbs_fragment_reset(ctx->cbc, au);
ff_cbs_fragment_reset(au);
return 0;
}
@@ -334,7 +335,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
if (err < 0)
goto fail;
err = ff_cbs_read_packet(ctx->cbc, au, pkt);
err = ff_cbs_read_packet(ctx->input, au, pkt);
if (err < 0) {
av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
goto fail;
@@ -349,7 +350,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
// If an AUD is present, it must be the first NAL unit.
if (au->units[0].type == H264_NAL_AUD) {
if (ctx->aud == REMOVE)
ff_cbs_delete_unit(ctx->cbc, au, 0);
ff_cbs_delete_unit(au, 0);
} else {
if (ctx->aud == INSERT) {
static const int primary_pic_type_table[] = {
@@ -390,7 +391,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
.primary_pic_type = j,
};
err = ff_cbs_insert_unit_content(ctx->cbc, au,
err = ff_cbs_insert_unit_content(au,
0, H264_NAL_AUD, &aud, NULL);
if (err < 0) {
av_log(bsf, AV_LOG_ERROR, "Failed to insert AUD.\n");
@@ -448,7 +449,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
udu->data_length = len + 1;
memcpy(udu->data, ctx->sei_user_data + i + 1, len + 1);
err = ff_cbs_h264_add_sei_message(ctx->cbc, au, &payload);
err = ff_cbs_h264_add_sei_message(au, &payload);
if (err < 0) {
av_log(bsf, AV_LOG_ERROR, "Failed to add user data SEI "
"message to access unit.\n");
@@ -467,7 +468,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
if (ctx->delete_filler) {
for (i = au->nb_units - 1; i >= 0; i--) {
if (au->units[i].type == H264_NAL_FILLER_DATA) {
ff_cbs_delete_unit(ctx->cbc, au, i);
ff_cbs_delete_unit(au, i);
continue;
}
@@ -478,8 +479,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
for (j = sei->payload_count - 1; j >= 0; j--) {
if (sei->payload[j].payload_type ==
H264_SEI_TYPE_FILLER_PAYLOAD)
ff_cbs_h264_delete_sei_message(ctx->cbc, au,
&au->units[i], j);
ff_cbs_h264_delete_sei_message(au, &au->units[i], j);
}
}
}
@@ -503,8 +503,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
if (ctx->display_orientation == REMOVE ||
ctx->display_orientation == INSERT) {
ff_cbs_h264_delete_sei_message(ctx->cbc, au,
&au->units[i], j);
ff_cbs_h264_delete_sei_message(au, &au->units[i], j);
continue;
}
@@ -595,7 +594,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
if (write) {
disp->display_orientation_repetition_period = 1;
err = ff_cbs_h264_add_sei_message(ctx->cbc, au, &payload);
err = ff_cbs_h264_add_sei_message(au, &payload);
if (err < 0) {
av_log(bsf, AV_LOG_ERROR, "Failed to add display orientation "
"SEI message to access unit.\n");
@@ -604,7 +603,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
}
}
err = ff_cbs_write_packet(ctx->cbc, pkt, au);
err = ff_cbs_write_packet(ctx->output, pkt, au);
if (err < 0) {
av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
goto fail;
@@ -614,7 +613,7 @@ static int h264_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
err = 0;
fail:
ff_cbs_fragment_reset(ctx->cbc, au);
ff_cbs_fragment_reset(au);
if (err < 0)
av_packet_unref(pkt);
@@ -628,12 +627,15 @@ static int h264_metadata_init(AVBSFContext *bsf)
CodedBitstreamFragment *au = &ctx->access_unit;
int err, i;
err = ff_cbs_init(&ctx->cbc, AV_CODEC_ID_H264, bsf);
err = ff_cbs_init(&ctx->input, AV_CODEC_ID_H264, bsf);
if (err < 0)
return err;
err = ff_cbs_init(&ctx->output, AV_CODEC_ID_H264, bsf);
if (err < 0)
return err;
if (bsf->par_in->extradata) {
err = ff_cbs_read_extradata(ctx->cbc, au, bsf->par_in);
err = ff_cbs_read_extradata(ctx->input, au, bsf->par_in);
if (err < 0) {
av_log(bsf, AV_LOG_ERROR, "Failed to read extradata.\n");
goto fail;
@@ -647,7 +649,7 @@ static int h264_metadata_init(AVBSFContext *bsf)
}
}
err = ff_cbs_write_extradata(ctx->cbc, bsf->par_out, au);
err = ff_cbs_write_extradata(ctx->output, bsf->par_out, au);
if (err < 0) {
av_log(bsf, AV_LOG_ERROR, "Failed to write extradata.\n");
goto fail;
@@ -656,7 +658,7 @@ static int h264_metadata_init(AVBSFContext *bsf)
err = 0;
fail:
ff_cbs_fragment_reset(ctx->cbc, au);
ff_cbs_fragment_reset(au);
return err;
}
@@ -664,8 +666,9 @@ static void h264_metadata_close(AVBSFContext *bsf)
{
H264MetadataContext *ctx = bsf->priv_data;
ff_cbs_fragment_free(ctx->cbc, &ctx->access_unit);
ff_cbs_close(&ctx->cbc);
ff_cbs_fragment_free(&ctx->access_unit);
ff_cbs_close(&ctx->input);
ff_cbs_close(&ctx->output);
}
#define OFFSET(x) offsetof(H264MetadataContext, x)