[FFmpeg-cvslog] avcodec/prores{dec,dsp}: Remove always-false checks
Andreas Rheinhardt
git at videolan.org
Thu Feb 27 16:55:00 EET 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Mon Feb 24 11:35:33 2025 +0100| [57d892bd7b22ecf7e29a394c95dc19487cb84dbb] | committer: Andreas Rheinhardt
avcodec/prores{dec,dsp}: Remove always-false checks
avctx->bits_per_raw_sample is always 10 or 12 here;
the checks have been added in preparation for making
bits_per_raw_sample user-settable via an AVOption,
but this never happened.
While just at it, also set unpack_alpha earlier
(where bits_per_raw_sample is set).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=57d892bd7b22ecf7e29a394c95dc19487cb84dbb
---
libavcodec/proresdec.c | 20 +++++---------------
libavcodec/proresdsp.c | 9 ++++-----
libavcodec/proresdsp.h | 2 +-
3 files changed, 10 insertions(+), 21 deletions(-)
diff --git a/libavcodec/proresdec.c b/libavcodec/proresdec.c
index f534b7b6b1..75cc2dcb6a 100644
--- a/libavcodec/proresdec.c
+++ b/libavcodec/proresdec.c
@@ -132,7 +132,6 @@ static void unpack_alpha_12(GetBitContext *gb, uint16_t *dst, int num_coeffs,
static av_cold int decode_init(AVCodecContext *avctx)
{
- int ret = 0;
ProresContext *ctx = avctx->priv_data;
uint8_t idct_permutation[64];
@@ -164,16 +163,15 @@ static av_cold int decode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_WARNING, "Unknown prores profile %d\n", avctx->codec_tag);
}
+ ctx->unpack_alpha = avctx->bits_per_raw_sample == 10 ?
+ unpack_alpha_10 : unpack_alpha_12;
+
av_log(avctx, AV_LOG_DEBUG,
"Auto bitdepth precision. Use %db decoding based on codec tag.\n",
avctx->bits_per_raw_sample);
ff_blockdsp_init(&ctx->bdsp);
- ret = ff_proresdsp_init(&ctx->prodsp, avctx->bits_per_raw_sample);
- if (ret < 0) {
- av_log(avctx, AV_LOG_ERROR, "Fail to init proresdsp for bits per raw sample %d\n", avctx->bits_per_raw_sample);
- return ret;
- }
+ ff_proresdsp_init(&ctx->prodsp, avctx->bits_per_raw_sample);
ff_init_scantable_permutation(idct_permutation,
ctx->prodsp.idct_permutation_type);
@@ -183,15 +181,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
ctx->pix_fmt = AV_PIX_FMT_NONE;
- if (avctx->bits_per_raw_sample == 10){
- ctx->unpack_alpha = unpack_alpha_10;
- } else if (avctx->bits_per_raw_sample == 12){
- ctx->unpack_alpha = unpack_alpha_12;
- } else {
- av_log(avctx, AV_LOG_ERROR, "Fail to set unpack_alpha for bits per raw sample %d\n", avctx->bits_per_raw_sample);
- return AVERROR_BUG;
- }
- return ret;
+ return 0;
}
static int decode_frame_header(ProresContext *ctx, const uint8_t *buf,
diff --git a/libavcodec/proresdsp.c b/libavcodec/proresdsp.c
index bc253e55f7..d20b9d938a 100644
--- a/libavcodec/proresdsp.c
+++ b/libavcodec/proresdsp.c
@@ -22,6 +22,7 @@
#include "config.h"
#include "libavutil/attributes.h"
+#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "idctdsp.h"
#include "proresdsp.h"
@@ -76,16 +77,15 @@ static void prores_idct_put_12_c(uint16_t *out, ptrdiff_t linesize, int16_t *blo
put_pixels_12(out, linesize >> 1, block);
}
-av_cold int ff_proresdsp_init(ProresDSPContext *dsp, int bits_per_raw_sample)
+av_cold void ff_proresdsp_init(ProresDSPContext *dsp, int bits_per_raw_sample)
{
if (bits_per_raw_sample == 10) {
dsp->idct_put = prores_idct_put_10_c;
dsp->idct_permutation_type = FF_IDCT_PERM_NONE;
- } else if (bits_per_raw_sample == 12) {
+ } else {
+ av_assert1(bits_per_raw_sample == 12);
dsp->idct_put = prores_idct_put_12_c;
dsp->idct_permutation_type = FF_IDCT_PERM_NONE;
- } else {
- return AVERROR_BUG;
}
#if ARCH_X86
@@ -94,5 +94,4 @@ av_cold int ff_proresdsp_init(ProresDSPContext *dsp, int bits_per_raw_sample)
ff_init_scantable_permutation(dsp->idct_permutation,
dsp->idct_permutation_type);
- return 0;
}
diff --git a/libavcodec/proresdsp.h b/libavcodec/proresdsp.h
index 966ba3d797..ef09d86380 100644
--- a/libavcodec/proresdsp.h
+++ b/libavcodec/proresdsp.h
@@ -32,7 +32,7 @@ typedef struct ProresDSPContext {
void (*idct_put)(uint16_t *out, ptrdiff_t linesize, int16_t *block, const int16_t *qmat);
} ProresDSPContext;
-int ff_proresdsp_init(ProresDSPContext *dsp, int bits_per_raw_sample);
+void ff_proresdsp_init(ProresDSPContext *dsp, int bits_per_raw_sample);
void ff_proresdsp_init_x86(ProresDSPContext *dsp, int bits_per_raw_sample);
More information about the ffmpeg-cvslog
mailing list