From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 7AF6244BC5 for ; Thu, 8 Dec 2022 14:07:32 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2668468B9FF; Thu, 8 Dec 2022 16:07:30 +0200 (EET) Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C5D4068A37E for ; Thu, 8 Dec 2022 16:07:23 +0200 (EET) Received: by mail-oi1-f176.google.com with SMTP id k189so1484553oif.7 for ; Thu, 08 Dec 2022 06:07:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=5jEsK8VD85hmX/3iJpot1jitOLIQ2oM8SljR63BcHtI=; b=JgQD6vbrHlzDWUW2jAPvvkHzwpg+zJ/5NsTWdv5FGU3VagSsUr2eINca7uuDaoyH5L vWXrz26aRtt/xz4bEpPv3dxMlQbaMyKrv5PppKg2cc4MLEhWLI9VlG3Wyh+rO17dYd3q k9Bl9YuEq389j8IJ0PEMQMMEhJXUK7wOnWjxul8qVj6fKZ41X6OeY684rimZpra01iHz 1UsHuyll6I+KveK6wX0mnQxQT/vavBjvKyIxJd2ghXybHLVsnogxvhOWmf36O1qwN8GD h+wxS6rG4c4q9kBki6dfBVJofuyM4IX5dJ5vv/YyJ75paYqbevsg/Df6S0S3+A4g4nOD a0AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5jEsK8VD85hmX/3iJpot1jitOLIQ2oM8SljR63BcHtI=; b=qwZrdCq5gA2wutuo8S6PG/T+IWDQQwc9DpixJDGzhYsKmJu+ZokTwdyb7BqfuKUint 5/KYm5rk1r7prKu6skAEGWfFnSJP/zSe14SSiCCBIxkaCwXLgUQLeEPsswPrCHMHg2ug bQya0NrxPrZzTKBEztWFOeCOhl6fqjtT3TF+ztQojanFV1/Us+uDlfBldQQNBjMKtHq1 OKWzaghWmAhpSsAGtmPSaKB3yPDEQ3ccoOt45enQULvgu0Ot4Np9K6TGlXTWwxFUs5OP mldTuZ8OAciAvaFLU2azOWZLz9KkEj8Xq6jwpoUeTrQyw4I85bXSEkKZNJ4KIvaPt1ou xMFw== X-Gm-Message-State: ANoB5plDUVv/d5PKY9LBd4q6OfKcuve7e/HZKAllEi9JEXaJLRnvc7hP 9+8cHyRMvhJ3dA+9rUJqwUD00yd2qaM= X-Google-Smtp-Source: AA0mqf6IsCc9N2zzUHnRUmQuv9Ev7IYgeaGWd7sAjj9W28TVAokLp/cWd+UMzWZr2MBjz0wMX7EH3w== X-Received: by 2002:a05:6808:1b0f:b0:35c:29b0:e6ea with SMTP id bx15-20020a0568081b0f00b0035c29b0e6eamr1285575oib.30.1670508441530; Thu, 08 Dec 2022 06:07:21 -0800 (PST) Received: from localhost.localdomain (host197.190-225-105.telecom.net.ar. [190.225.105.197]) by smtp.gmail.com with ESMTPSA id e29-20020a544f1d000000b0035aa617156bsm10672553oiy.17.2022.12.08.06.07.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Dec 2022 06:07:21 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 8 Dec 2022 11:07:02 -0300 Message-Id: <20221208140706.3086-1-jamrial@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/5] avcodec/decode: add a function to set frame props from a user provided packet 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: It will be useful for decoders that don't rely on last_pkt_props to set frame props. Signed-off-by: James Almer --- libavcodec/decode.c | 19 +++++++++++++++---- libavcodec/decode.h | 5 +++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/libavcodec/decode.c b/libavcodec/decode.c index b184c3f55b..8f7f0fadbe 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -1261,9 +1261,8 @@ static int add_metadata_from_side_data(const AVPacket *avpkt, AVFrame *frame) return av_packet_unpack_dictionary(side_metadata, size, frame_md); } -int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) +int ff_decode_frame_props_from_pkt(AVFrame *frame, const AVPacket *pkt) { - const AVPacket *pkt = avctx->internal->last_pkt_props; static const struct { enum AVPacketSideDataType packet; enum AVFrameSideDataType frame; @@ -1281,11 +1280,10 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) { AV_PKT_DATA_DYNAMIC_HDR10_PLUS, AV_FRAME_DATA_DYNAMIC_HDR_PLUS }, }; - if (!(ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS)) { frame->pts = pkt->pts; frame->pkt_pos = pkt->pos; frame->duration = pkt->duration; - frame->pkt_size = (int)(intptr_t)pkt->opaque; + frame->pkt_size = pkt->size; for (int i = 0; i < FF_ARRAY_ELEMS(sd); i++) { size_t size; @@ -1307,6 +1305,19 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) } else { frame->flags = (frame->flags & ~AV_FRAME_FLAG_DISCARD); } + + return 0; +} + +int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) +{ + const AVPacket *pkt = avctx->internal->last_pkt_props; + + if (!(ffcodec(avctx->codec)->caps_internal & FF_CODEC_CAP_SETS_FRAME_PROPS)) { + int ret = ff_decode_frame_props_from_pkt(frame, pkt); + if (ret < 0) + return ret; + frame->pkt_size = (int)(intptr_t)pkt->opaque; } frame->reordered_opaque = avctx->reordered_opaque; diff --git a/libavcodec/decode.h b/libavcodec/decode.h index 5d95369b5e..906122b4a7 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -69,6 +69,11 @@ int ff_decode_receive_frame(AVCodecContext *avctx, AVFrame *frame); */ int ff_decode_get_packet(AVCodecContext *avctx, AVPacket *pkt); +/** + * Set various frame properties from the provided packet. + */ +int ff_decode_frame_props_from_pkt(AVFrame *frame, const AVPacket *pkt); + /** * Set various frame properties from the codec context / packet data. */ -- 2.38.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".