diff mbox

[FFmpeg-devel,2/3] avcodec/av1_metadata: add an option to remove Padding OBUs

Message ID 20190325142253.5276-2-jamrial@gmail.com
State New
Headers show

Commit Message

James Almer March 25, 2019, 2:22 p.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/av1_metadata_bsf.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Mark Thompson April 1, 2019, 10:51 p.m. UTC | #1
On 25/03/2019 14:22, James Almer wrote:
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  libavcodec/av1_metadata_bsf.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c
> index 2b74b697e4..fe208feaf5 100644
> --- a/libavcodec/av1_metadata_bsf.c
> +++ b/libavcodec/av1_metadata_bsf.c
> @@ -46,6 +46,8 @@ typedef struct AV1MetadataContext {
>  
>      AVRational tick_rate;
>      int num_ticks_per_picture;
> +
> +    int delete_padding;
>  } AV1MetadataContext;
>  
>  
> @@ -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);
>      if (err < 0) {
>          av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
> @@ -275,6 +290,10 @@ static const AVOption av1_metadata_options[] = {
>          OFFSET(num_ticks_per_picture), AV_OPT_TYPE_INT,
>          { .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 }
>  };
>  
> 

LGTM with matching doc update :)

Thanks,

- Mark
diff mbox

Patch

diff --git a/libavcodec/av1_metadata_bsf.c b/libavcodec/av1_metadata_bsf.c
index 2b74b697e4..fe208feaf5 100644
--- a/libavcodec/av1_metadata_bsf.c
+++ b/libavcodec/av1_metadata_bsf.c
@@ -46,6 +46,8 @@  typedef struct AV1MetadataContext {
 
     AVRational tick_rate;
     int num_ticks_per_picture;
+
+    int delete_padding;
 } AV1MetadataContext;
 
 
@@ -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);
     if (err < 0) {
         av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
@@ -275,6 +290,10 @@  static const AVOption av1_metadata_options[] = {
         OFFSET(num_ticks_per_picture), AV_OPT_TYPE_INT,
         { .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 }
 };