From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTP id 325E74576E
	for <ffmpegdev@gitmailbox.com>; Mon, 20 Feb 2023 18:54:05 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5E5A368C083;
	Mon, 20 Feb 2023 20:54:02 +0200 (EET)
Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D75CD68BEE9
 for <ffmpeg-devel@ffmpeg.org>; 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 <ffmpeg-devel@ffmpeg.org>; 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 <ffmpeg-devel@ffmpeg.org>;
 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 <ffmpeg-devel@ffmpeg.org>; 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 <ffmpeg-devel@ffmpeg.org>; Mon, 20 Feb 2023 19:53:48 +0100 (CET)
From: Anton Khirnov <anton@khirnov.net>
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 <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/20230220185347.25008-1-anton@khirnov.net/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

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)
-- 
2.39.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".