From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 43F2245547 for ; Mon, 30 Oct 2023 18:57:09 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2B1BB68CCAF; Mon, 30 Oct 2023 20:57:07 +0200 (EET) Received: from w4.tutanota.de (w4.tutanota.de [81.3.6.165]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6973468C92B for ; Mon, 30 Oct 2023 20:57:00 +0200 (EET) Received: from tutadb.w10.tutanota.de (unknown [192.168.1.10]) by w4.tutanota.de (Postfix) with ESMTP id 124AC1060307 for ; Mon, 30 Oct 2023 18:57:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1698692219; s=s1; d=lynne.ee; h=From:From:To:To:Subject:Subject:Content-Description:Content-ID:Content-Type:Content-Type:Content-Transfer-Encoding:Cc:Date:Date:In-Reply-To:MIME-Version:MIME-Version:Message-ID:Message-ID:Reply-To:References:Sender; bh=E7O/1lV01JzRZEnKHpKwRfqbivd2NK92nq07RPVQ48w=; b=w8JX8s7Vn8HMBUc+rjc2H5wbdF3RoMlAVMv7IBuik+g6KygysDuULT1pTEE7fw6P pYgThfZW+FR12ZEbjrs6x27H2o2UuXXiYrprk4Pu5nTV4Nx1msgmtEdthfitDhB35Od sZEY4Z/Aw3+OgHABObLcDxYi/oAUN4D4FY/XjONDJ89e9m4DToVb4kd0HWr0NeiFnjl 3gyHMwcPm8QrGzEPEBE+YuAK6SyRU7oO25WeK+OyIlAkW2uyGLCJKz+EQ3A95MqeY17 0iwKwODAJ3PUxntrWjTD+diftynOp3WIxpq/DW7eys3ftPfsZmKDY0CF5vUKEhLk/VX 94hy9Yvptg== Date: Mon, 30 Oct 2023 19:56:59 +0100 (CET) From: Lynne To: Ffmpeg Devel Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_245898_1119122514.1698692219402" Subject: [FFmpeg-devel] [PATCH] avformat: add AVFMT_INIT_ZERO_SKIP flag and use it in MOV X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: ------=_Part_245898_1119122514.1698692219402 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Meant to be applied on top my AAC patchset. MOV trims both the decoder/codec's algorithmic delay, and additionally, any samples the encoder needs removed, via edit lists, which we export as skip_samples side data. The issue is that if there are no edit lists, with the recent AAC decoding algorithmic delay removal patch, the default, algorithmic delay will be removed of 1024 samples. However, MOV specifies that this delay should be left as-is, even if edit lists are not used. demux.c, however, only signals a SKIP_SAMPLES side data if it is non-zero. Hence, this patch just changes this such that side data will always be put for MOV, even if it is zero, for only the first frame. This way, the decoder will not skip the algorithmic delay by itself. Patch attached. ------=_Part_245898_1119122514.1698692219402 Content-Type: text/x-diff; charset=us-ascii; name=0001-avformat-add-AVFMT_INIT_ZERO_SKIP-flag-and-use-it-in.patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0001-avformat-add-AVFMT_INIT_ZERO_SKIP-flag-and-use-it-in.patch >From 27e7e32e862b7dcd0f3c89a138f9ff64ed5042ed Mon Sep 17 00:00:00 2001 From: Lynne Date: Mon, 30 Oct 2023 19:42:14 +0100 Subject: [PATCH] avformat: add AVFMT_INIT_ZERO_SKIP flag and use it in MOV MOV trims both the decoder/codec's algorithmic delay, and additionally, any samples the encoder needs removed, via edit lists, which we export as skip_samples side data. The issue is that if there are no edit lists, with the recent AAC decoding algorithmic delay removal patch, the default, algorithmic delay will be removed of 1024 samples. However, MOV specifies that this delay should be left as-is, even if edit lists are not used. demux.c, however, only signals a SKIP_SAMPLES side data if it is non-zero. Hence, this patch just changes this such that side data will always be put for MOV, even if it is zero, for only the first frame. --- libavformat/avformat.h | 4 ++++ libavformat/demux.c | 3 ++- libavformat/mov.c | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 9e7eca007e..8a1ae91042 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -501,6 +501,10 @@ typedef struct AVProbeData { AVFormatContext.avoid_negative_ts */ +#define AVFMT_INIT_ZERO_SKIP 0x80000 /**< Format requires that skip_samples should + always be signalled, even if it is zero, + for the first frame. */ + #define AVFMT_SEEK_TO_PTS 0x4000000 /**< Seeking is based on PTS */ /** diff --git a/libavformat/demux.c b/libavformat/demux.c index 6f640b92b1..a4953d36f1 100644 --- a/libavformat/demux.c +++ b/libavformat/demux.c @@ -1398,7 +1398,8 @@ FF_ENABLE_DEPRECATION_WARNINGS if (sti->start_skip_samples && (pkt->pts == 0 || pkt->pts == RELATIVE_TS_BASE)) sti->skip_samples = sti->start_skip_samples; sti->skip_samples = FFMAX(0, sti->skip_samples); - if (sti->skip_samples || discard_padding) { + if (sti->skip_samples || discard_padding || + ((s->iformat->flags & AVFMT_INIT_ZERO_SKIP) && (pkt->pts == 0 || pkt->pts == RELATIVE_TS_BASE))) { uint8_t *p = av_packet_new_side_data(pkt, AV_PKT_DATA_SKIP_SAMPLES, 10); if (p) { AV_WL32(p, sti->skip_samples); diff --git a/libavformat/mov.c b/libavformat/mov.c index 2f29487beb..e012bd0291 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -9327,5 +9327,5 @@ const AVInputFormat ff_mov_demuxer = { .read_packet = mov_read_packet, .read_close = mov_read_close, .read_seek = mov_read_seek, - .flags = AVFMT_NO_BYTE_SEEK | AVFMT_SEEK_TO_PTS | AVFMT_SHOW_IDS, + .flags = AVFMT_NO_BYTE_SEEK | AVFMT_SEEK_TO_PTS | AVFMT_SHOW_IDS | AVFMT_INIT_ZERO_SKIP, }; -- 2.42.0 ------=_Part_245898_1119122514.1698692219402 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". ------=_Part_245898_1119122514.1698692219402--