aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2022-09-30 18:56:43 +0200
committerPaul B Mahol <onemda@gmail.com>2022-09-30 19:10:32 +0200
commit9a494b82d998823d0de68cb6b8db83cc451d1781 (patch)
treeaa82e575c13aad1cca18de250a3ae00c07e35f6c
parent9d52844aba797343e27ba6c35ca47aec459bdf22 (diff)
downloadffmpeg-9a494b82d998823d0de68cb6b8db83cc451d1781.tar.gz
avcodec/mjpegdec: remove not needed operations on channel identifiers
-rw-r--r--libavcodec/mjpegdec.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 559bda5e6f..85d1129f30 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -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++)