From patchwork Sun Aug 11 10:33:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 50977 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:1ff2:b0:489:2eb3:e4c4 with SMTP id ks18csp798894vqb; Sun, 11 Aug 2024 03:33:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWFDi/U2lTWVk7wNikCMq3/JWyWZGpzor1NlTANO5RYKf5wOdg9fe8PA5Y5NM5L4NgBF2J1VategPBxZllTNCRJC7sdc+Isbb6QSQ== X-Google-Smtp-Source: AGHT+IHzYljKj+VQS4RSlJzJ6qwcCzf3eUfG9mzJCrX3CvmxTQJebNM1V/+uJ0J56pC1JNFzcyci X-Received: by 2002:a05:6512:39d3:b0:52c:a7c8:ec43 with SMTP id 2adb3069b0e04-530ee8b7e5bmr5004370e87.0.1723372410730; Sun, 11 Aug 2024 03:33:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723372410; cv=none; d=google.com; s=arc-20160816; b=bDjwqo4kULtZVz6RPkyJzSDvLGQeIfj/kJxpuoLQBMZsGjxvgfpDUm+11SbOkVXATg vgU073Q28CwvtMKHFR8nBVDscPbWjrIfKmaxg4N7tLCMxXfq+BV34U48NeyIAwTROdBh 611/i67sdC+rUfNTqkS6NJr8GQeokJdsQ8PwZVbjm4dmDbK7bNjQC1vD7hbAff0ZRHbc XpOoaXzsJCmeZnLBoek4wUeXgmJsuAXCWD+jsx+cMzqtsajoqXO1HkD8qNE6ErNDDwzL LWRF7xwlzOtaES66MPV0lYNNJBvyLQauvC0KsCoahjlmDpsZOHbx03QTQol0quT0zelM paSA== 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:message-id:date:to:from :delivered-to; bh=vu6c5Gx12R6OohjTVKQgJYMkuA13ZVUFN8x620i7sQM=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=ncPio8Sio03yiD7Fy0xMVBAwnyFvkD0Kwh0/10EQ6a6r0xfSq4lSyWznIiLEpU8icl ybz2I5GKuxqq6R8cBUcvaikDi3eQO484y6ALm3n2rEocLeP63ANS4T8eDypXtN2On1sz EEz2yyAjekOgmjziF18lRQ+eXJBORw47AuTA75WdH+ajRCjafECHZUdUPmZYL+H5oTpb tyvP49DpF9R/o527/AJlhDbijLhvksNu6+c4+SD4P19J1ckg+SPXnkbSrBuuMFt12uWZ Wxe2AmMU6V7QPIx8xa2g+7v7o+OTu5rlHCBrcKta9nTIwqd7ZBcDlEKxcqbaF0Z3mRso vfNA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a80bb218fbfsi161558566b.561.2024.08.11.03.33.30; Sun, 11 Aug 2024 03:33:30 -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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 35C6868D98A; Sun, 11 Aug 2024 13:33:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5CF0568D96B for ; Sun, 11 Aug 2024 13:33:19 +0300 (EEST) Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4WhYrr6s40z9sq6 for ; Sun, 11 Aug 2024 12:33:16 +0200 (CEST) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Sun, 11 Aug 2024 16:03:00 +0530 Message-ID: <20240811103300.11627-1-ffmpeg@gyani.pro> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4WhYrr6s40z9sq6 Subject: [FFmpeg-devel] [PATCH] lavc/libx265: unbreak build for X265_BUILD >= 210 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: ddsU9nBb59KS x265 added support for alpha starting with build 210. While doing so, x265_encoder_encode() changed its fifth arg to an array of pointers to x265_picture. This broke building lavc/libx265.c This patch simply unbreaks the build and maintains existing single-layer non-alpha encoding support. Fixes #11130 --- libavcodec/libx265.c | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c index 0dc7ab6eeb..3bc3b5a03e 100644 --- a/libavcodec/libx265.c +++ b/libavcodec/libx265.c @@ -661,7 +661,13 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, { libx265Context *ctx = avctx->priv_data; x265_picture x265pic; - x265_picture x265pic_out = { 0 }; +#if X265_BUILD >= 210 + x265_picture x265pic_layers_out[MAX_SCALABLE_LAYERS]; + x265_picture* x265pic_lyrptr_out[MAX_SCALABLE_LAYERS]; +#else + x265_picture x265pic_solo_out = { 0 }; +#endif + x265_picture* x265pic_out; x265_nal *nal; x265_sei *sei; uint8_t *dst; @@ -798,8 +804,16 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, #endif } +#if X265_BUILD >= 210 + for (i = 0; i < MAX_SCALABLE_LAYERS; i++) + x265pic_lyrptr_out[i] = &x265pic_layers_out[i]; + + ret = ctx->api->encoder_encode(ctx->encoder, &nal, &nnal, + pic ? &x265pic : NULL, x265pic_lyrptr_out); +#else ret = ctx->api->encoder_encode(ctx->encoder, &nal, &nnal, - pic ? &x265pic : NULL, &x265pic_out); + pic ? &x265pic : NULL, &x265pic_solo_out); +#endif for (i = 0; i < sei->numPayloads; i++) av_free(sei->payloads[i].payload); @@ -829,10 +843,16 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, pkt->flags |= AV_PKT_FLAG_KEY; } - pkt->pts = x265pic_out.pts; - pkt->dts = x265pic_out.dts; +#if X265_BUILD >= 210 + x265pic_out = x265pic_lyrptr_out[0]; +#else + x265pic_out = &x265pic_solo_out; +#endif + + pkt->pts = x265pic_out->pts; + pkt->dts = x265pic_out->dts; - switch (x265pic_out.sliceType) { + switch (x265pic_out->sliceType) { case X265_TYPE_IDR: case X265_TYPE_I: pict_type = AV_PICTURE_TYPE_I; @@ -850,16 +870,16 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt, } #if X265_BUILD >= 130 - if (x265pic_out.sliceType == X265_TYPE_B) + if (x265pic_out->sliceType == X265_TYPE_B) #else - if (x265pic_out.frameData.sliceType == 'b') + if (x265pic_out->frameData.sliceType == 'b') #endif pkt->flags |= AV_PKT_FLAG_DISPOSABLE; - ff_side_data_set_encoder_stats(pkt, x265pic_out.frameData.qp * FF_QP2LAMBDA, NULL, 0, pict_type); + ff_side_data_set_encoder_stats(pkt, x265pic_out->frameData.qp * FF_QP2LAMBDA, NULL, 0, pict_type); - if (x265pic_out.userData) { - int idx = (int)(intptr_t)x265pic_out.userData - 1; + if (x265pic_out->userData) { + int idx = (int)(intptr_t)x265pic_out->userData - 1; ReorderedData *rd = &ctx->rd[idx]; pkt->duration = rd->duration;