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).
Unified · Split
| @@ -132,7 +132,6 @@ static void unpack_alpha_12(GetBitContext *gb, uint16_t *dst, int num_coeffs, · 131 unmodified lines | ||
| 132 | 132 | |
| 133 | 133 | static av_cold int decode_init(AVCodecContext *avctx) |
| 134 | 134 | { |
| 135 | − int ret = 0; | |
| 136 | 135 | ProresContext *ctx = avctx->priv_data; |
| 137 | 136 | uint8_t idct_permutation[64]; |
| 138 | 137 | |
| @@ -164,16 +163,15 @@ static av_cold int decode_init(AVCodecContext *avctx) · 25 unmodified lines | ||
| 164 | 163 | av_log(avctx, AV_LOG_WARNING, "Unknown prores profile %d\n", avctx->codec_tag); |
| 165 | 164 | } |
| 166 | 165 | |
| 166 | + ctx->unpack_alpha = avctx->bits_per_raw_sample == 10 ? | |
| 167 | + unpack_alpha_10 : unpack_alpha_12; | |
| 168 | + | |
| 167 | 169 | av_log(avctx, AV_LOG_DEBUG, |
| 168 | 170 | "Auto bitdepth precision. Use %db decoding based on codec tag.\n", |
| 169 | 171 | avctx->bits_per_raw_sample); |
| 170 | 172 | |
| 171 | 173 | ff_blockdsp_init(&ctx->bdsp); |
| 172 | − ret = ff_proresdsp_init(&ctx->prodsp, avctx->bits_per_raw_sample); | |
| 173 | − if (ret < 0) { | |
| 174 | − av_log(avctx, AV_LOG_ERROR, "Fail to init proresdsp for bits per raw sample %d\n", avctx->bits_per_raw_sample); | |
| 175 | − return ret; | |
| 176 | − } | |
| 174 | + ff_proresdsp_init(&ctx->prodsp, avctx->bits_per_raw_sample); | |
| 177 | 175 | |
| 178 | 176 | ff_init_scantable_permutation(idct_permutation, |
| 179 | 177 | ctx->prodsp.idct_permutation_type); |
| @@ -183,15 +181,7 @@ static av_cold int decode_init(AVCodecContext *avctx) · 3 unmodified lines | ||
| 183 | 181 | |
| 184 | 182 | ctx->pix_fmt = AV_PIX_FMT_NONE; |
| 185 | 183 | |
| 186 | − if (avctx->bits_per_raw_sample == 10){ | |
| 187 | − ctx->unpack_alpha = unpack_alpha_10; | |
| 188 | − } else if (avctx->bits_per_raw_sample == 12){ | |
| 189 | − ctx->unpack_alpha = unpack_alpha_12; | |
| 190 | − } else { | |
| 191 | − av_log(avctx, AV_LOG_ERROR, "Fail to set unpack_alpha for bits per raw sample %d\n", avctx->bits_per_raw_sample); | |
| 192 | − return AVERROR_BUG; | |
| 193 | − } | |
| 194 | − return ret; | |
| 184 | + return 0; | |
| 195 | 185 | } |
| 196 | 186 | |
| 197 | 187 | static int decode_frame_header(ProresContext *ctx, const uint8_t *buf, |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | |
| 23 | 23 | #include "config.h" |
| 24 | 24 | #include "libavutil/attributes.h" |
| 25 | +#include "libavutil/avassert.h" | |
| 25 | 26 | #include "libavutil/common.h" |
| 26 | 27 | #include "idctdsp.h" |
| 27 | 28 | #include "proresdsp.h" |
| @@ -76,16 +77,15 @@ static void prores_idct_put_12_c(uint16_t *out, ptrdiff_t linesize, int16_t *blo · 48 unmodified lines | ||
| 76 | 77 | put_pixels_12(out, linesize >> 1, block); |
| 77 | 78 | } |
| 78 | 79 | |
| 79 | −av_cold int ff_proresdsp_init(ProresDSPContext *dsp, int bits_per_raw_sample) | |
| 80 | +av_cold void ff_proresdsp_init(ProresDSPContext *dsp, int bits_per_raw_sample) | |
| 80 | 81 | { |
| 81 | 82 | if (bits_per_raw_sample == 10) { |
| 82 | 83 | dsp->idct_put = prores_idct_put_10_c; |
| 83 | 84 | dsp->idct_permutation_type = FF_IDCT_PERM_NONE; |
| 84 | − } else if (bits_per_raw_sample == 12) { | |
| 85 | + } else { | |
| 86 | + av_assert1(bits_per_raw_sample == 12); | |
| 85 | 87 | dsp->idct_put = prores_idct_put_12_c; |
| 86 | 88 | dsp->idct_permutation_type = FF_IDCT_PERM_NONE; |
| 87 | − } else { | |
| 88 | − return AVERROR_BUG; | |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | #if ARCH_X86 |
| @@ -94,5 +94,4 @@ av_cold int ff_proresdsp_init(ProresDSPContext *dsp, int bits_per_raw_sample) · 2 unmodified lines | ||
| 94 | 94 | |
| 95 | 95 | ff_init_scantable_permutation(dsp->idct_permutation, |
| 96 | 96 | dsp->idct_permutation_type); |
| 97 | − return 0; | |
| 98 | 97 | } |
| @@ -32,7 +32,7 @@ typedef struct ProresDSPContext { · 31 unmodified lines | ||
| 32 | 32 | void (*idct_put)(uint16_t *out, ptrdiff_t linesize, int16_t *block, const int16_t *qmat); |
| 33 | 33 | } ProresDSPContext; |
| 34 | 34 | |
| 35 | −int ff_proresdsp_init(ProresDSPContext *dsp, int bits_per_raw_sample); | |
| 35 | +void ff_proresdsp_init(ProresDSPContext *dsp, int bits_per_raw_sample); | |
| 36 | 36 | |
| 37 | 37 | void ff_proresdsp_init_x86(ProresDSPContext *dsp, int bits_per_raw_sample); |
| 38 | 38 | |