From patchwork Thu Apr 2 17:17:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18579 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 8FD61448F27 for ; Thu, 2 Apr 2020 20:17:57 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 663D1689D84; Thu, 2 Apr 2020 20:17:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5325A689CE9 for ; Thu, 2 Apr 2020 20:17:51 +0300 (EEST) Received: by mail-wr1-f65.google.com with SMTP id 31so5180768wrs.3 for ; Thu, 02 Apr 2020 10:17:51 -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:mime-version :content-transfer-encoding; bh=rnM4cx6AGl3JlAAC5kQvpKFWtK8l19gf9x8VhjnKR0o=; b=suuJAKPCPbZpLDmkGIhTG3qdJIsGv0EhM1ESNWW1doYxbXy7A0cBKb+FS+Z9wyrQ7j O6M2b4KRwzmZpa9LV+EINMH3E9c4/AjPuZc57VOBk1K5XY/ixxzlr9DE4Q6gfOyK8nOC OfgsKIxLRmPkSxm+MsChZHsFMOT6AVqpjGSwirQ55t6ZiXDm6Go89dh0Ds/pWGzMssq2 sutV1HHtI8Od5DWwncXpp3ihgC0ax66vy6/7akL1ggOCG/y2tfsAqx2vscuYCHGdLAnq HrfiS6f5cYLxXQSuJ9ZrM30oCEk4xBN5TfiWiHLgEI/mukVI/TwylWro/CAOyFRNZkaR D1wA== 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:mime-version :content-transfer-encoding; bh=rnM4cx6AGl3JlAAC5kQvpKFWtK8l19gf9x8VhjnKR0o=; b=TvYWHZ65oIAaRHW1jR+88AdZFHPMwyE0Hz2odEsJInLdA4TTXyHNfzYgHQXcLyEGMG vsUN7XFnO1by9/iA1HNYohh2jRA+AUN7+PG3+mUS/ep/qGil81+NRY9p9vgQSqP+Cg62 Navu9r32hpEs5kCK+oWr/LUaNRxc8GRh2zm0Ji4D4mQHjgfKh/SmWa7oSV66PS1MPq/t 6FDzBJXMsqOVFAy3RjitclKdjtZpcD2/ikO2WI+GmgoMwDCh9Ub1M0xTK6Vq+rnL4MiC 6lbMcQbETU7WOXf3bKzHejCrt4NJKh+cBAAdaYS5TOCdU35pF6vpNq7ygU8N9EfK/3Kw apyw== X-Gm-Message-State: AGi0PuZIUXZMFFWqxMgTfKmkjnsGKJVF3EQuEwk3t8Yk0XnJJxySWDtr Nm5ED/n8FHE+Qd0JdJGC8YXv99ZU X-Google-Smtp-Source: APiQypIsNksFrcM4tNcDIGjaHs71sYhgUThdBMjU9ZeImWgpe+WFJOZsvbpAVBX2qDoHkQRYyZ9inw== X-Received: by 2002:adf:a28e:: with SMTP id s14mr17061wra.208.1585847870221; Thu, 02 Apr 2020 10:17:50 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id 9sm7645173wmm.6.2020.04.02.10.17.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 10:17:49 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 2 Apr 2020 19:17:38 +0200 Message-Id: <20200402171740.19121-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] avformat/ilbc: Don't reimplement ff_raw_write_packet 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" Signed-off-by: Andreas Rheinhardt --- libavformat/ilbc.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/libavformat/ilbc.c b/libavformat/ilbc.c index d41027174d..c778f5a5af 100644 --- a/libavformat/ilbc.c +++ b/libavformat/ilbc.c @@ -21,6 +21,7 @@ #include "avformat.h" #include "internal.h" +#include "rawenc.h" static const char mode20_header[] = "#!iLBC20\n"; static const char mode30_header[] = "#!iLBC30\n"; @@ -52,12 +53,6 @@ static int ilbc_write_header(AVFormatContext *s) return 0; } -static int ilbc_write_packet(AVFormatContext *s, AVPacket *pkt) -{ - avio_write(s->pb, pkt->data, pkt->size); - return 0; -} - static int ilbc_probe(const AVProbeData *p) { // Only check for "#!iLBC" which matches both formats @@ -133,6 +128,6 @@ AVOutputFormat ff_ilbc_muxer = { .extensions = "lbc", .audio_codec = AV_CODEC_ID_ILBC, .write_header = ilbc_write_header, - .write_packet = ilbc_write_packet, + .write_packet = ff_raw_write_packet, .flags = AVFMT_NOTIMESTAMPS, }; From patchwork Thu Apr 2 17:17:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18580 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 BD13E449727 for ; Thu, 2 Apr 2020 20:19:12 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A31C668A3AF; Thu, 2 Apr 2020 20:19:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 03F4A68A176 for ; Thu, 2 Apr 2020 20:19:07 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id 91so3236586wri.10 for ; Thu, 02 Apr 2020 10:19:06 -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=1M2OkkH7FGyd/p+PFTq9QDJnV2xabAoxFUDINMXApvk=; b=uDfwr/+Lxso6cdkCg1AYckzBLTVS0tcM4OrQvmQVwlbUpr7+IaqFk1IOsMkhGprP8F CNTsjPrnYGlKvfpT8fBoZ1yYIqh7bMQNPxwPOPg676/0jaIi9/+NjaloDZttLLTABdmG GBir3Y+uhuCcs3a5TUAUxDMHHRGtHQGxg5ITt1FCakgatouv5fAVclUa4zN5iYDJidGT ZSWB04iTV+PGZCrebUneN6OhXgoc8uy4aiZ4vX84apy30K7CIHP6JpiAvMyrIqXFDeED xvR3p40bKgmfABuui0BRuoBBCZVUmHeIvCmD0cyGXGDazUfNfkhWFrBe9Es4XlUuycsM UHdQ== 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=1M2OkkH7FGyd/p+PFTq9QDJnV2xabAoxFUDINMXApvk=; b=X7KixkUxynz9Xc7kGEw4CMGhf37Zw55nf25wi/8eWtyz6EUHYfpSgnIORgYDUwKj15 M1RlUbWVYQDrxBmf3eC3jmJCy8TGhD2gtg9k4AUZLiT/sb219ZxVu+7yuf0t0sD/jb0Z KICzvAe8W0qrIwZTbLkw5heC6FhBtIsSmKPxWRY98PecP/thbha1GdGaQIYrqmqeZgpQ /6FLyNGg6cIsG8WnB1MoLVeW+Fajfca2TiiItiNvtlN8bE2m/u+vtuDaijTsNbdTrUwE wL+eG0RecPec7WHgeFCC6EUH2cLx5LsP2bIJb7vnMPk2ppWhOt5YYvmih9FoXp/KKUGS l5PQ== X-Gm-Message-State: AGi0PuYJT6uq12iUcl6/xw6t68iLAO7HKUvD1X9r33a4qeO5A9OAHrJJ xtorplEr6L/5jFBPoU58xrtjQJPZ X-Google-Smtp-Source: APiQypKqadpEXctQ9QqDIYBLzrpHk89ephv87Khc43tZNlXINtHd25REbLN4Vl6Y/v6i2oQvNLQZZw== X-Received: by 2002:adf:fc08:: with SMTP id i8mr4598882wrr.109.1585847945910; Thu, 02 Apr 2020 10:19:05 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id 9sm7645173wmm.6.2020.04.02.10.19.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 10:19:05 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 2 Apr 2020 19:17:39 +0200 Message-Id: <20200402171740.19121-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200402171740.19121-1-andreas.rheinhardt@gmail.com> References: <20200402171740.19121-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] avformat/mpc: Simplify cleanup 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" Currently Musepack allocates an array that needs to be freed later in the demuxer's read_close-function; it is the sole reason for said function's existence. But it is unnecessary, because one can store this array in the stream's priv_data pointer, so that it will be freed generically. Signed-off-by: Andreas Rheinhardt --- libavformat/mpc.c | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/libavformat/mpc.c b/libavformat/mpc.c index 85036cd118..6a94b5d1d0 100644 --- a/libavformat/mpc.c +++ b/libavformat/mpc.c @@ -57,6 +57,7 @@ static int mpc_read_header(AVFormatContext *s) { MPCContext *c = s->priv_data; AVStream *st; + int ret; if(avio_rl24(s->pb) != MKTAG('M', 'P', '+', 0)){ av_log(s, AV_LOG_ERROR, "Not a Musepack file\n"); @@ -72,15 +73,6 @@ static int mpc_read_header(AVFormatContext *s) av_log(s, AV_LOG_ERROR, "Too many frames, seeking is not possible\n"); return AVERROR_INVALIDDATA; } - if(c->fcount){ - c->frames = av_malloc(c->fcount * sizeof(MPCFrame)); - if(!c->frames){ - av_log(s, AV_LOG_ERROR, "Cannot allocate seektable\n"); - return AVERROR(ENOMEM); - } - }else{ - av_log(s, AV_LOG_WARNING, "Container reports no frames\n"); - } c->curframe = 0; c->lastframe = -1; c->curbits = 8; @@ -88,15 +80,27 @@ static int mpc_read_header(AVFormatContext *s) st = avformat_new_stream(s, NULL); if (!st) - goto mem_error; + return AVERROR(ENOMEM); + + if (c->fcount) { + c->frames = av_malloc(c->fcount * sizeof(MPCFrame)); + if (!c->frames) { + av_log(s, AV_LOG_ERROR, "Cannot allocate seektable\n"); + return AVERROR(ENOMEM); + } + st->priv_data = c->frames; + } else { + av_log(s, AV_LOG_WARNING, "Container reports no frames\n"); + } + st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO; st->codecpar->codec_id = AV_CODEC_ID_MUSEPACK7; st->codecpar->channels = 2; st->codecpar->channel_layout = AV_CH_LAYOUT_STEREO; st->codecpar->bits_per_coded_sample = 16; - if (ff_get_extradata(s, st->codecpar, s->pb, 16) < 0) - goto mem_error; + if ((ret = ff_get_extradata(s, st->codecpar, s->pb, 16)) < 0) + return ret; st->codecpar->sample_rate = mpc_rate[st->codecpar->extradata[2] & 3]; avpriv_set_pts_info(st, 32, MPC_FRAMESIZE, st->codecpar->sample_rate); /* scan for seekpoints */ @@ -113,9 +117,6 @@ static int mpc_read_header(AVFormatContext *s) } return 0; -mem_error: - av_freep(&c->frames); - return AVERROR(ENOMEM); } static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) @@ -176,14 +177,6 @@ static int mpc_read_packet(AVFormatContext *s, AVPacket *pkt) return 0; } -static int mpc_read_close(AVFormatContext *s) -{ - MPCContext *c = s->priv_data; - - av_freep(&c->frames); - return 0; -} - /** * Seek to the given position * If position is unknown but is within the limits of file @@ -232,7 +225,6 @@ AVInputFormat ff_mpc_demuxer = { .read_probe = mpc_probe, .read_header = mpc_read_header, .read_packet = mpc_read_packet, - .read_close = mpc_read_close, .read_seek = mpc_read_seek, .extensions = "mpc", }; From patchwork Thu Apr 2 17:17:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 18581 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 82ABF449727 for ; Thu, 2 Apr 2020 20:19:14 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6B0BB689DC8; Thu, 2 Apr 2020 20:19:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 076DB68A484 for ; Thu, 2 Apr 2020 20:19:08 +0300 (EEST) Received: by mail-wr1-f68.google.com with SMTP id t7so5132467wrw.12 for ; Thu, 02 Apr 2020 10:19:07 -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=YCQ7e93xE7xka8D8x/FHjjdMwaOtkvx+z5kScWPdtLQ=; b=bu3UDtWf2Bh+B1115Sb5XN3xCeCfj/mSLszH3oS7vej41fd4J8gUbNtWL8RxXx8rk/ fopp+tw3j7HgagqeZvdDrgO1gP4SbLQY4k9f7RRiKOwr48e8f+xQ4izyNYfCZ/6gx3R7 jBHlWwT6ezyNPxH05hnp01fjpxpC9nfw47vdNnxe4WGVWgtdB+aHf79b10+yKPvpZHeo LOw4NZX+Unp5OUIGUsrJrIvg6flKp2953W5tBkiabBf15ewTNCFCncXIJ4Ad3JktLunO qWtG+HlOA3QJHQVnW7++9spFvfJMoHAcnMUpusLxa2k3ciCrGonDHpF+r79DL8LGup1S wYtg== 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=YCQ7e93xE7xka8D8x/FHjjdMwaOtkvx+z5kScWPdtLQ=; b=R6oKaqwkIcXN3VgeaV1RVer84l9u9FjYhr4kG5kngKa35pjeNfqrJPZ5gXJ/X8WQkc mGc1jEFAHSAgr8LL2tu7t66z80Gp2cZNVo0FGJhDYkNtcXcifmTgo3QJKiHmHd4COTsk 46ewFOlNnNBXeZdbjAGrMDC9JaLmOQlYHteC54pKNeoqMcJ5jcWQpr4ab1LV4An/qZ0w d4diVzADDqSAEeLzx4U0v9GmKKSYKkJ88+N7i7sAhxSMuAioHDtrjf88Xv1wW3pFqe3f syayZ6/CMq74z3T+TsoY1RBL9bbqxEJrQsC8cB/6qkpDO1j/N0DYtGypgHpcf/TuUD1t olJQ== X-Gm-Message-State: AGi0PuYtb48Ovd6miONBEwMzVPIUAW2cKvJrIQ3DJ+ubxNXMqVuVmjA2 4rPtdp8YlSwY70WgJz5mCzHy7JNq X-Google-Smtp-Source: APiQypIg3sjHKivmMTNQ+/1a4Tdj6Cw/WC38hX0h+OFrp6sqmXChKGuCruzWXRMEpdh1oxknVYT+bg== X-Received: by 2002:adf:dd10:: with SMTP id a16mr4468238wrm.26.1585847947082; Thu, 02 Apr 2020 10:19:07 -0700 (PDT) Received: from sblaptop.fritz.box (ipbcc1ab57.dynamic.kabel-deutschland.de. [188.193.171.87]) by smtp.gmail.com with ESMTPSA id 9sm7645173wmm.6.2020.04.02.10.19.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 10:19:06 -0700 (PDT) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 2 Apr 2020 19:17:40 +0200 Message-Id: <20200402171740.19121-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200402171740.19121-1-andreas.rheinhardt@gmail.com> References: <20200402171740.19121-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avformat/dss: Remove unnecessary allocation 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" Put a buffer with a known fixed size into the demuxer's context instead of allocating it separately. This also allows to remove the demuxer's read_close()-function. Signed-off-by: Andreas Rheinhardt --- libavformat/dss.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/libavformat/dss.c b/libavformat/dss.c index ae7a259526..0585049130 100644 --- a/libavformat/dss.c +++ b/libavformat/dss.c @@ -50,7 +50,7 @@ typedef struct DSSDemuxContext { int counter; int swap; int dss_sp_swap_byte; - int8_t *dss_sp_buf; + int8_t dss_sp_buf[DSS_FRAME_SIZE + 1]; int packet_size; int dss_header_size; @@ -168,10 +168,6 @@ static int dss_read_header(AVFormatContext *s) ctx->counter = 0; ctx->swap = 0; - ctx->dss_sp_buf = av_malloc(DSS_FRAME_SIZE + 1); - if (!ctx->dss_sp_buf) - return AVERROR(ENOMEM); - return 0; } @@ -327,15 +323,6 @@ static int dss_read_packet(AVFormatContext *s, AVPacket *pkt) return dss_723_1_read_packet(s, pkt); } -static int dss_read_close(AVFormatContext *s) -{ - DSSDemuxContext *ctx = s->priv_data; - - av_freep(&ctx->dss_sp_buf); - - return 0; -} - static int dss_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) { @@ -382,7 +369,6 @@ AVInputFormat ff_dss_demuxer = { .read_probe = dss_probe, .read_header = dss_read_header, .read_packet = dss_read_packet, - .read_close = dss_read_close, .read_seek = dss_read_seek, .extensions = "dss" };