Commit ee16d14b authored by James Almer's avatar James Almer

avcodec/av1_metadata: add an option to remove Padding OBUs

Reviewed-by: 's avatarMark Thompson <sw@jkqxz.net>
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 1125277b
...@@ -87,6 +87,9 @@ the timing info in the sequence header. ...@@ -87,6 +87,9 @@ the timing info in the sequence header.
Set the number of ticks in each picture, to indicate that the stream Set the number of ticks in each picture, to indicate that the stream
has a fixed framerate. Ignored if @option{tick_rate} is not also set. has a fixed framerate. Ignored if @option{tick_rate} is not also set.
@item delete_padding
Deletes Padding OBUs.
@end table @end table
@section chomp @section chomp
......
...@@ -46,6 +46,8 @@ typedef struct AV1MetadataContext { ...@@ -46,6 +46,8 @@ typedef struct AV1MetadataContext {
AVRational tick_rate; AVRational tick_rate;
int num_ticks_per_picture; int num_ticks_per_picture;
int delete_padding;
} AV1MetadataContext; } AV1MetadataContext;
...@@ -158,6 +160,19 @@ static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *out) ...@@ -158,6 +160,19 @@ static int av1_metadata_filter(AVBSFContext *bsf, AVPacket *out)
} }
} }
if (ctx->delete_padding) {
for (i = 0; i < frag->nb_units; i++) {
if (frag->units[i].type == AV1_OBU_PADDING) {
err = ff_cbs_delete_unit(ctx->cbc, frag, i);
if (err < 0) {
av_log(bsf, AV_LOG_ERROR, "Failed to delete Padding OBU.\n");
goto fail;
}
--i;
}
}
}
err = ff_cbs_write_packet(ctx->cbc, out, frag); err = ff_cbs_write_packet(ctx->cbc, out, frag);
if (err < 0) { if (err < 0) {
av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n"); av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
...@@ -275,6 +290,10 @@ static const AVOption av1_metadata_options[] = { ...@@ -275,6 +290,10 @@ static const AVOption av1_metadata_options[] = {
OFFSET(num_ticks_per_picture), AV_OPT_TYPE_INT, OFFSET(num_ticks_per_picture), AV_OPT_TYPE_INT,
{ .i64 = -1 }, -1, INT_MAX, FLAGS }, { .i64 = -1 }, -1, INT_MAX, FLAGS },
{ "delete_padding", "Delete all Padding OBUs",
OFFSET(delete_padding), AV_OPT_TYPE_BOOL,
{ .i64 = 0 }, 0, 1, FLAGS},
{ NULL } { NULL }
}; };
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
#define LIBAVCODEC_VERSION_MAJOR 58 #define LIBAVCODEC_VERSION_MAJOR 58
#define LIBAVCODEC_VERSION_MINOR 48 #define LIBAVCODEC_VERSION_MINOR 48
#define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_MICRO 101
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \ LIBAVCODEC_VERSION_MINOR, \
......
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