/* quantize tables */
int ff_mjpeg_decode_dqt(MJpegDecodeContext *s)
{
- int len, index, i, j;
+ int len, index, i;
len = get_bits(&s->gb, 16) - 2;
av_log(s->avctx, AV_LOG_DEBUG, "index=%d\n", index);
/* read quant table */
for (i = 0; i < 64; i++) {
- j = s->scantable.permutated[i];
- s->quant_matrixes[index][j] = get_bits(&s->gb, pr ? 16 : 8);
+ s->quant_matrixes[index][i] = get_bits(&s->gb, pr ? 16 : 8);
}
// XXX FIXME finetune, and perhaps add dc too
- s->qscale[index] = FFMAX(s->quant_matrixes[index][s->scantable.permutated[1]],
- s->quant_matrixes[index][s->scantable.permutated[8]]) >> 1;
+ s->qscale[index] = FFMAX(s->quant_matrixes[index][1],
+ s->quant_matrixes[index][8]) >> 1;
av_log(s->avctx, AV_LOG_DEBUG, "qscale[%d]: %d\n",
index, s->qscale[index]);
len -= 1 + 64 * (1+pr);
}
if (s->avctx->bits_per_raw_sample != bits) {
- av_log(s->avctx, AV_LOG_INFO, "Changing bps to %d\n", bits);
+ av_log(s->avctx, s->avctx->bits_per_raw_sample > 0 ? AV_LOG_INFO : AV_LOG_DEBUG, "Changing bps from %d to %d\n", s->avctx->bits_per_raw_sample, bits);
s->avctx->bits_per_raw_sample = bits;
init_idct(s->avctx);
}
return AVERROR_BUG;
}
+ if (s->avctx->skip_frame == AVDISCARD_ALL) {
+ s->picture_ptr->pict_type = AV_PICTURE_TYPE_I;
+ s->picture_ptr->key_frame = 1;
+ s->got_picture = 1;
+ return 0;
+ }
+
av_frame_unref(s->picture_ptr);
if (ff_get_buffer(s->avctx, s->picture_ptr, AV_GET_BUFFER_FLAG_REF) < 0)
return -1;
return AVERROR_INVALIDDATA;
}
j = s->scantable.permutated[i];
- block[j] = level * quant_matrix[j];
+ block[j] = level * quant_matrix[i];
}
} while (i < 63);
CLOSE_READER(re, &s->gb);}
if (i >= se) {
if (i == se) {
j = s->scantable.permutated[se];
- block[j] = level * (quant_matrix[j] << Al);
+ block[j] = level * (quant_matrix[se] << Al);
break;
}
av_log(s->avctx, AV_LOG_ERROR, "error count: %d\n", i);
return AVERROR_INVALIDDATA;
}
j = s->scantable.permutated[i];
- block[j] = level * (quant_matrix[j] << Al);
+ block[j] = level * (quant_matrix[i] << Al);
} else {
if (run == 0xF) {// ZRL - skip 15 coefficients
i += 15;
UPDATE_CACHE(re, &s->gb); \
sign = block[j] >> 15; \
block[j] += SHOW_UBITS(re, &s->gb, 1) * \
- ((quant_matrix[j] ^ sign) - sign) << Al; \
+ ((quant_matrix[i] ^ sign) - sign) << Al; \
LAST_SKIP_BITS(re, &s->gb, 1); \
}
ZERO_RUN;
j = s->scantable.permutated[i];
val--;
- block[j] = ((quant_matrix[j] << Al) ^ val) - val;
+ block[j] = ((quant_matrix[i] << Al) ^ val) - val;
if (i == se) {
if (i > *last_nnz)
*last_nnz = i;
return AVERROR_INVALIDDATA;
}
- if (!Al) {
- // s->coefs_finished is a bitmask for coefficients coded
- // ss and se are parameters telling start and end coefficients
- s->coefs_finished[c] |= (2ULL << se) - (1ULL << ss);
- last_scan = !~s->coefs_finished[c];
- }
+ // s->coefs_finished is a bitmask for coefficients coded
+ // ss and se are parameters telling start and end coefficients
+ s->coefs_finished[c] |= (2ULL << se) - (1ULL << ss);
+ last_scan = !Al && !~s->coefs_finished[c];
if (s->interlaced && s->bottom_field)
data += linesize >> 1;
goto out;
}
- if (id == AV_RB32("Adob") && (get_bits(&s->gb, 8) == 'e')) {
+ if ( id == AV_RB32("Adob")
+ && len >= 7
+ && show_bits(&s->gb, 8) == 'e'
+ && show_bits_long(&s->gb, 32) != AV_RB32("e_CM")) {
+ skip_bits(&s->gb, 8); /* 'e' */
skip_bits(&s->gb, 16); /* version */
skip_bits(&s->gb, 16); /* flags0 */
skip_bits(&s->gb, 16); /* flags1 */
else if ((!strncmp(cbuf, "Intel(R) JPEG Library, version 1", 32) && s->avctx->codec_tag) ||
(!strncmp(cbuf, "Metasoft MJPEG Codec", 20)))
s->flipped = 1;
- else if (!strcmp(cbuf, "MULTISCOPE II"))
+ else if (!strcmp(cbuf, "MULTISCOPE II")) {
+ s->avctx->sample_aspect_ratio = (AVRational) { 1, 2 };
s->multiscope = 2;
+ }
av_free(cbuf);
}
avctx->pix_fmt == AV_PIX_FMT_GBRAP
);
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
- for (p = 0; p<4; p++) {
+ av_assert0(s->nb_components == av_pix_fmt_count_planes(s->picture_ptr->format));
+ for (p = 0; p<s->nb_components; p++) {
uint8_t *line = s->picture_ptr->data[p];
int w = s->width;
int h = s->height;
avctx->pix_fmt == AV_PIX_FMT_GBRAP
);
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
- for (p = 0; p < 4; p++) {
+ av_assert0(s->nb_components == av_pix_fmt_count_planes(s->picture_ptr->format));
+ for (p = 0; p < s->nb_components; p++) {
uint8_t *dst;
int w = s->width;
int h = s->height;
if (s->flipped) {
int j;
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
- for (index=0; index<4; index++) {
+ av_assert0(s->nb_components == av_pix_fmt_count_planes(s->picture_ptr->format));
+ for (index=0; index<s->nb_components; index++) {
uint8_t *dst = s->picture_ptr->data[index];
int w = s->picture_ptr->width;
int h = s->picture_ptr->height;
if (s->adobe_transform == 0 && s->avctx->pix_fmt == AV_PIX_FMT_GBRAP) {
int w = s->picture_ptr->width;
int h = s->picture_ptr->height;
+ av_assert0(s->nb_components == 4);
for (i=0; i<h; i++) {
int j;
uint8_t *dst[4];
if (s->adobe_transform == 2 && s->avctx->pix_fmt == AV_PIX_FMT_YUVA444P) {
int w = s->picture_ptr->width;
int h = s->picture_ptr->height;
+ av_assert0(s->nb_components == 4);
for (i=0; i<h; i++) {
int j;
uint8_t *dst[4];