aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2020-11-15 18:55:39 -0300
committerJames Almer <jamrial@gmail.com>2021-01-04 16:28:29 -0300
commit3b8400c221983c9b1c894532d275af03144f8834 (patch)
tree2410a15a3c2f8b6b6cef1d2f51222ff576c0386b
parent9caf132462de6fe9b68644703c953c899c4e5bb8 (diff)
downloadffmpeg-3b8400c221983c9b1c894532d275af03144f8834.tar.gz
avcodec/cbs: allow cbs_read_fragment_content() to skip decomposition of units
The caller may not need all units in a fragment in reading only scenarios. They could in fact alter global state stored in the private CodedBitstreamType fields in an undesirable way. With this change, unit decomposition can be skipped based on parsed values within the unit. Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavcodec/cbs.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libavcodec/cbs.c b/libavcodec/cbs.c
index d7efac5b93..ecf22b3fdb 100644
--- a/libavcodec/cbs.c
+++ b/libavcodec/cbs.c
@@ -202,6 +202,12 @@ static int cbs_read_fragment_content(CodedBitstreamContext *ctx,
av_log(ctx->log_ctx, AV_LOG_VERBOSE,
"Decomposition unimplemented for unit %d "
"(type %"PRIu32").\n", i, unit->type);
+ } else if (err == AVERROR(EAGAIN)) {
+ av_log(ctx->log_ctx, AV_LOG_VERBOSE,
+ "Skipping decomposition of unit %d "
+ "(type %"PRIu32").\n", i, unit->type);
+ av_buffer_unref(&unit->content_ref);
+ unit->content = NULL;
} else if (err < 0) {
av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to read unit %d "
"(type %"PRIu32").\n", i, unit->type);