[FFmpeg-cvslog] avcodec/cbs_av1: add support for Padding OBUs
James Almer
git at videolan.org
Sun Apr 14 21:55:28 EEST 2019
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Mon Mar 25 00:11:39 2019 -0300| [1f260d7285c841f9e13c1d76158949a5d3c73a06] | committer: James Almer
avcodec/cbs_av1: add support for Padding OBUs
Based on itut_t35 Matadata OBU parsing code.
Reviewed-by: Mark Thompson <sw at jkqxz.net>
Signed-off-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1f260d7285c841f9e13c1d76158949a5d3c73a06
---
libavcodec/cbs_av1.c | 20 ++++++++++++++++++++
libavcodec/cbs_av1.h | 7 +++++++
libavcodec/cbs_av1_syntax_template.c | 24 ++++++++++++++++++++++++
3 files changed, 51 insertions(+)
diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
index f8f7e5f050..41dd4c97ac 100644
--- a/libavcodec/cbs_av1.c
+++ b/libavcodec/cbs_av1.c
@@ -868,6 +868,11 @@ static void cbs_av1_free_tile_data(AV1RawTileData *td)
av_buffer_unref(&td->data_ref);
}
+static void cbs_av1_free_padding(AV1RawPadding *pd)
+{
+ av_buffer_unref(&pd->payload_ref);
+}
+
static void cbs_av1_free_metadata(AV1RawMetadata *md)
{
switch (md->metadata_type) {
@@ -894,6 +899,9 @@ static void cbs_av1_free_obu(void *unit, uint8_t *content)
case AV1_OBU_METADATA:
cbs_av1_free_metadata(&obu->obu.metadata);
break;
+ case AV1_OBU_PADDING:
+ cbs_av1_free_padding(&obu->obu.padding);
+ break;
}
av_freep(&obu);
@@ -1068,6 +1076,12 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
}
break;
case AV1_OBU_PADDING:
+ {
+ err = cbs_av1_read_padding_obu(ctx, &gbc, &obu->obu.padding);
+ if (err < 0)
+ return err;
+ }
+ break;
default:
return AVERROR(ENOSYS);
}
@@ -1193,6 +1207,12 @@ static int cbs_av1_write_obu(CodedBitstreamContext *ctx,
}
break;
case AV1_OBU_PADDING:
+ {
+ err = cbs_av1_write_padding_obu(ctx, pbc, &obu->obu.padding);
+ if (err < 0)
+ return err;
+ }
+ break;
default:
return AVERROR(ENOSYS);
}
diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
index 71ceff9427..e799964b72 100644
--- a/libavcodec/cbs_av1.h
+++ b/libavcodec/cbs_av1.h
@@ -364,6 +364,12 @@ typedef struct AV1RawMetadata {
} metadata;
} AV1RawMetadata;
+typedef struct AV1RawPadding {
+ uint8_t *payload;
+ size_t payload_size;
+ AVBufferRef *payload_ref;
+} AV1RawPadding;
+
typedef struct AV1RawOBU {
AV1RawOBUHeader header;
@@ -377,6 +383,7 @@ typedef struct AV1RawOBU {
AV1RawTileGroup tile_group;
AV1RawTileList tile_list;
AV1RawMetadata metadata;
+ AV1RawPadding padding;
} obu;
} AV1RawOBU;
diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c
index 56009145e8..0e019aa113 100644
--- a/libavcodec/cbs_av1_syntax_template.c
+++ b/libavcodec/cbs_av1_syntax_template.c
@@ -1755,3 +1755,27 @@ static int FUNC(metadata_obu)(CodedBitstreamContext *ctx, RWContext *rw,
return 0;
}
+
+static int FUNC(padding_obu)(CodedBitstreamContext *ctx, RWContext *rw,
+ AV1RawPadding *current)
+{
+ int i, err;
+
+ HEADER("Padding");
+
+#ifdef READ
+ // The payload runs up to the start of the trailing bits, but there might
+ // be arbitrarily many trailing zeroes so we need to read through twice.
+ current->payload_size = cbs_av1_get_payload_bytes_left(rw);
+
+ current->payload_ref = av_buffer_alloc(current->payload_size);
+ if (!current->payload_ref)
+ return AVERROR(ENOMEM);
+ current->payload = current->payload_ref->data;
+#endif
+
+ for (i = 0; i < current->payload_size; i++)
+ xf(8, obu_padding_byte[i], current->payload[i], 0x00, 0xff, 1, i);
+
+ return 0;
+}
More information about the ffmpeg-cvslog
mailing list