From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 35FC048D47 for ; Tue, 16 Dec 2025 18:31:52 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'dOqrSBAMlv6O4rf/rilTdr5TnAf+yZyNIPSPdI4cPoc=', expected b'ZelHJX6D1b9eL4eKhmceOD40pUhZGs5N2FePgHqf8PQ=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1765909899; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=dOqrSBAMlv6O4rf/rilTdr5TnAf+yZyNIPSPdI4cPoc=; b=VdaJqEvzdH7tyWZRJ6thNmNzB8+/i0hOu8WVyjLSabZ1Tp/0Vcsde+qgZcxzD0TV/yLp8 ceiy8jEbowKRBRd+fFNJl/eWxtMLofqxOoLYzwzFKZbJZpt/0M0QY7OZdcPBSA0R1TOkT5/ 4kN/eg6CsX8hJbHYVjrKbUoKrsw1J+lNEoWrPuVrNyVhcq/bMSOJYTD18D/Jmy+9AAyMkjl gJ6ajrYY0WDmIl6Ftc+JH2JlFY9uxMvk9SDI6NM8N/I5l2xfYrB/cMif/K4B2UpmcvR9a4D NHyj1mqYSPP4BB6ROQ3FdBrWi/cx0IjXIY4vvliNXM0oBEbPuDjkhaDET3iA== Received: from [172.20.0.2] (unknown [172.19.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id BF7DA6908D6; Tue, 16 Dec 2025 20:31:39 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1765909891; b=Gjiw3DpJRPPwhS4AeQhcDImu5ziExrcM0BNDrPmKwpWs5r4+crbFPCtWL70Rt0ZgebEcI TAD8F38+73LLSyMhAgG3jd/ZA88RQAAi185nygtIwgORqz2XY4DYcn0diicyv+1itiYFglG Ydln3Y5VgHitxD+aT20VQZKgZ7WINIxx+N5yPOPsHFa3iIY/QotzbjlZ3PhxWylnoDynY8D 5b67DtCe8Cc/9Vzgtgh6ga3qu433oJcu+5qhETGC9XsD1MNqbnBOPpbo9tWxDoPuflnuvBN ZYH4PFI8lj3VCvOKy78fF1HtXe7MB1O+IO6bneEL9uBAWBdDFLtcYQynChxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1765909891; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=2Pjorq8Fswv2F55hUTcs/IrNOj6Cl7cZ3XrUL/pVW04=; b=DKFwkuZLyyS0F33h06oIatS/qaoHl6M+tpWMCahBZ938xbPMUeyHDKoGhwTUV93tOfefP oi78zUUj077yl6otTEaCOTiiVg5zKcR8p42Lb1Pm2wDk3oLeaiG7YEZDvoBW+8G5HygCC+6 OHFO6Rx5ZVei1XVV/QBrh04iiYXB2qHf4LGk79koZqrXxnnJZMLn4FEmRHn4fQ9+kq1d7Ba kga1CW4BbiId+/F9d52I94C9mBeZZM4sqvi4sqavO8buqSIbToz6Expm2Ee1TqCLNGNLv6i Aeh+YBPbfrwyfNHQbkgeuTUaQ+tF76NJ0CP0FWuAsjvCdofSWp5og+rymtrA== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1765909884; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=ZelHJX6D1b9eL4eKhmceOD40pUhZGs5N2FePgHqf8PQ=; b=cb8Zg6i+m5I/CQcC7ChT/IhBy/xCflQKBOFVPivbFXdqblu7iqXrIz67MhB4EZStR39Kf m7m3SEnHccVzKd17iGaWwMovssXziuZQ7oYWmdsx767iksfP3hJb09vaUaemth7aUr5A/Rt BDMtRJcYvdQtSFp5V6QKGkPmwZ94MyfD2LECvuyoO7w5yRjCNMqFlPYTbLKRsejLgS8Y3Jk +MB5YtLhpcqbZMS1Av5CTBnTz/ctjrygMgq1dFszcwWP29xFlY2jXCyaSIwklFkuYUtIXAu l42Oob14sU1A+ZtZa7u3x/+CvgBVqu+CYHYugK2JxzsAwv4lkUVH+0G8e7uQ== Received: from 55ca25703178 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id D094E6908C4 for ; Tue, 16 Dec 2025 20:31:24 +0200 (EET) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Tue, 16 Dec 2025 18:31:24 -0000 Message-ID: <176590988497.60.52283857978838630@2cb04c0e5124> Message-ID-Hash: AI7PP5THLFKZU5CBTCOJHCZFOHP3ISJ5 X-Message-ID-Hash: AI7PP5THLFKZU5CBTCOJHCZFOHP3ISJ5 X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] avcodec/apv_parser: add support for AU assembly (PR #21216) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: James Almer via ffmpeg-devel Cc: James Almer Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #21216 opened by James Almer (jamrial) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21216 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21216.patch >>From ba76ab558c55f447364521bdae422fa5e6424d3a Mon Sep 17 00:00:00 2001 From: James Almer Date: Tue, 16 Dec 2025 15:27:27 -0300 Subject: [PATCH] avcodec/apv_parser: add support for AU assembly Signed-off-by: James Almer --- libavcodec/apv_parser.c | 69 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/libavcodec/apv_parser.c b/libavcodec/apv_parser.c index dbecbb5a5e..3417bd751f 100644 --- a/libavcodec/apv_parser.c +++ b/libavcodec/apv_parser.c @@ -18,14 +18,18 @@ #include "libavutil/avassert.h" #include "libavutil/buffer.h" +#include "libavutil/mem.h" #include "avcodec.h" #include "apv.h" #include "cbs.h" #include "cbs_apv.h" +#include "parser.h" #include "parser_internal.h" typedef struct APVParseContext { + ParseContext pc; + CodedBitstreamContext *cbc; CodedBitstreamFragment au; } APVParseContext; @@ -38,6 +42,48 @@ 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 int find_frame_end(APVParseContext *p, const uint8_t *buf, int buf_size) +{ + ParseContext *pc = &p->pc; + int pic_found, i = 0; + uint32_t state; + + pic_found = pc->frame_start_found; + state = pc->state; + + if (buf_size == 0) { + pc->frame_start_found = 0; + pc->state = -1; + return 0; + } + + if (!pic_found) { + for (; i < buf_size; i++) { + state = (state << 8) | buf[i]; + if (state == APV_SIGNATURE) { + i++; + pic_found = 1; + break; + } + } + } + + if (pic_found) { + for(; i < buf_size; i++) { + state = (state << 8) | buf[i]; + if (state == APV_SIGNATURE) { + pc->frame_start_found = 0; + pc->state = -1; + return i - 3; + } + } + } + + pc->frame_start_found = pic_found; + pc->state = state; + return END_NOT_FOUND; +} + static void dummy_free(void *opaque, uint8_t *data) { av_assert0(opaque == data); @@ -51,15 +97,30 @@ static int parse(AVCodecParserContext *s, APVParseContext *p = s->priv_data; CodedBitstreamFragment *au = &p->au; AVBufferRef *ref = NULL; - int ret; + int next, ret; + + if (s->flags & PARSER_FLAG_COMPLETE_FRAMES) { + next = buf_size; + } else { + next = find_frame_end(p, buf, buf_size); + + if (ff_combine_frame(&p->pc, next, &buf, &buf_size) < 0) { + *poutbuf = NULL; + *poutbuf_size = 0; + return buf_size; + } + } *poutbuf = buf; *poutbuf_size = buf_size; + if (!buf_size) + return 0; + ref = av_buffer_create((uint8_t *)buf, buf_size, dummy_free, (void *)buf, AV_BUFFER_FLAG_READONLY); if (!ref) - return buf_size; + return next; p->cbc->log_ctx = avctx; @@ -111,7 +172,7 @@ end: av_buffer_unref(&ref); p->cbc->log_ctx = NULL; - return buf_size; + return next; } static const CodedBitstreamUnitType decompose_unit_types[] = { @@ -136,7 +197,9 @@ static av_cold int init(AVCodecParserContext *s) static av_cold void close(AVCodecParserContext *s) { APVParseContext *p = s->priv_data; + ParseContext *pc = &p->pc; + av_freep(&pc->buffer); ff_cbs_fragment_free(&p->au); ff_cbs_close(&p->cbc); } -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org