From patchwork Fri Jul 24 08:37:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 21247 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 627F8448D9F for ; Fri, 24 Jul 2020 11:38:20 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 489DC68B7C6; Fri, 24 Jul 2020 11:38:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A4BFE68B579 for ; Fri, 24 Jul 2020 11:38:14 +0300 (EEST) Received: by mail-ej1-f67.google.com with SMTP id l4so9116742ejd.13 for ; Fri, 24 Jul 2020 01:38:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kGHcgvmk7BpuFCdX0qKPzyvAv8Ng0yh365q0Mua/rp0=; b=bJjNtQKffEsHmLGno8t5mHj40pgfbHGYEpiaUojqxs2Q1Blb0ac7StQrVDbzvKMmig sJ1rPpWpRPah7UT8uQQ6wtH1hx40u3h6hh+qeoU8FSVq7HUIQnXFk+xpVcK6vVYvkBxt BQMdzfU1ZcmtTMhPuQW3tbqfyRkwZmX23/JgxNOsG/JXSHPN+IaruO3RgirZfB730Gir aRZchKPmVN5xsjthttr/nRJzGQsTXxvsCeDy+YhV2Qo45LyOs212Wpt3r3rx8hq8humo x1L+3jfUJBvtXdAgvu0YjrKlu7Ber1L/pQD4S6qSa902HHUGImdlvIVQP35d2rPkTKYP kn5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kGHcgvmk7BpuFCdX0qKPzyvAv8Ng0yh365q0Mua/rp0=; b=PM/xgDR2sD9KQGys9vog+Io6Ty/loACeR3AV0p/QfIKJUyBfFH/UEcujnLoCT8gLJM UqTQFDdW7/hI3gFiVSkZirkJajCzg5zVN+22567Am31VzTIU5ddIZFkhF7cgp8Si07Ff dKvuNegKruK8hJL01Su64RAyPQ9eN0rdnnU98ovKPFTpYPB5HrqGeD+wPExWCfXsa3zP AAuChiSmoNVG/Y+WY0RgpT/a+CwBPk/WHQPykXtKDPzitcEamTiz37fn6BvwNqE8ISH6 9KCmwyWgO85rOMuP5YvoHIgkR2up9tWHbSm+QqxqEh+JTz/eX9prSJ2F6RlIYEtfDasj 6A6g== X-Gm-Message-State: AOAM532jun/SAVlkB1L44wbeHE9jdgrdylouPLNYy50Nz5wxgoEpC7cX WjWctZ+9syFZNjWhJiZ18mMq9d2a X-Google-Smtp-Source: ABdhPJy2HT3NvQBSypSHndKxdxUlCaZMHYa48FLqdsnfiiH9IoqBRqnHrImA4Q24gT2m4lwci2ZjiQ== X-Received: by 2002:a17:906:8602:: with SMTP id o2mr8380155ejx.277.1595579893742; Fri, 24 Jul 2020 01:38:13 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc10296.dynamic.kabel-deutschland.de. [188.193.2.150]) by smtp.gmail.com with ESMTPSA id r19sm239487edi.85.2020.07.24.01.38.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jul 2020 01:38:13 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 24 Jul 2020 10:37:16 +0200 Message-Id: <20200724083717.8491-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200724041021.23977-1-andreas.rheinhardt@gmail.com> References: <20200724041021.23977-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] avformat/smacker: Fix duration for PCM audio X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" For non-PCM audio, a Smacker frame contains the size of the decoded audio in the first four bytes of the audio packet data; for PCM data, said information would be redundant and according to [1] this field does not exist. Therefore this commit sets the duration and timestamps properly for PCM audio. [1]: https://wiki.multimedia.cx/index.php/Smacker#Audio_Track_Chunk Signed-off-by: Andreas Rheinhardt --- libavformat/smacker.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavformat/smacker.c b/libavformat/smacker.c index 4ab150a6f0..b7a68a63f3 100644 --- a/libavformat/smacker.c +++ b/libavformat/smacker.c @@ -52,6 +52,7 @@ typedef struct SmackerContext { int cur_frame; int videoindex; int indexes[7]; + int duration_size[7]; /* current frame for demuxing */ uint32_t frame_size; int flags; @@ -197,6 +198,8 @@ static int smacker_read_header(AVFormatContext *s) if (par->bits_per_coded_sample == 16 && par->codec_id == AV_CODEC_ID_PCM_U8) par->codec_id = AV_CODEC_ID_PCM_S16LE; + else + smk->duration_size[i] = 4; avpriv_set_pts_info(ast, 64, 1, par->sample_rate * par->channels * par->bits_per_coded_sample / 8); } @@ -297,7 +300,7 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) uint32_t size; size = avio_rl32(s->pb); - if ((int)size < 8 || size > smk->frame_size) { + if ((int)size < 4 + smk->duration_size[i] || size > smk->frame_size) { av_log(s, AV_LOG_ERROR, "Invalid audio part size\n"); ret = AVERROR_INVALIDDATA; goto next_frame; @@ -315,7 +318,8 @@ static int smacker_read_packet(AVFormatContext *s, AVPacket *pkt) } pkt->stream_index = smk->indexes[i]; pkt->pts = smk->aud_pts[i]; - pkt->duration = AV_RL32(pkt->data); + pkt->duration = smk->duration_size[i] ? AV_RL32(pkt->data) + : size; smk->aud_pts[i] += pkt->duration; smk->next_audio_index = i + 1; return 0;