From patchwork Sat Jul 8 19:00:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 42533 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6d25:b0:130:f365:34ad with SMTP id fv37csp614808pzb; Sat, 8 Jul 2023 12:01:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlEg2fe9zrI9UIyKp+nD9YwHT3GNhMLUe9iE6b8iEt+JfZGhy0lXCPaCJurCtaAhJ13Oq1qg X-Received: by 2002:a17:906:2201:b0:992:401f:d030 with SMTP id s1-20020a170906220100b00992401fd030mr7548503ejs.13.1688842884629; Sat, 08 Jul 2023 12:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688842884; cv=none; d=google.com; s=arc-20160816; b=N7WXfFDwcNtZotfzRGtdz5PNpjvT8WSgoXY3tsdHeDMvTSN3GED+fFN4+LDz64yTB5 PKiVEa0Eo6ISY04zr0hI9eBWfoAuCEF7XdbuCGCKCS0In4pofVbLgVIT8yAk8v0OpE0I P1vSz9iXtkvZ+yYAlN6t9H4aU9dPPykoAovzxJL7DwmuxIOEAI/yfMaC+Av0x34UWeT1 R9UaCelY1fC+Bbe6su/h3FUfkAaXaoWsWvLCs/Y0YALtvcANthM3qcTRql+Em7TSpUEn A7O37tm5kvWXgQ2gJHMmla3D/HA5rKyv0yb+bt03+9wmP8eNC7LrqUj/C8M6jqLKsfgm 2BXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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:dkim-signature:delivered-to; bh=w0F8uPYgpl98xK/ZFfWM5yRjCBfpLaewt7s5aQatX1U=; fh=J3zlMo7rVW2t2IQYogliBcMNuBh6YQg7NRChcrschf4=; b=0NsoZYtVYd9Sd9uo0qn2NS3KMOLaLB5YQfm2k3of3P3ZvHOaAZ/I8JPbLEF9TfM6iD p6sgrfO2sp34oQV6aLyxz7zAfRxHy482hRvY+14UQVTbGIa30PMarWWIxcgpAZ9fMoWa db8kRH1LiCbaQWiOxwJzcqKswdGpH8ivtrruKMHGdds1VmNwc769Il3+M8f22kpyV+4E NRkfPOEcA6s3OP1KinX/1QCcf1ouh1a/Lp+8sfMrW5VJvXB8deYmLpGr8hffkBWh7jAx GuKtc6Z1RtNpRR0j79e3FWdp1F9HsmdhTfuRdwK3BWHKUg5YcdrSxckqK2J3DcbeRXI9 37sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20221208 header.b=INEF++mp; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id lr24-20020a170906fb9800b00993d5cdf483si2466285ejb.807.2023.07.08.12.01.24; Sat, 08 Jul 2023 12:01:24 -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=20221208 header.b=INEF++mp; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5435268C537; Sat, 8 Jul 2023 22:01:05 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 33DDA68C50B for ; Sat, 8 Jul 2023 22:00:57 +0300 (EEST) Received: by mail-ot1-f47.google.com with SMTP id 46e09a7af769-6b723aedd3dso2173101a34.3 for ; Sat, 08 Jul 2023 12:00:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688842855; x=1691434855; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=7A45TDqM8pzgmY6T+ahTSivfxdoJPqQBU+bvqWJlA1s=; b=INEF++mpfbbYTmpWOhKpWkFBhNymQ7igbxLNfDGFMtcsp8MsStIMl6NtsCktgleZJ6 hFLFzYMinfYgkol3PbkUFqRVGL983Q2Oci5w6/Gll7JZExK+iEZIlXqL/ZlBwgxnXUAR JQNEF454mA7S+O3RqfvRxsw/a/iBj/sWuKSI6IUrtHEG3i+UNvJo+By6E70rNpnM9moG GWQJ7XuoDWtOwtw5r3D0pd6iGDq/l1tOVSQ+ydMioLHLLW4qRMHHv5GRWZkR9l5fr6QT MwNVk3T7lJCutEw9N5fY7wkg21jBCyvyet4bUa6m9ly2gCEXDRkULrLhQIi9MjUq6yFJ ErsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688842855; x=1691434855; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7A45TDqM8pzgmY6T+ahTSivfxdoJPqQBU+bvqWJlA1s=; b=SBBxtXCAIKeiYSdD0N2cEl3oUCsE2Znkbs1ld0cgTMfwQTWbwVDE6q/yoVsk0Llupt 4ZpFvSRY5nw47fw8Wo2iWITiUnFr1tHoA/GQzCohsjatdiRJbTU9jC02WOAJqPnPeI6L icQY3reHqRejTNLCTKfzVJSHjjvQIIOsfDB7V7HaYF9I+nGepi+Edq5P4RepVgu9UW7B yNn81E3W0EMy1oJSbtplwnHuRT0RI02iDJLHQu8gRUGV+gBhGquxlWopqlo+9S8QEKPd 5+jh9kxV5OBofF35eYZ6fOK3OZokrNqzhHY/+KI49Ke3eMDCxMAfUPGB4xrCn2PwGv4H +CiQ== X-Gm-Message-State: ABy/qLYw9f6OB/7viiEPnab/MNeRszf1J29nMXHp1t6Vl5zRvwuxLi6n VuEckmeXpVKvLF9RrhEoZ737oKQgWdo= X-Received: by 2002:a9d:7c87:0:b0:6b2:93f0:63a0 with SMTP id q7-20020a9d7c87000000b006b293f063a0mr7384225otn.19.1688842855348; Sat, 08 Jul 2023 12:00:55 -0700 (PDT) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id p23-20020a0568301d5700b006b92c078d05sm988738oth.31.2023.07.08.12.00.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Jul 2023 12:00:55 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Sat, 8 Jul 2023 16:00:38 -0300 Message-ID: <20230708190038.24324-3-jamrial@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230708190038.24324-1-jamrial@gmail.com> References: <20230708190038.24324-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/decode: fill missing frame fields for all decoders 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: VnQ2/i3ROF5l And not just those with the old decode() API. Signed-off-by: James Almer --- libavcodec/decode.c | 52 +++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 49c8b7e0f4..fe07e906c2 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -304,22 +304,6 @@ static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t *disca uint8_t skip_reason = 0; uint8_t discard_reason = 0; - if (frame->format == AV_SAMPLE_FMT_NONE) - frame->format = avctx->sample_fmt; - if (!frame->ch_layout.nb_channels) - ret = av_channel_layout_copy(&frame->ch_layout, &avctx->ch_layout); -#if FF_API_OLD_CHANNEL_LAYOUT -FF_DISABLE_DEPRECATION_WARNINGS - if (!frame->channel_layout) - frame->channel_layout = avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ? - avctx->ch_layout.u.mask : 0; - if (!frame->channels) - frame->channels = avctx->ch_layout.nb_channels; -FF_ENABLE_DEPRECATION_WARNINGS -#endif - if (!frame->sample_rate) - frame->sample_rate = avctx->sample_rate; - side= av_packet_get_side_data(avci->last_pkt_props, AV_PKT_DATA_SKIP_SAMPLES, &side_size); if(side && side_size>=10) { avci->skip_samples = AV_RL32(side); @@ -452,14 +436,6 @@ FF_DISABLE_DEPRECATION_WARNINGS frame->pkt_pos = pkt->pos; FF_ENABLE_DEPRECATION_WARNINGS #endif - //FIXME these should be under if(!avctx->has_b_frames) - /* get_buffer is supposed to set frame parameters */ - if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) { - if (!frame->sample_aspect_ratio.num) frame->sample_aspect_ratio = avctx->sample_aspect_ratio; - if (!frame->width) frame->width = avctx->width; - if (!frame->height) frame->height = avctx->height; - if (frame->format == AV_PIX_FMT_NONE) frame->format = avctx->pix_fmt; - } } } emms_c(); @@ -613,8 +589,34 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) } if (!ret) { - if (avctx->codec_type != AVMEDIA_TYPE_VIDEO) + if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) { + /* get_buffer is supposed to set frame parameters */ + if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) { + if (!frame->sample_aspect_ratio.num) frame->sample_aspect_ratio = avctx->sample_aspect_ratio; + if (!frame->width) frame->width = avctx->width; + if (!frame->height) frame->height = avctx->height; + if (frame->format == AV_PIX_FMT_NONE) frame->format = avctx->pix_fmt; + } + } else { + if (frame->format == AV_SAMPLE_FMT_NONE) + frame->format = avctx->sample_fmt; + if (!frame->ch_layout.nb_channels) + ret = av_channel_layout_copy(&frame->ch_layout, &avctx->ch_layout); +#if FF_API_OLD_CHANNEL_LAYOUT +FF_DISABLE_DEPRECATION_WARNINGS + if (!frame->channel_layout) + frame->channel_layout = avctx->ch_layout.order == AV_CHANNEL_ORDER_NATIVE ? + avctx->ch_layout.u.mask : 0; + if (!frame->channels) + frame->channels = avctx->ch_layout.nb_channels; +FF_ENABLE_DEPRECATION_WARNINGS +#endif + if (!frame->sample_rate) + frame->sample_rate = avctx->sample_rate; + frame->flags |= AV_FRAME_FLAG_KEY; + } + #if FF_API_FRAME_KEY FF_DISABLE_DEPRECATION_WARNINGS frame->key_frame = !!(frame->flags & AV_FRAME_FLAG_KEY);