avcodec/mjpegdec: remove not needed operations on channel identifiers

This commit is contained in:
Paul B Mahol 2022-09-30 18:56:43 +02:00
parent 9d52844aba
commit 9a494b82d9
1 changed files with 8 additions and 14 deletions

View File

@ -373,10 +373,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
s->v_max = 1;
for (i = 0; i < nb_components; i++) {
/* component id */
int id = get_bits(&s->gb, 8);
if (id == 0)
return AVERROR_INVALIDDATA;
s->component_id[i] = id - 1;
s->component_id[i] = get_bits(&s->gb, 8);
h_count[i] = get_bits(&s->gb, 4);
v_count[i] = get_bits(&s->gb, 4);
/* compute hmax and vmax (only used in interleaved case) */
@ -401,10 +398,10 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
s->component_id[i], s->quant_index[i]);
}
if ( nb_components == 4
&& s->component_id[0] == 'C' - 1
&& s->component_id[1] == 'M' - 1
&& s->component_id[2] == 'Y' - 1
&& s->component_id[3] == 'K' - 1)
&& s->component_id[0] == 'C'
&& s->component_id[1] == 'M'
&& s->component_id[2] == 'Y'
&& s->component_id[3] == 'K')
s->adobe_transform = 0;
if (s->ls && (s->h_max > 1 || s->v_max > 1)) {
@ -526,7 +523,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
s->avctx->pix_fmt = s->bits <= 9 ? AV_PIX_FMT_BGR24 : AV_PIX_FMT_BGR48;
else {
if ( s->adobe_transform == 0
|| s->component_id[0] == 'R' - 1 && s->component_id[1] == 'G' - 1 && s->component_id[2] == 'B' - 1) {
|| s->component_id[0] == 'R' && s->component_id[1] == 'G' && s->component_id[2] == 'B') {
s->avctx->pix_fmt = s->bits <= 8 ? AV_PIX_FMT_GBRP : AV_PIX_FMT_GBRP16;
} else {
if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
@ -599,7 +596,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
case 0x14111100:
case 0x22211100:
case 0x22112100:
if (s->component_id[0] == 'Q' && s->component_id[1] == 'F' && s->component_id[2] == 'A') {
if (s->component_id[0] == 'R' && s->component_id[1] == 'G' && s->component_id[B] == 'B') {
if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_GBRP;
else
goto unk_pixfmt;
@ -614,7 +611,7 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
}
break;
case 0x21111100:
if (s->component_id[0] == 'Q' && s->component_id[1] == 'F' && s->component_id[2] == 'A') {
if (s->component_id[0] == 'R' && s->component_id[1] == 'G' && s->component_id[2] == 'B') {
if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_GBRP;
else
goto unk_pixfmt;
@ -1681,9 +1678,6 @@ int ff_mjpeg_decode_sos(MJpegDecodeContext *s, const uint8_t *mb_bitmask,
}
for (i = 0; i < nb_components; i++) {
id = get_bits(&s->gb, 8);
if (id == 0)
return AVERROR_INVALIDDATA;
id -= 1;
av_log(s->avctx, AV_LOG_DEBUG, "component: %d\n", id);
/* find component index */
for (index = 0; index < s->nb_components; index++)