summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-02-20 19:47:51 +0100
committerAnton Khirnov <anton@khirnov.net>2023-03-02 21:32:00 +0100
commit432adca5fedcb277b9a715a723cfd40735ec58f8 (patch)
tree68bf173c1fce8c1b2255344f2daa605e59d2ba27
parent79b40ff58c2e6f59d7a5e6d289243a10ff1dccb4 (diff)
lavc: disable an obsolete hack for real video
AVCodecContext.slice_{count,offset} are unneeded since 2007, commit 383b123ed37df4ff99010646f1fa5911ff1428cc and following. Deprecate those fields.
-rw-r--r--libavcodec/avcodec.h4
-rw-r--r--libavcodec/options_table.h2
-rw-r--r--libavcodec/pthread_frame.c8
-rw-r--r--libavcodec/rv10.c28
-rw-r--r--libavcodec/rv34.c14
-rw-r--r--libavcodec/version_major.h1
6 files changed, 31 insertions, 26 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 75775a3693..87ebee22b1 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 31785acbef..74864e19c5 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)