cbs: Refcount all the things!

This makes it easier for users of the CBS API to get alloc/free right -
all subelements use the buffer API so that it's clear how to free them.
It also allows eliding some redundant copies: the packet -> fragment copy
disappears after this change if the input packet is refcounted, and more
codec-specific cases are now possible (but not included in this patch).
This commit is contained in:
Mark Thompson
2018-02-11 00:51:33 +00:00
parent 13ca5d34ba
commit ce5870a3a8
15 changed files with 416 additions and 291 deletions

View File

@@ -71,9 +71,10 @@ static int FUNC(user_data)(CodedBitstreamContext *ctx, RWContext *rw,
av_assert0(k % 8 == 0);
current->user_data_length = k /= 8;
if (k > 0) {
current->user_data = av_malloc(k);
if (!current->user_data)
current->user_data_ref = av_buffer_alloc(k);
if (!current->user_data_ref)
return AVERROR(ENOMEM);
current->user_data = current->user_data_ref->data;
}
#endif