From patchwork Sun Sep 8 19:30:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Scholz X-Patchwork-Id: 51440 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:9c4f:0:b0:48e:c0f8:d0de with SMTP id w15csp1412906vqu; Sun, 8 Sep 2024 21:34:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWXq2rQ5jCoxZrcy9L7X497w5uyLNtvu+969MTnCgJOj95N9rmJvaXNyRoJr9JLGkxNcltWxveUVNio0MLL+IfG@gmail.com X-Google-Smtp-Source: AGHT+IF52Qt23XGeP5ZSlAiGKjV4n6cM8XlydF5yWBdPyqCb6ARhszzTT16H6wnvSKV99rR4bgzT X-Received: by 2002:a2e:bd11:0:b0:2f7:66ce:a319 with SMTP id 38308e7fff4ca-2f766cea5b1mr6882981fa.9.1725856451203; Sun, 08 Sep 2024 21:34:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725856451; cv=none; d=google.com; s=arc-20240605; b=CIgUi7+zgJAzdoWcs1BWcSqvZiBm9mW2kig722f3CuGT2eacqmIUAyZ8ECWAP0jvIL IUJIrJXrvvrCAGOvcOp2UUa3PCdnHIQaij90q5vNfPwMQFEqUu0YRa4PCdW0P8MfUy9S /BcvSU9ZX6jiNWUATGikwq0AKNdRvvzypOwo75G/kVgUl5s34NQHvtXZlpCjcSbHAqVd tm1z79V0dsnGXm3pM7wWzgdGVCB1D1HpMJN1UQJm8IXHjaFkom7vQntuV2jiwXFaL+55 kf0ws/NB4yt8HDTxEXNbtNtIhPFsBYhXVGcvehhDFzXdBZTjxaj5GT/QO+h6W/h+MZL9 Zg7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:date:from:to:message-id:in-reply-to :dkim-signature:delivered-to; bh=GMQfjWfP53/eTbz89H6WJcDvIth6ZKbKnOnBz47H3I8=; fh=5IeVwzS1vbVKjIV8MP3mnmnRtZGb8uteQ9r4QD2keV0=; b=WPJ72JgXfdgLqmtIN8UbvFJgQDjy4x7VsSN6OaCsXSY0eFLmdDaLUStBjjObWaw5/O llOjWoE1SXpj16QPqPzBEH3ESuzhFRouQu3BGxtx9mQypvUujlCoKz6U2MAHo2PNwRYz Q6gme5B7vZ2rPXj8ABWg7dAlWjZ+VhYSOso7IidZTuVmQAA+9dRnkaR1icWHb8fhR+st PNzOfM9bIrCrWIBiwWihwMBZcUBGL/Gxsw8liaNKHBIDbYpDkJbzE8Sfh1tGCiNNwn4r MyC676L4MwlLiFdrKBd3akvRESCMKD3D67kK0zS/mkv6gq+IZUmr0MsKtYwsJB20vgCD UAPg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=dWsBaGNP; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 4fb4d7f45d1cf-5c3ebd7a0afsi3158766a12.290.2024.09.08.21.34.10; Sun, 08 Sep 2024 21:34:11 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=dWsBaGNP; 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=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5FE5368DC47; Mon, 9 Sep 2024 03:55:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D1D2668DB2F for ; Mon, 9 Sep 2024 03:55:16 +0300 (EEST) Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-42bb6d3e260so33712955e9.1 for ; Sun, 08 Sep 2024 17:55:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725843316; x=1726448116; darn=ffmpeg.org; h=subject:date:from:to:message-id:in-reply-to:from:to:cc:subject:date :message-id:reply-to; bh=r1Bhs21Y7waGB+5jXXPYfkwwJH6zX4y1G9sjwhQmOp8=; b=dWsBaGNPPRjrs9LPxjwQndYTT35/KXND1XcmV86BZiGb+9fUkbAyVwREoXS6be7+aO +TWrgAaRzoAxdDW8Y0bc7Cjgdrbexl27ZgMUx4ZCYYkKnuod3ksBr/kep6Q8BDUtdiyF 0mK9ffUkxhd7P80pgjFboUNjPsKbStnEOdiQRtGN4kBy5eTH7JmzGVFM2MEDLMdHKa8v QQGPm/pglWd9M+3V6S/GYIyELLJ3oORi2rM3ksofGEgGnB1GLuASoBYkU/Zx/ps93ixI ouRwYER8IEHt6iyM3qk051jouQNz55CSSI/04Xrrk6DVk16wtdmtGLbVPcR0sKUUhIJD x/pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725843316; x=1726448116; h=subject:date:from:to:message-id:in-reply-to:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=r1Bhs21Y7waGB+5jXXPYfkwwJH6zX4y1G9sjwhQmOp8=; b=rah094nvcdFR/Haj0808ScLZ3v6sTEiA1Rt/+9qiawYjG87sTOm54iP2+7N3gUmhHa uAUTMfMi3aCB3yllf5cigduYVXQIJ3JzF/D/rrC2Fu6dWvBz6X5BWtnSmmZSsbvIfLem ts8BXkuMMUrylFdHC0KK3kKqdVzLF9/RA7keZxE71osFTq30TiXBIq+hRPFYmGSMQDBE Gd+bFBSMJbWODfcaVaZKI5tYA5Zl4mNBB6dpblXtBuUhsV6ZRNj2r/Ss/KGNDvm0JkQb QMu7amp1TDOvlZcln2+oCZytks5CDNFqkqqu5UIPmQH/k39b4oLN/5f7UyCCY8rJ4GtX yYGA== X-Gm-Message-State: AOJu0YxIncLaXMwRoWTNOGatt5O7igqPBsEZtMc7AwuCHU3Z2ITVbCNp rdewjipwTXfFSsElF8ju5al27D8rWQqLhpF8xDC3zXSHVE7E4UcM6QEIow== X-Received: by 2002:a05:600c:b9b:b0:42c:b037:5fce with SMTP id 5b1f17b1804b1-42cb0376448mr34591205e9.3.1725843316015; Sun, 08 Sep 2024 17:55:16 -0700 (PDT) Received: from localhost (p200300cccf1178009d94fda8472792f7.dip0.t-ipconnect.de. [2003:cc:cf11:7800:9d94:fda8:4727:92f7]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37895649728sm4583399f8f.16.2024.09.08.17.55.15 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 08 Sep 2024 17:55:15 -0700 (PDT) In-Reply-To: Message-Id: To: From: "Marvin Scholz" Date: Sun, 8 Sep 2024 21:30:40 +0200 Subject: [FFmpeg-devel] [PATCH 16/60] avformat/dashdec: use av_err2str to simplify code 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: NrozIMIt0O/h No need to explicitly specify the buffer here as it is only ever passed to av_log, so av_err2str can be used. --- libavformat/dashenc.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c index d4a6fe0304..df9d0c9d50 100644 --- a/libavformat/dashenc.c +++ b/libavformat/dashenc.c @@ -277,10 +277,8 @@ static const char *get_extension_str(SegmentType type, int single_file) static int handle_io_open_error(AVFormatContext *s, int err, char *url) { DASHContext *c = s->priv_data; - char errbuf[AV_ERROR_MAX_STRING_SIZE]; - av_strerror(err, errbuf, sizeof(errbuf)); av_log(s, c->ignore_io_errors ? AV_LOG_WARNING : AV_LOG_ERROR, - "Unable to open %s for writing: %s\n", url, errbuf); + "Unable to open %s for writing: %s\n", url, av_err2str(err)); return c->ignore_io_errors ? 0 : err; } @@ -1054,7 +1052,7 @@ static int parse_adaptation_sets(AVFormatContext *s) } else if ((state != new_set) && av_strstart(p, "streams=", &p)) { //descriptor and durations are optional state = parsing_streams; } else if (state == parsing_streams) { - AdaptationSet *as = &c->as[c->nb_as - 1]; + AdaptationSet *tmp_as = &c->as[c->nb_as - 1]; char idx_str[8], *end_str; n = strcspn(p, " ,"); @@ -1062,7 +1060,7 @@ static int parse_adaptation_sets(AVFormatContext *s) p += n; // if value is "a" or "v", map all streams of that type - if (as->media_type == AVMEDIA_TYPE_UNKNOWN && (idx_str[0] == 'v' || idx_str[0] == 'a')) { + if (tmp_as->media_type == AVMEDIA_TYPE_UNKNOWN && (idx_str[0] == 'v' || idx_str[0] == 'a')) { enum AVMediaType type = (idx_str[0] == 'v') ? AVMEDIA_TYPE_VIDEO : AVMEDIA_TYPE_AUDIO; av_log(s, AV_LOG_DEBUG, "Map all streams of type %s\n", idx_str); @@ -1070,7 +1068,7 @@ static int parse_adaptation_sets(AVFormatContext *s) if (s->streams[i]->codecpar->codec_type != type) continue; - as->media_type = s->streams[i]->codecpar->codec_type; + tmp_as->media_type = s->streams[i]->codecpar->codec_type; if ((ret = adaptation_set_add_stream(s, c->nb_as, i)) < 0) return ret; @@ -1083,8 +1081,8 @@ static int parse_adaptation_sets(AVFormatContext *s) } av_log(s, AV_LOG_DEBUG, "Map stream %d\n", i); - if (as->media_type == AVMEDIA_TYPE_UNKNOWN) { - as->media_type = s->streams[i]->codecpar->codec_type; + if (tmp_as->media_type == AVMEDIA_TYPE_UNKNOWN) { + tmp_as->media_type = s->streams[i]->codecpar->codec_type; } if ((ret = adaptation_set_add_stream(s, c->nb_as, i)) < 0) @@ -1865,9 +1863,8 @@ static void dashenc_delete_file(AVFormatContext *s, char *filename) { } else { int res = ffurl_delete(filename); if (res < 0) { - char errbuf[AV_ERROR_MAX_STRING_SIZE]; - av_strerror(res, errbuf, sizeof(errbuf)); - av_log(s, (res == AVERROR(ENOENT) ? AV_LOG_WARNING : AV_LOG_ERROR), "failed to delete %s: %s\n", filename, errbuf); + av_log(s, (res == AVERROR(ENOENT) ? AV_LOG_WARNING : AV_LOG_ERROR), "failed to delete %s: %s\n", + filename, av_err2str(res)); } } } @@ -2120,7 +2117,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt) if (!os->availability_time_offset && ((os->frag_type == FRAG_TYPE_DURATION && os->seg_duration != os->frag_duration) || (os->frag_type == FRAG_TYPE_EVERY_FRAME && pkt->duration))) { - AdaptationSet *as = &c->as[os->as_idx - 1]; + AdaptationSet *tmp_as = &c->as[os->as_idx - 1]; int64_t frame_duration = 0; switch (os->frag_type) { @@ -2134,7 +2131,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt) os->availability_time_offset = ((double) os->seg_duration - frame_duration) / AV_TIME_BASE; - as->max_frag_duration = FFMAX(frame_duration, as->max_frag_duration); + tmp_as->max_frag_duration = FFMAX(frame_duration, tmp_as->max_frag_duration); } if (c->use_template && !c->use_timeline) {