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 | static av_cold int decode_init(AVCodecContext *avctx) | 133 | static av_cold int decode_init(AVCodecContext *avctx) |
| 134 | { | 134 | { |
| 135 | int ret = 0; | ||
| 136 | ProresContext *ctx = avctx->priv_data; | 135 | ProresContext *ctx = avctx->priv_data; |
| 137 | uint8_t idct_permutation[64]; | 136 | uint8_t idct_permutation[64]; |
| 138 | 137 | ||
| @@ -164,16 +163,15 @@ static av_cold int decode_init(AVCodecContext *avctx) · 25 unmodified lines | |||
| 164 | av_log(avctx, AV_LOG_WARNING, "Unknown prores profile %d\n", avctx->codec_tag); | 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 | av_log(avctx, AV_LOG_DEBUG, | 169 | av_log(avctx, AV_LOG_DEBUG, |
| 168 | "Auto bitdepth precision. Use %db decoding based on codec tag.\n", | 170 | "Auto bitdepth precision. Use %db decoding based on codec tag.\n", |
| 169 | avctx->bits_per_raw_sample); | 171 | avctx->bits_per_raw_sample); |
| 170 | 172 | ||
| 171 | ff_blockdsp_init(&ctx->bdsp); | 173 | ff_blockdsp_init(&ctx->bdsp); |
| 172 | ret = ff_proresdsp_init(&ctx->prodsp, avctx->bits_per_raw_sample); | 174 | 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 | } | ||
| 177 | 175 | ||
| 178 | ff_init_scantable_permutation(idct_permutation, | 176 | ff_init_scantable_permutation(idct_permutation, |
| 179 | ctx->prodsp.idct_permutation_type); | 177 | ctx->prodsp.idct_permutation_type); |
| @@ -183,15 +181,7 @@ static av_cold int decode_init(AVCodecContext *avctx) · 3 unmodified lines | |||
| 183 | 181 | ||
| 184 | ctx->pix_fmt = AV_PIX_FMT_NONE; | 182 | ctx->pix_fmt = AV_PIX_FMT_NONE; |
| 185 | 183 | ||
| 186 | if (avctx->bits_per_raw_sample == 10){ | 184 | return 0; |
| 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; | ||
| 195 | } | 185 | } |
| 196 | 186 | ||
| 197 | static int decode_frame_header(ProresContext *ctx, const uint8_t *buf, | 187 | static int decode_frame_header(ProresContext *ctx, const uint8_t *buf, |
| @@ -22,6 +22,7 @@ · 21 unmodified lines | |||
| 22 | 22 | ||
| 23 | #include "config.h" | 23 | #include "config.h" |
| 24 | #include "libavutil/attributes.h" | 24 | #include "libavutil/attributes.h" |
| 25 | #include "libavutil/avassert.h" | ||
| 25 | #include "libavutil/common.h" | 26 | #include "libavutil/common.h" |
| 26 | #include "idctdsp.h" | 27 | #include "idctdsp.h" |
| 27 | #include "proresdsp.h" | 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 | put_pixels_12(out, linesize >> 1, block); | 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 | if (bits_per_raw_sample == 10) { | 82 | if (bits_per_raw_sample == 10) { |
| 82 | dsp->idct_put = prores_idct_put_10_c; | 83 | dsp->idct_put = prores_idct_put_10_c; |
| 83 | dsp->idct_permutation_type = FF_IDCT_PERM_NONE; | 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 | dsp->idct_put = prores_idct_put_12_c; | 87 | dsp->idct_put = prores_idct_put_12_c; |
| 86 | dsp->idct_permutation_type = FF_IDCT_PERM_NONE; | 88 | dsp->idct_permutation_type = FF_IDCT_PERM_NONE; |
| 87 | } else { | ||
| 88 | return AVERROR_BUG; | ||
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | #if ARCH_X86 | 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 | ff_init_scantable_permutation(dsp->idct_permutation, | 95 | ff_init_scantable_permutation(dsp->idct_permutation, |
| 96 | dsp->idct_permutation_type); | 96 | dsp->idct_permutation_type); |
| 97 | return 0; | ||
| 98 | } | 97 | } |
| @@ -32,7 +32,7 @@ typedef struct ProresDSPContext { · 31 unmodified lines | |||
| 32 | void (*idct_put)(uint16_t *out, ptrdiff_t linesize, int16_t *block, const int16_t *qmat); | 32 | void (*idct_put)(uint16_t *out, ptrdiff_t linesize, int16_t *block, const int16_t *qmat); |
| 33 | } ProresDSPContext; | 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 | void ff_proresdsp_init_x86(ProresDSPContext *dsp, int bits_per_raw_sample); | 37 | void ff_proresdsp_init_x86(ProresDSPContext *dsp, int bits_per_raw_sample); |
| 38 | 38 | ||