From patchwork Mon Oct 11 11:25:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 31045 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp3582463ioa; Mon, 11 Oct 2021 04:25:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYrIckkLorKnokAf5VxHm3PX5GSTA+pALQySMoe1jhklxLsHYNuinWci8mfXGv9dmZoKkR X-Received: by 2002:a05:6402:1e8e:: with SMTP id f14mr3707210edf.27.1633951551960; Mon, 11 Oct 2021 04:25:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633951551; cv=none; d=google.com; s=arc-20160816; b=XTBS3YacwNzCTJkwjCCQTtFt89CpcNCT3+FQb5zyGb3fmBxKPBEak75fBiuavGRRbo 7bkGDIKAFbkwJkHjjN3DM2Xsbnpj/XAcaKgaNNi1otAU3nl0takenZfZl2y9472yuAOY afKVmwWM7C+DupRIxZeUcc9VbBrNOMg6idLBPfAmOr0cmXkp+Zyv5jDEBfFecS7UePx2 zCDdgJuqqaFSO/mRe6aGDLZ4GN0C3L1Wr9+IjQ8xz2isCeQEtqKysNpZcebqh2XAFT62 8MHTZ5ENW+l4ErEM4cjAk9LlhgELIOiZ4NfwcEBE36CaUocJ6/d6rnDuEhCDSKYz8J3j vijQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=f8KXTrUmeMvvVacyB2WeSwdDv3TXTAcEAyb0pfdFyHY=; b=N6+OpDEnMfRAhDhO5hgrUVOQWOxhGJd+/aY2guxDTrijPhF3Y+Y7dHmQ5fPz/1xnGg D/jeKEguvkc7hmFGIEFydPhWfI2kCO4Nly52r/iEIq3e7ljRgtPKmveiDJxnBq8IRaRq Xdfte13CUsvfDJ1gpTeBx7SHH7t+7DiI5X1gquf26MD3HA2bCCt2yc2GTZbnjmJroMzI q8nyr1Csn7hjt5hhN0GNYDPERycoxJ+IwWTXXcQD8IlFgUPj95XL9mXLzM7+qcRhXNtV z0DID0Jf6P7RBwb6EJ/xyE/6Ce89BzHekFnCfyoL07IJpa3WV3LANEfvYBWR5lfLGKJW JiwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zanevaniperen.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h11si10336899edf.416.2021.10.11.04.25.50; Mon, 11 Oct 2021 04:25:51 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zanevaniperen.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2AC0168A863; Mon, 11 Oct 2021 14:25:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 214C9689F94 for ; Mon, 11 Oct 2021 14:25:39 +0300 (EEST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Zane van Iperen To: ffmpeg-devel@ffmpeg.org Date: Mon, 11 Oct 2021 21:25:32 +1000 Message-Id: <20211011112533.173814-1-zane@zanevaniperen.com> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: noreply-caprica@cadance.vs49688.net Subject: [FFmpeg-devel] [PATCH 1/2] avformat/argo_asf: pass name through as metadata 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 Cc: Zane van Iperen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: mypj4wNOqDGd Signed-off-by: Zane van Iperen --- libavformat/argo_asf.c | 5 +++++ libavformat/argo_asf.h | 3 ++- tests/ref/acodec/adpcm-argo | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c index 7e759c7c0c..f729a393ad 100644 --- a/libavformat/argo_asf.c +++ b/libavformat/argo_asf.c @@ -181,6 +181,7 @@ static int argo_asf_read_header(AVFormatContext *s) AVStream *st; ArgoASFDemuxContext *asf = s->priv_data; uint8_t buf[ASF_MIN_BUFFER_SIZE]; + char namebuf[ASF_MAX_NAME_SIZE + 1]; if (!(st = avformat_new_stream(s, NULL))) return AVERROR(ENOMEM); @@ -209,6 +210,10 @@ static int argo_asf_read_header(AVFormatContext *s) ff_argo_asf_parse_chunk_header(&asf->ckhdr, buf); + memcpy(namebuf, asf->fhdr.name, ASF_MAX_NAME_SIZE); + namebuf[ASF_MAX_NAME_SIZE] = '\0'; + av_dict_set(&s->metadata, "title", namebuf, 0); + return ff_argo_asf_fill_stream(s, st, &asf->fhdr, &asf->ckhdr); } diff --git a/libavformat/argo_asf.h b/libavformat/argo_asf.h index e65125fb79..f0607c7859 100644 --- a/libavformat/argo_asf.h +++ b/libavformat/argo_asf.h @@ -33,6 +33,7 @@ #define ASF_CHUNK_HEADER_SIZE 20 #define ASF_SAMPLE_COUNT 32 #define ASF_MIN_BUFFER_SIZE FFMAX(ASF_FILE_HEADER_SIZE, ASF_CHUNK_HEADER_SIZE) +#define ASF_MAX_NAME_SIZE 8 typedef struct ArgoASFFileHeader { uint32_t magic; /*< Magic Number, {'A', 'S', 'F', '\0'} */ @@ -40,7 +41,7 @@ typedef struct ArgoASFFileHeader { uint16_t version_minor; /*< File Minor Version. */ uint32_t num_chunks; /*< No. chunks in the file. */ uint32_t chunk_offset; /*< Offset to the first chunk from the start of the file. */ - int8_t name[8]; /*< Name. */ + int8_t name[ASF_MAX_NAME_SIZE]; /*< Name. */ } ArgoASFFileHeader; typedef struct ArgoASFChunkHeader { diff --git a/tests/ref/acodec/adpcm-argo b/tests/ref/acodec/adpcm-argo index 127153c081..4032a8f1fe 100644 --- a/tests/ref/acodec/adpcm-argo +++ b/tests/ref/acodec/adpcm-argo @@ -1,4 +1,4 @@ 14b2507d14e95c20bb7ae49b4fcbcbf1 *tests/data/fate/acodec-adpcm-argo.argo_asf 281190 tests/data/fate/acodec-adpcm-argo.argo_asf -cc5e5c695adeaebaa2b1f0df5ebd59ee *tests/data/fate/acodec-adpcm-argo.out.wav +446f28460bdb7ff4361cf7d82ac22c3e *tests/data/fate/acodec-adpcm-argo.out.wav stddev: 1542.05 PSNR: 32.57 MAXDIFF:59667 bytes: 1058400/ 1058432 From patchwork Mon Oct 11 11:25:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zane van Iperen X-Patchwork-Id: 31046 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2084:0:0:0:0 with SMTP id a4csp3582609ioa; Mon, 11 Oct 2021 04:26:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWutdt1uA8ioJkLJ2PEOqLLbOqCzuVIebudYYU6Zq0/iZRVsBjxQ8HkdxemcVgG7IgRZoY X-Received: by 2002:a05:6402:3554:: with SMTP id f20mr35374972edd.210.1633951563258; Mon, 11 Oct 2021 04:26:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633951563; cv=none; d=google.com; s=arc-20160816; b=cMFRbXYGBGZLH6N9KoqAOmIMVXiQ8uIIkkaUApcqlDVVHBdj+hTXPBBHirNpsGua9w 9MMNX9U8MAj+kez386QAE2LoQNnLXSGCMADrUhEY6SOIQ4JPRIwjW2z7OWAVpOQAIMSv QaH5KsmYONlHUWFNYhJ2mxQHq2RPv2XMtuuNAQeJuw2aKMB3Ou1ixfqk3P0q1rVzED0H BYki8wzybp4kP+Vz/OhgYPqPQHEKU6yy1JnlrAl1zLbGuoDyDaVHx1RoJYL2C5nOWhRB ER0uuuzLGTRBqz/H+Gh5J5P9dwnVlTz2KeDMRyQ4klpvrMCH7ffOMsaCzuA7VP+FQuV7 95ug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=QmJosvBtL/T9qUvkgCT83mr6gvMlF6RekMszke1n5OE=; b=lvYJ0gC7JfjA0+Diiy4/nQX8j8BQBdpr7HLNv9SDa5yW0nnGegsRO2NJzdSFkva9E4 0HUrvB49HXI27ajqnOaSP48OEcU0YGIlN8sKJ8bBL712c+77XBnplWgXcfq/rPk91mDb C3r6odR0MsM3RpW3Y0fXOk5BjMuXqMUy1uRIW/pmitl1F+X7h5eNv86rgCs8zLgZTgd2 KoCLgqwTTKzTukgQo5oBUcxtfRYC5FXLmgpPjLoHo42U7jZ1GJvYn7dZPzcMa81rkVEh i1Mm7c/Gi653Jl7/DgmuB7VMKcKbsCPRSGZbI6U0Vy8SuXp5AvVQ6Cag5DhMduqQb2Tm 73Zg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zanevaniperen.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gb1si16738875ejc.89.2021.10.11.04.26.03; Mon, 11 Oct 2021 04:26:03 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zanevaniperen.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5696F68A883; Mon, 11 Oct 2021 14:25:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DA1C368A863 for ; Mon, 11 Oct 2021 14:25:40 +0300 (EEST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Zane van Iperen To: ffmpeg-devel@ffmpeg.org Date: Mon, 11 Oct 2021 21:25:33 +1000 Message-Id: <20211011112533.173814-2-zane@zanevaniperen.com> In-Reply-To: <20211011112533.173814-1-zane@zanevaniperen.com> References: <20211011112533.173814-1-zane@zanevaniperen.com> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: noreply-caprica@cadance.vs49688.net Subject: [FFmpeg-devel] [PATCH 2/2] avformat/argo_asf: use title metadata when muxing 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 Cc: Zane van Iperen Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ox6Lzx+FVqWz Signed-off-by: Zane van Iperen --- libavformat/argo_asf.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/libavformat/argo_asf.c b/libavformat/argo_asf.c index f729a393ad..1171d9b7a7 100644 --- a/libavformat/argo_asf.c +++ b/libavformat/argo_asf.c @@ -361,18 +361,27 @@ static int argo_asf_write_header(AVFormatContext *s) .num_chunks = 1, .chunk_offset = ASF_FILE_HEADER_SIZE }; - const char *name = ctx->name, *end; + AVDictionaryEntry *t; + const char *name, *end; size_t len; /* - * If the user specified a name, use it as is. Otherwise take the - * basename and lop off the extension (if any). + * If the user specified a name, use it as is. Otherwise, + * try to use metadata (if present), then fall back to the + * filename (minus extension). */ - if (name || !(end = strrchr((name = av_basename(s->url)), '.'))) { + if (ctx->name) { + name = ctx->name; + len = strlen(ctx->name); + } else if ((t = av_dict_get(s->metadata, "title", NULL, 0))) { + name = t->value; + len = strlen(t->value); + } else if (!(end = strrchr((name = av_basename(s->url)), '.'))) { len = strlen(name); } else { len = end - name; } + memcpy(fhdr.name, name, FFMIN(len, sizeof(fhdr.name))); chdr.num_blocks = 0;