From 62e5f78289f53ed14aa55fdc593b3cdffa6b369b Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Mon, 5 May 2025 20:11:56 +0200 Subject: [PATCH 07/11] avcodec/apv_parser: Don't use dummy AVBufferRef* Use the new CodedBitstreamContext.force_refcounting instead. This achieves the same aim as 0cabfdc8bc324891e4301c96940bca39d504cfbf, but in a cleaner way. Signed-off-by: Andreas Rheinhardt --- libavcodec/apv_parser.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/libavcodec/apv_parser.c b/libavcodec/apv_parser.c index fdd575339b..f3cc9dd669 100644 --- a/libavcodec/apv_parser.c +++ b/libavcodec/apv_parser.c @@ -16,9 +16,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/avassert.h" -#include "libavutil/buffer.h" - #include "avcodec.h" #include "apv.h" #include "cbs.h" @@ -37,11 +34,6 @@ static const enum AVPixelFormat apv_format_table[5][5] = { { AV_PIX_FMT_YUVA444P, AV_PIX_FMT_YUVA444P10, AV_PIX_FMT_YUVA444P12, AV_PIX_FMT_GRAY14, AV_PIX_FMT_YUVA444P16 }, }; -static void dummy_free(void *opaque, uint8_t *data) -{ - av_assert0(opaque == data); -} - static int parse(AVCodecParserContext *s, AVCodecContext *avctx, const uint8_t **poutbuf, int *poutbuf_size, @@ -49,20 +41,14 @@ static int parse(AVCodecParserContext *s, { APVParseContext *p = s->priv_data; CodedBitstreamFragment *au = &p->au; - AVBufferRef *ref = NULL; int ret; *poutbuf = buf; *poutbuf_size = buf_size; - ref = av_buffer_create((uint8_t *)buf, buf_size, dummy_free, - (void *)buf, AV_BUFFER_FLAG_READONLY); - if (!ref) - return buf_size; - p->cbc->log_ctx = avctx; - ret = ff_cbs_read(p->cbc, au, ref, buf, buf_size); + ret = ff_cbs_read(p->cbc, au, NULL, buf, buf_size); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Failed to parse access unit.\n"); goto end; @@ -106,8 +92,6 @@ static int parse(AVCodecParserContext *s, end: ff_cbs_fragment_reset(au); - av_assert1(av_buffer_get_ref_count(ref) == 1); - av_buffer_unref(&ref); p->cbc->log_ctx = NULL; return buf_size; @@ -128,6 +112,7 @@ static av_cold int init(AVCodecParserContext *s) p->cbc->decompose_unit_types = decompose_unit_types; p->cbc->nb_decompose_unit_types = FF_ARRAY_ELEMS(decompose_unit_types); + p->cbc->force_refcounting = 0; return 0; } -- 2.45.2