From patchwork Mon Feb 20 18:53:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 40450 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:5494:b0:bf:7b3a:fd32 with SMTP id i20csp2145793pzk; Mon, 20 Feb 2023 10:54:06 -0800 (PST) X-Google-Smtp-Source: AK7set+wy42lkWr60z5/9pWGx7ZsrwdJgov+P6XSxA/F2UqdQetSc8pJQOk9D3iqtRFGBMdaVsGn X-Received: by 2002:a17:906:53c7:b0:885:fee4:69ee with SMTP id p7-20020a17090653c700b00885fee469eemr8565533ejo.59.1676919246651; Mon, 20 Feb 2023 10:54:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676919246; cv=none; d=google.com; s=arc-20160816; b=0+v9sMJT0jLCvJUH3PFJaGWbwb1mZ9znrbz+xsa+4i8gml5VWYEh9OjiMJEDDiK4Bf QjR4A/uOyw01I4axCBNoh8MVAZ2Cy19ayDnl0hKvunKpIGgj00gkyLl9VyuBvbN/sRiY cJ+7L6hLH87x3KHy6X/4e1J4lu3JiqJuVzn2Wy2RDGOuXnIeSB/RfV72i7vVp7MvEdl8 OcA2KB5A8+oYWipFP1j6sCSyb4BHqfCe+BfnXp0XjmTgQAxq++hXM1EqZUdzwGf34yP9 2Ii4KVWnnxM3V+4Djlb2hEYY0PHBen+mAJroQbQp35KC6vnIW01lNdLm+q4QS2S3sCZP tofg== 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=zHJNZqWQ9Q3ooHDgzP2KN1OqOYcH0oGIo33nhwwVV/U=; b=FjuRdgjXdR/RDnPBYidZH3DKjcHhOOJPLC0QWIJjvEuO+ArWoj17mo5Qn7lixI3aVV EKpy8grUhNO7vkFipdESWTn8LIanltoA891QZNi5HNdIRi9ZVaxXvkCmFzj3La3WapeO Grfh1g6k8x9DvvDobk3++VjkgOs9B/ag/RDLyUzDNwru7ChPoAZoc0KgnaVeHrVZkjNf o7MO8oUahCa8gk6Np9PXJ09pJRV5qJvi/QgCEgKx1RYYdtH0Szlen10fM38MAAQIP7IJ TIeMoOR8Mml/mbeuIz6Lhvr1FKDm+WSMl9IjHUOI53yBv6AfQiluoggN2v90AseNngHF 5mMg== 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 20-20020a17090600d400b008dd491949c6si404398eji.978.2023.02.20.10.54.06; Mon, 20 Feb 2023 10:54:06 -0800 (PST) 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 9122E68C085; Mon, 20 Feb 2023 20:54:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D75CD68BEE9 for ; Mon, 20 Feb 2023 20:53:55 +0200 (EET) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 9630D2404EE for ; Mon, 20 Feb 2023 19:53:55 +0100 (CET) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id DeQAYj0Kg2Pc for ; Mon, 20 Feb 2023 19:53:54 +0100 (CET) Received: from libav.khirnov.net (unknown [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 D5E362404EC for ; Mon, 20 Feb 2023 19:53:54 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 2601F3A02E1 for ; Mon, 20 Feb 2023 19:53:48 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 20 Feb 2023 19:53:47 +0100 Message-Id: <20230220185347.25008-1-anton@khirnov.net> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] lavc: disable an obsolete hack for real video 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: 1pRee5JvdF/F AVCodecContext.slice_{count,offset} are unneeded since 2007, commit 383b123ed37df4ff99010646f1fa5911ff1428cc and following. Deprecate those fields. --- libavcodec/avcodec.h | 4 ++++ libavcodec/options_table.h | 2 ++ libavcodec/pthread_frame.c | 8 ++++++++ libavcodec/rv10.c | 28 +++++++++++----------------- libavcodec/rv34.c | 14 +++++--------- libavcodec/version_major.h | 1 + 6 files changed, 31 insertions(+), 26 deletions(-) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 39881a1d2b..998bf457ba 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -771,11 +771,13 @@ typedef struct AVCodecContext { */ float dark_masking; +#if FF_API_SLICE_OFFSET /** * slice count * - encoding: Set by libavcodec. * - decoding: Set by user (or 0). */ + attribute_deprecated int slice_count; /** @@ -783,7 +785,9 @@ typedef struct AVCodecContext { * - encoding: Set/allocated by libavcodec. * - decoding: Set/allocated by user (or NULL). */ + attribute_deprecated int *slice_offset; +#endif /** * sample aspect ratio (0 if unknown) diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h index 4fea57673a..f331ce2861 100644 --- a/libavcodec/options_table.h +++ b/libavcodec/options_table.h @@ -177,7 +177,9 @@ static const AVOption avcodec_options[] = { {"xvidmmx", "deprecated, for compatibility only", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_XVID }, INT_MIN, INT_MAX, V|E|D, "idct"}, {"faani", "floating point AAN IDCT", 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_FAAN }, INT_MIN, INT_MAX, V|D|E, "idct"}, {"simpleauto", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEAUTO }, INT_MIN, INT_MAX, V|E|D, "idct"}, +#if FF_API_SLICE_OFFSET {"slice_count", NULL, OFFSET(slice_count), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, INT_MIN, INT_MAX}, +#endif {"ec", "set error concealment strategy", OFFSET(error_concealment), AV_OPT_TYPE_FLAGS, {.i64 = 3 }, INT_MIN, INT_MAX, V|D, "ec"}, {"guess_mvs", "iterative motion vector (MV) search (slow)", 0, AV_OPT_TYPE_CONST, {.i64 = FF_EC_GUESS_MVS }, INT_MIN, INT_MAX, V|D, "ec"}, {"deblock", "use strong deblock filter for damaged MBs", 0, AV_OPT_TYPE_CONST, {.i64 = FF_EC_DEBLOCK }, INT_MIN, INT_MAX, V|D, "ec"}, diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index d9d5afaa82..7d0c0364df 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -374,6 +374,8 @@ FF_DISABLE_DEPRECATION_WARNINGS FF_ENABLE_DEPRECATION_WARNINGS #endif +#if FF_API_SLICE_OFFSET +FF_DISABLE_DEPRECATION_WARNINGS if (src->slice_count && src->slice_offset) { if (dst->slice_count < src->slice_count) { int err = av_reallocp_array(&dst->slice_offset, src->slice_count, @@ -385,6 +387,8 @@ FF_ENABLE_DEPRECATION_WARNINGS src->slice_count * sizeof(*dst->slice_offset)); } dst->slice_count = src->slice_count; +FF_ENABLE_DEPRECATION_WARNINGS +#endif av_packet_unref(dst->internal->last_pkt_props); err = av_packet_copy_props(dst->internal->last_pkt_props, src->internal->last_pkt_props); @@ -686,7 +690,11 @@ void ff_frame_thread_free(AVCodecContext *avctx, int thread_count) av_freep(&ctx->priv_data); } +#if FF_API_SLICE_OFFSET +FF_DISABLE_DEPRECATION_WARNINGS av_freep(&ctx->slice_offset); +FF_ENABLE_DEPRECATION_WARNINGS +#endif av_buffer_unref(&ctx->internal->pool); av_packet_free(&ctx->internal->last_pkt_props); diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 2233edfca5..bb1ead5002 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -587,10 +587,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf, static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n) { - if (avctx->slice_count) - return avctx->slice_offset[n]; - else - return AV_RL32(buf + n * 8); + return AV_RL32(buf + n * 8); } static int rv10_decode_frame(AVCodecContext *avctx, AVFrame *pict, @@ -610,21 +607,18 @@ static int rv10_decode_frame(AVCodecContext *avctx, AVFrame *pict, return 0; } - if (!avctx->slice_count) { - slice_count = (*buf++) + 1; - buf_size--; + slice_count = (*buf++) + 1; + buf_size--; - if (!slice_count || buf_size <= 8 * slice_count) { - av_log(avctx, AV_LOG_ERROR, "Invalid slice count: %d.\n", - slice_count); - return AVERROR_INVALIDDATA; - } + if (!slice_count || buf_size <= 8 * slice_count) { + av_log(avctx, AV_LOG_ERROR, "Invalid slice count: %d.\n", + slice_count); + return AVERROR_INVALIDDATA; + } - slices_hdr = buf + 4; - buf += 8 * slice_count; - buf_size -= 8 * slice_count; - } else - slice_count = avctx->slice_count; + slices_hdr = buf + 4; + buf += 8 * slice_count; + buf_size -= 8 * slice_count; for (i = 0; i < slice_count; i++) { unsigned offset = get_slice_offset(avctx, slices_hdr, i); diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c index be188edc47..45f64666f8 100644 --- a/libavcodec/rv34.c +++ b/libavcodec/rv34.c @@ -1549,8 +1549,7 @@ int ff_rv34_decode_update_thread_context(AVCodecContext *dst, const AVCodecConte static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n, int slice_count, int buf_size) { if (n < slice_count) { - if(avctx->slice_count) return avctx->slice_offset[n]; - else return AV_RL32(buf + n*8 - 4) == 1 ? AV_RL32(buf + n*8) : AV_RB32(buf + n*8); + return AV_RL32(buf + n*8 - 4) == 1 ? AV_RL32(buf + n*8) : AV_RB32(buf + n*8); } else return buf_size; } @@ -1623,13 +1622,10 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame *pict, return 0; } - if(!avctx->slice_count){ - slice_count = (*buf++) + 1; - slices_hdr = buf + 4; - buf += 8 * slice_count; - buf_size -= 1 + 8 * slice_count; - }else - slice_count = avctx->slice_count; + slice_count = (*buf++) + 1; + slices_hdr = buf + 4; + buf += 8 * slice_count; + buf_size -= 1 + 8 * slice_count; offset = get_slice_offset(avctx, slices_hdr, 0, slice_count, buf_size); //parse first slice header to check whether this frame can be decoded diff --git a/libavcodec/version_major.h b/libavcodec/version_major.h index c2f118b262..40db213499 100644 --- a/libavcodec/version_major.h +++ b/libavcodec/version_major.h @@ -45,6 +45,7 @@ #define FF_API_AVCODEC_CHROMA_POS (LIBAVCODEC_VERSION_MAJOR < 61) #define FF_API_VT_HWACCEL_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 61) #define FF_API_AVCTX_FRAME_NUMBER (LIBAVCODEC_VERSION_MAJOR < 61) +#define FF_API_SLICE_OFFSET (LIBAVCODEC_VERSION_MAJOR < 61) // reminder to remove CrystalHD decoders on next major bump #define FF_CODEC_CRYSTAL_HD (LIBAVCODEC_VERSION_MAJOR < 61)