1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-26 19:01:44 +02:00

lavc: disable an obsolete hack for real video

AVCodecContext.slice_{count,offset} are unneeded since 2007, commit
383b123ed3 and following. Deprecate those
fields.
This commit is contained in:
Anton Khirnov 2023-02-20 19:47:51 +01:00
parent 79b40ff58c
commit 432adca5fe
6 changed files with 31 additions and 26 deletions

View File

@ -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)

View File

@ -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"},

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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)