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 93AD64401F for ; Wed, 24 Aug 2022 14:20:48 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BACC468B9D5; Wed, 24 Aug 2022 17:20:44 +0300 (EEST) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-oln040092068046.outbound.protection.outlook.com [40.92.68.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B248E68B93E for ; Wed, 24 Aug 2022 17:20:38 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ISGn7YSrA/rxabn9Nycx4kIEgOFBjPZU9ynXALQi8qjVUlSi1wBMCqtVHdnGvO/UoQuYdu2e0hsaX32jG9GAo1OODsSKCiIUg4DPyj2YLY/BtwHgLsEVjk4UncCp54LD3/cvzenwAi40xatjICa/gFqDtY2S/RQG46DGJUVPUb06+2mGE24msiBaEC47Nw/PDTvJ1nL9RhGybIGhxQRCtQI1yxmCiYTYLelNiJfwlHE2tgWN2IOfbeXBsXXsp/TklRVNuO7IeX51Rs28sVJRHlsspTE8cXPp9Uja61b2z/xDlCAQ9zyrdhBfFD7KW98w+4PeeFGpR8RfLpzGZvpWIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Z3vnoo0shTlfEJsC6ivxlDkmMXTeor+zjIGYBFSYuBo=; b=mb7pA8dtNwtp5TIKnuTWD/v7kW0m+AV1Xw41YV21zeLkAsWKNlhZKypDGIMRvORX0uSw5uwvB2qiEyu9Kaz72K/rDxL30s4ZPyYtiofal/8oVhJuUQei07yACDXx+8x5OJeVkW9L9nNnkARMXwTP1SOKWTzHSA2XcgFSeRv8EFxrBl39AYHMcbwU0IVKD+eN1XlsmdDQUxA8sPFn1j/RKYWFsoYa1U+8b3LbzJPwNez9tnemVsDA9geVf2r7LmIO9emEegmx3V2Y4ysGi1j84fiW+seyITrZdUn3y91H+op78QvI935KZ/jAfoG7szEIFvd7AXI9UyfkMOi0WlyQGw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Z3vnoo0shTlfEJsC6ivxlDkmMXTeor+zjIGYBFSYuBo=; b=mHlCqYZw3ymAyM4PBnRZ6NHGEpCGGrtJjEY0fEIYtX3k5Bsj3XLvSyKk7DH1xWPGVXNsQBjWGHtzQdhtc5fzdADF/kLPMR9ZmaqF2p2Sk++2fxUy/NG04oWxlFckIcZL9shELvgYbZ2ZFH/J3o3Asb+39GYGEDlMA62bY+q1xgJthWuT39sMVqVeuGYMVEJrSIihEhRW0NYQLB6eVzd48qoIKlrxjFZhq2UW4eQZiVc76/zOU0L/HrVGtFiFPZ+idNTftoVejfx7qVg7O/7gQRVB2lkux5yaeg9/VIMqoStn7txvlR+S1jTuF+ROUPli82kxeGbeorngZK8JbmkUIQ== Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) by AM5PR0102MB2770.eurprd01.prod.exchangelabs.com (2603:10a6:206:10::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.19; Wed, 24 Aug 2022 14:20:37 +0000 Received: from DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::210e:b627:bcc9:8c46]) by DB6PR0101MB2214.eurprd01.prod.exchangelabs.com ([fe80::210e:b627:bcc9:8c46%11]) with mapi id 15.20.5546.022; Wed, 24 Aug 2022 14:20:36 +0000 Message-ID: Date: Wed, 24 Aug 2022 16:20:35 +0200 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20220824084318.333-1-anton@khirnov.net> <20220824084318.333-17-anton@khirnov.net> From: Andreas Rheinhardt In-Reply-To: <20220824084318.333-17-anton@khirnov.net> X-TMN: [QfknVtYCA0DokooUJODgC1Qyi1ZWUJ7W] X-ClientProxiedBy: ZR0P278CA0053.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::22) To DB6PR0101MB2214.eurprd01.prod.exchangelabs.com (2603:10a6:4:42::27) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1e71223a-db45-458e-0e9e-08da85dbd042 X-MS-TrafficTypeDiagnostic: AM5PR0102MB2770:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: h1VSnrFahZT84jFhCkOovNDC1tCBB3MTojgQKEOc713p3QpwvpclCviG22fnTAReGqz9yOS36nAai4C1hpJrF7cnJBCS/2NX7pIf7kd/uo6/fyYZiiOkwgZndq/iKxOiJzYyK/Hm/otTTYAI0ypJO6fp+/G+RBaCuf6laqZr3MCy78ff2CEhWXiNCFCFNhEDYzE5RDcVXFaCqbdETIHXWD9ZxEYBLSzXypDTQLEnMcCrUeiwhuhwr6JxahzNKUSuvGovhjE4zYmvtAoCDujNjf74ZvXaT2WG4vpgEpbIKTv+6WMfXfhuIZ0rmK2ikypl8ATah+EZXPRCQriG+bMXABv+YetAZvgLM5U54U9nKS1FqEVzJ1O8kz4QXGFsMReKkkiIeBrCeG7cCXw6TYa5u+MEa/GoWb3Wu/kNGyhg0la6zspwCFAjmTZepq49viXKG1u52cYdgeKsCtW2jvSwfmt05lFqi3UYLqIUpkXK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DV4VS9Id3FzNEdQ?= =?utf-8?B?c1puT2dBeE5jV2l2dDZLV1U0UGU1VjdxcnExb1NwL21HelpXU0o2V0pXazVa?= =?utf-8?B?YjVFOWZraU54KzVWZ2VGTGNveG1wbmR2djRUc3hoeStUc0x4RHRUVi9jblg3?= =?utf-8?B?Y0MxUnFDZ3RTb2VJa2szQ01CZVEyZ3RodUN5SVhUajl5WTFsdHV2RjJ5Uk01?= =?utf-8?Q?CiPcfnr+JFQKdTBtk0=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e71223a-db45-458e-0e9e-08da85dbd042 X-MS-Exchange-CrossTenant-AuthSource: DB6PR0101MB2214.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2022 14:20:36.9043 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0102MB2770 Subject: Re: [FFmpeg-devel] [PATCH 17/18] lavf/dv: do not update AVCodecParameters.sample_rate while demuxing 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Anton Khirnov: > Demuxers are not allowed to do this and few callers, if any, will handle > this correctly. Send the AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE side data > instead. > --- > libavformat/dv.c | 49 +++++++++++++++++++++++++++++++++--------------- > 1 file changed, 34 insertions(+), 15 deletions(-) > > diff --git a/libavformat/dv.c b/libavformat/dv.c > index 9c8b0a262c..ffed1a7a90 100644 > --- a/libavformat/dv.c > +++ b/libavformat/dv.c > @@ -33,6 +33,7 @@ > > #include > #include "avformat.h" > +#include "demux.h" > #include "internal.h" > #include "libavcodec/dv_profile.h" > #include "libavcodec/dv.h" > @@ -46,7 +47,7 @@ > #if CONFIG_DV_DEMUXER > > // Must be kept in sync with AVPacket > -struct DVPacket { > +typedef struct DVPacket { > int64_t pts; > uint8_t *data; > int size; > @@ -54,7 +55,10 @@ struct DVPacket { > int flags; > int64_t pos; > int64_t duration; > -}; > + > + int sample_rate; > + int last_sample_rate; > +} DVPacket; > > struct DVDemuxContext { > const AVDVProfile* sys; /* Current DV profile. E.g.: 525/60, 625/50 */ > @@ -237,7 +241,7 @@ static int dv_extract_audio(const uint8_t *frame, uint8_t **ppcm, > static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame) > { > const uint8_t *as_pack; > - int freq, stype, smpls, quant, i, ach; > + int freq, stype, smpls, quant, i, ach, sr; > > as_pack = dv_extract_pack(frame, DV_AUDIO_SOURCE); > if (!as_pack || !c->sys) { /* No audio ? */ > @@ -255,6 +259,7 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame) > "Unrecognized audio sample rate index (%d)\n", freq); > return 0; > } > + sr = dv_audio_frequency[freq]; > > if (stype > 3) { > av_log(c->fctx, AV_LOG_ERROR, "stype %d is invalid\n", stype); > @@ -280,7 +285,10 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame) > c->ast[i]->codecpar->codec_id = AV_CODEC_ID_PCM_S16LE; > c->ast[i]->codecpar->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO; > c->ast[i]->start_time = 0; > - c->ast[i]->codecpar->bit_rate = 2 * dv_audio_frequency[freq] * 16; > + c->ast[i]->codecpar->bit_rate = 2 * sr * 16; > + > + c->ast[i]->codecpar->sample_rate = sr; > + c->audio_pkt[i].last_sample_rate = sr; > > c->audio_pkt[i].size = 0; > c->audio_pkt[i].data = c->audio_buf[i]; > @@ -290,7 +298,8 @@ static int dv_extract_audio_info(DVDemuxContext *c, const uint8_t *frame) > c->audio_pkt[i].duration = 0; > c->audio_pkt[i].pos = -1; > } > - c->ast[i]->codecpar->sample_rate = dv_audio_frequency[freq]; > + > + c->audio_pkt[i].sample_rate = sr; > } > c->ach = ach; > > @@ -380,16 +389,26 @@ int avpriv_dv_get_packet(DVDemuxContext *c, AVPacket *pkt) > > for (i = 0; i < c->ach; i++) { > if (c->ast[i] && c->audio_pkt[i].size) { > - pkt->size = c->audio_pkt[i].size; > - pkt->data = c->audio_pkt[i].data; > - pkt->stream_index = c->audio_pkt[i].stream_index; > - pkt->flags = c->audio_pkt[i].flags; > - pkt->pts = c->audio_pkt[i].pts; > - pkt->duration = c->audio_pkt[i].duration; > - pkt->pos = c->audio_pkt[i].pos; > - > - c->audio_pkt[i].size = 0; > - size = pkt->size; > + DVPacket *dpkt = &c->audio_pkt[i]; > + > + pkt->size = dpkt->size; > + pkt->data = dpkt->data; > + pkt->stream_index = dpkt->stream_index; > + pkt->flags = dpkt->flags; > + pkt->pts = dpkt->pts; > + pkt->duration = dpkt->duration; > + pkt->pos = dpkt->pos; > + > + dpkt->size = 0; > + size = pkt->size; > + > + if (dpkt->last_sample_rate != dpkt->sample_rate) { > + int ret = ff_add_param_change(pkt, 0, 0, dpkt->sample_rate, 0, 0); > + if (ret < 0) > + return ret; > + dpkt->last_sample_rate = dpkt->sample_rate; > + } > + > break; > } > } 1. One of the callers which did not handle this correctly is the mov demuxer: A sample rate update would not propagate to the user, because it uses a separate AVFormatContext for it. This should be mentioned in the commit message. (Btw: I don't see anything that guarantees that the samplerate and timebase of the inner demuxer and the sample rate and time base reported to the user (presumably taken from mov structures) coincide. Given that dv_fctx and dv_demux are part of MOVContext, they would also leak if it would be attempted to allocate them multiple times. Do you see anything that guarantees that they will not be allocated multiple times?) 2. In case of ff_add_param_change() failure, users will just interpret that as "no more packets available", won't they? This might be wrong, but it is not problematic. 3. Have you tested this with a sample with actual parameter changes? - Andreas _______________________________________________ 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".