You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-07-11 14:30:22 +02:00
cbs: Fragment/unit data is always reference counted
Make this clear in the documentation and add some asserts to ensure that it is always true.
This commit is contained in:
@ -140,26 +140,30 @@ static int cbs_read_fragment_content(CodedBitstreamContext *ctx,
|
|||||||
int err, i, j;
|
int err, i, j;
|
||||||
|
|
||||||
for (i = 0; i < frag->nb_units; i++) {
|
for (i = 0; i < frag->nb_units; i++) {
|
||||||
|
CodedBitstreamUnit *unit = &frag->units[i];
|
||||||
|
|
||||||
if (ctx->decompose_unit_types) {
|
if (ctx->decompose_unit_types) {
|
||||||
for (j = 0; j < ctx->nb_decompose_unit_types; j++) {
|
for (j = 0; j < ctx->nb_decompose_unit_types; j++) {
|
||||||
if (ctx->decompose_unit_types[j] == frag->units[i].type)
|
if (ctx->decompose_unit_types[j] == unit->type)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (j >= ctx->nb_decompose_unit_types)
|
if (j >= ctx->nb_decompose_unit_types)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
av_buffer_unref(&frag->units[i].content_ref);
|
av_buffer_unref(&unit->content_ref);
|
||||||
frag->units[i].content = NULL;
|
unit->content = NULL;
|
||||||
|
|
||||||
err = ctx->codec->read_unit(ctx, &frag->units[i]);
|
av_assert0(unit->data && unit->data_ref);
|
||||||
|
|
||||||
|
err = ctx->codec->read_unit(ctx, unit);
|
||||||
if (err == AVERROR(ENOSYS)) {
|
if (err == AVERROR(ENOSYS)) {
|
||||||
av_log(ctx->log_ctx, AV_LOG_VERBOSE,
|
av_log(ctx->log_ctx, AV_LOG_VERBOSE,
|
||||||
"Decomposition unimplemented for unit %d "
|
"Decomposition unimplemented for unit %d "
|
||||||
"(type %"PRIu32").\n", i, frag->units[i].type);
|
"(type %"PRIu32").\n", i, unit->type);
|
||||||
} else if (err < 0) {
|
} else if (err < 0) {
|
||||||
av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to read unit %d "
|
av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to read unit %d "
|
||||||
"(type %"PRIu32").\n", i, frag->units[i].type);
|
"(type %"PRIu32").\n", i, unit->type);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -277,6 +281,7 @@ int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx,
|
|||||||
"(type %"PRIu32").\n", i, unit->type);
|
"(type %"PRIu32").\n", i, unit->type);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
av_assert0(unit->data && unit->data_ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
av_buffer_unref(&frag->data_ref);
|
av_buffer_unref(&frag->data_ref);
|
||||||
@ -287,6 +292,7 @@ int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx,
|
|||||||
av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to assemble fragment.\n");
|
av_log(ctx->log_ctx, AV_LOG_ERROR, "Failed to assemble fragment.\n");
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
av_assert0(frag->data && frag->data_ref);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -327,7 +333,6 @@ int ff_cbs_write_packet(CodedBitstreamContext *ctx,
|
|||||||
if (err < 0)
|
if (err < 0)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
av_assert0(frag->data_ref);
|
|
||||||
buf = av_buffer_ref(frag->data_ref);
|
buf = av_buffer_ref(frag->data_ref);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
|
@ -84,8 +84,9 @@ typedef struct CodedBitstreamUnit {
|
|||||||
*/
|
*/
|
||||||
size_t data_bit_padding;
|
size_t data_bit_padding;
|
||||||
/**
|
/**
|
||||||
* If data is reference counted, a reference to the buffer containing
|
* A reference to the buffer containing data.
|
||||||
* data. Null if data is not reference counted.
|
*
|
||||||
|
* Must be set if data is not NULL.
|
||||||
*/
|
*/
|
||||||
AVBufferRef *data_ref;
|
AVBufferRef *data_ref;
|
||||||
|
|
||||||
@ -130,8 +131,9 @@ typedef struct CodedBitstreamFragment {
|
|||||||
*/
|
*/
|
||||||
size_t data_bit_padding;
|
size_t data_bit_padding;
|
||||||
/**
|
/**
|
||||||
* If data is reference counted, a reference to the buffer containing
|
* A reference to the buffer containing data.
|
||||||
* data. Null if data is not reference counted.
|
*
|
||||||
|
* Must be set if data is not NULL.
|
||||||
*/
|
*/
|
||||||
AVBufferRef *data_ref;
|
AVBufferRef *data_ref;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user