History

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

Andreas Rheinhardt committed 1 year ago

Commit 57d892b1 parent 90ed5dd3 files · +10 −21Browse files

Showing the changes to libavcodec (3 of 3 files). Show all

Unified · Split

3 files
  1. libavcodec/proresdec.c +5 −15
  2. libavcodec/proresdsp.c +4 −5
  3. libavcodec/proresdsp.h +1 −1
libavcodec/proresdec.c+5−15
@@ -132,7 +132,6 @@ static void unpack_alpha_12(GetBitContext *gb, uint16_t *dst, int num_coeffs, · 131 unmodified lines
132132
133133 static av_cold int decode_init(AVCodecContext *avctx)
134134 {
135− int ret = 0;
136135 ProresContext *ctx = avctx->priv_data;
137136 uint8_t idct_permutation[64];
138137
@@ -164,16 +163,15 @@ static av_cold int decode_init(AVCodecContext *avctx) · 25 unmodified lines
164163 av_log(avctx, AV_LOG_WARNING, "Unknown prores profile %d\n", avctx->codec_tag);
165164 }
166165
166+ ctx->unpack_alpha = avctx->bits_per_raw_sample == 10 ?
167+ unpack_alpha_10 : unpack_alpha_12;
168+
167169 av_log(avctx, AV_LOG_DEBUG,
168170 "Auto bitdepth precision. Use %db decoding based on codec tag.\n",
169171 avctx->bits_per_raw_sample);
170172
171173 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);
177175
178176 ff_init_scantable_permutation(idct_permutation,
179177 ctx->prodsp.idct_permutation_type);
@@ -183,15 +181,7 @@ static av_cold int decode_init(AVCodecContext *avctx) · 3 unmodified lines
183181
184182 ctx->pix_fmt = AV_PIX_FMT_NONE;
185183
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;
195185 }
196186
197187 static int decode_frame_header(ProresContext *ctx, const uint8_t *buf,
libavcodec/proresdsp.c+4−5
@@ -22,6 +22,7 @@ · 21 unmodified lines
2222
2323 #include "config.h"
2424 #include "libavutil/attributes.h"
25+#include "libavutil/avassert.h"
2526 #include "libavutil/common.h"
2627 #include "idctdsp.h"
2728 #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
7677 put_pixels_12(out, linesize >> 1, block);
7778 }
7879
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)
8081 {
8182 if (bits_per_raw_sample == 10) {
8283 dsp->idct_put = prores_idct_put_10_c;
8384 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);
8587 dsp->idct_put = prores_idct_put_12_c;
8688 dsp->idct_permutation_type = FF_IDCT_PERM_NONE;
87− } else {
88− return AVERROR_BUG;
8989 }
9090
9191 #if ARCH_X86
@@ -94,5 +94,4 @@ av_cold int ff_proresdsp_init(ProresDSPContext *dsp, int bits_per_raw_sample) · 2 unmodified lines
9494
9595 ff_init_scantable_permutation(dsp->idct_permutation,
9696 dsp->idct_permutation_type);
97− return 0;
9897 }
libavcodec/proresdsp.h+1−1
@@ -32,7 +32,7 @@ typedef struct ProresDSPContext { · 31 unmodified lines
3232 void (*idct_put)(uint16_t *out, ptrdiff_t linesize, int16_t *block, const int16_t *qmat);
3333 } ProresDSPContext;
3434
35−int ff_proresdsp_init(ProresDSPContext *dsp, int bits_per_raw_sample);
35+void ff_proresdsp_init(ProresDSPContext *dsp, int bits_per_raw_sample);
3636
3737 void ff_proresdsp_init_x86(ProresDSPContext *dsp, int bits_per_raw_sample);
3838

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t