Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2019-03-25 06:11:39 +0300
committerJames Almer <jamrial@gmail.com>2019-04-14 20:51:51 +0300
commit1f260d7285c841f9e13c1d76158949a5d3c73a06 (patch)
tree4688d31cf37b0d51b6ae6abfbe831fa793a95e27
parent62074b8f85e083212abdf09c849e148e7634f5a2 (diff)
avcodec/cbs_av1: add support for Padding OBUs
Based on itut_t35 Matadata OBU parsing code. Reviewed-by: Mark Thompson <sw@jkqxz.net> Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavcodec/cbs_av1.c20
-rw-r--r--libavcodec/cbs_av1.h7
-rw-r--r--libavcodec/cbs_av1_syntax_template.c24
3 files changed, 51 insertions, 0 deletions
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;
+}