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 01A1A43C5D for ; Wed, 25 Jan 2023 16:57:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0D62868BDEE; Wed, 25 Jan 2023 18:56:28 +0200 (EET) Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2C30368BD36 for ; Wed, 25 Jan 2023 18:56:21 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id A5D7D2404F5 for ; Wed, 25 Jan 2023 17:56:20 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id BHwAKd-IDJST for ; Wed, 25 Jan 2023 17:56:20 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 40869240705 for ; Wed, 25 Jan 2023 17:56:05 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 1C8D13A0455 for ; Wed, 25 Jan 2023 17:55:59 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Wed, 25 Jan 2023 17:55:31 +0100 Message-Id: <20230125165537.5371-13-anton@khirnov.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20230125165537.5371-1-anton@khirnov.net> References: <20230125165537.5371-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 13/19] lavc/mpegvideo_enc: handle frame durations and AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE 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: For delay-capable encoders, i.e. mpeg12 and mpeg4video. Generic code in encode.c already handles this for all other mpegvideo encoders. --- libavcodec/mpeg12enc.c | 6 ++++-- libavcodec/mpeg4videoenc.c | 3 ++- libavcodec/mpegvideo_enc.c | 9 +++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c index 3ad1cd84a1..ff3d737e2a 100644 --- a/libavcodec/mpeg12enc.c +++ b/libavcodec/mpeg12enc.c @@ -1246,7 +1246,8 @@ const FFCodec ff_mpeg1video_encoder = { .p.supported_framerates = ff_mpeg12_frame_rate_tab + 1, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, - .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS, + .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.priv_class = &mpeg1_class, }; @@ -1264,7 +1265,8 @@ const FFCodec ff_mpeg2video_encoder = { .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_NONE }, - .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS, + .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.priv_class = &mpeg2_class, }; diff --git a/libavcodec/mpeg4videoenc.c b/libavcodec/mpeg4videoenc.c index a2a14afbd0..f7d48490f9 100644 --- a/libavcodec/mpeg4videoenc.c +++ b/libavcodec/mpeg4videoenc.c @@ -1403,7 +1403,8 @@ const FFCodec ff_mpeg4_encoder = { FF_CODEC_ENCODE_CB(ff_mpv_encode_picture), .close = ff_mpv_encode_end, .p.pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, - .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS, + .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS | + AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .p.priv_class = &mpeg4enc_class, }; diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index 9b11c5c05a..e77d5bcd57 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -1952,6 +1952,7 @@ vbv_retry: s->total_bits += s->frame_bits; pkt->pts = s->current_picture.f->pts; + pkt->duration = s->current_picture.f->duration; if (!s->low_delay && s->pict_type != AV_PICTURE_TYPE_B) { if (!s->current_picture.f->coded_picture_number) pkt->dts = pkt->pts - s->dts_delta; @@ -1960,6 +1961,14 @@ vbv_retry: s->reordered_pts = pkt->pts; } else pkt->dts = pkt->pts; + + // the no-delay case is handled in generic code + if (avctx->codec->capabilities & AV_CODEC_CAP_DELAY) { + ret = ff_encode_reordered_opaque(avctx, pkt, s->current_picture.f); + if (ret < 0) + return ret; + } + if (s->current_picture.f->key_frame) pkt->flags |= AV_PKT_FLAG_KEY; if (s->mb_info) -- 2.35.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".