(s->h_count[2] << 12) | (s->v_count[2] << 8) |
(s->h_count[3] << 4) | s->v_count[3];
av_log(s->avctx, AV_LOG_DEBUG, "pix fmt id %x\n", pix_fmt_id);
- if(!(pix_fmt_id & 0x10101010))
+ //NOTE we do not allocate pictures large enough for the possible padding of h/v_count being 4
+ if(!(pix_fmt_id & 0xD0D0D0D0))
pix_fmt_id-= (pix_fmt_id & 0xF0F0F0F0)>>1;
- if(!(pix_fmt_id & 0x01010101))
+ if(!(pix_fmt_id & 0x0D0D0D0D))
pix_fmt_id-= (pix_fmt_id & 0x0F0F0F0F)>>1;
switch(pix_fmt_id){
case 0x11111100:
if(s->rgb){
- s->avctx->pix_fmt = PIX_FMT_RGB32;
+ s->avctx->pix_fmt = PIX_FMT_BGRA;
}else
s->avctx->pix_fmt = s->cs_itu601 ? PIX_FMT_YUV444P : PIX_FMT_YUVJ444P;
assert(s->nb_components==3);
}
}else{
for(mb_x = 0; mb_x < s->mb_width; mb_x++) {
- ptr[4*mb_x+0] = buffer[mb_x][0];
+ ptr[4*mb_x+0] = buffer[mb_x][2];
ptr[4*mb_x+1] = buffer[mb_x][1];
- ptr[4*mb_x+2] = buffer[mb_x][2];
+ ptr[4*mb_x+2] = buffer[mb_x][0];
}
}
}
uint8_t* data[MAX_COMPONENTS];
int linesize[MAX_COMPONENTS];
+ if(s->flipped && s->avctx->flags & CODEC_FLAG_EMU_EDGE) {
+ av_log(s->avctx, AV_LOG_ERROR, "Can not flip image with CODEC_FLAG_EMU_EDGE set!\n");
+ s->flipped = 0;
+ }
for(i=0; i < nb_components; i++) {
int c = s->comp_index[i];
data[c] = s->picture.data[c];
s->coefs_finished[c] |= 1;
if(s->flipped) {
//picture should be flipped upside-down for this codec
- assert(!(s->avctx->flags & CODEC_FLAG_EMU_EDGE));
data[c] += (linesize[c] * (s->v_scount[i] * (8 * s->mb_height -((s->height/s->v_max)&7)) - 1 ));
linesize[c] *= -1;
}
/* XXX: verify len field validity */
len = get_bits(&s->gb, 16);
nb_components = get_bits(&s->gb, 8);
+ if (nb_components == 0 || nb_components > MAX_COMPONENTS){
+ av_log(s->avctx, AV_LOG_ERROR, "decode_sos: nb_components (%d) unsupported\n", nb_components);
+ return -1;
+ }
if (len != 6+2*nb_components)
{
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: invalid len (%d)\n", len);
av_log(s->avctx, AV_LOG_ERROR, "decode_sos: index(%d) out of components\n", index);
return -1;
}
+ /* Metasoft MJPEG codec has Cb and Cr swapped */
+ if (s->avctx->codec_tag == MKTAG('M', 'T', 'S', 'J')
+ && nb_components == 3 && s->nb_components == 3 && i)
+ index = 3 - i;
s->comp_index[i] = index;
}
if(s->avctx->debug & FF_DEBUG_PICT_INFO)
- av_log(s->avctx, AV_LOG_DEBUG, "%s %s p:%d >>:%d ilv:%d bits:%d %s\n", s->lossless ? "lossless" : "sequencial DCT", s->rgb ? "RGB" : "",
+ av_log(s->avctx, AV_LOG_DEBUG, "%s %s p:%d >>:%d ilv:%d bits:%d %s\n", s->lossless ? "lossless" : "sequential DCT", s->rgb ? "RGB" : "",
predictor, point_transform, ilv, s->bits,
s->pegasus_rct ? "PRCT" : (s->rct ? "RCT" : ""));
else if(!strcmp(cbuf, "CS=ITU601")){
s->cs_itu601= 1;
}
- else if(len > 20 && !strncmp(cbuf, "Intel(R) JPEG Library", 21)){
+ else if((len > 20 && !strncmp(cbuf, "Intel(R) JPEG Library", 21)) ||
+ (len > 19 && !strncmp(cbuf, "Metasoft MJPEG Codec", 20))){
s->flipped = 1;
}
AVCodec mjpeg_decoder = {
"mjpeg",
- CODEC_TYPE_VIDEO,
+ AVMEDIA_TYPE_VIDEO,
CODEC_ID_MJPEG,
sizeof(MJpegDecodeContext),
ff_mjpeg_decode_init,
AVCodec thp_decoder = {
"thp",
- CODEC_TYPE_VIDEO,
+ AVMEDIA_TYPE_VIDEO,
CODEC_ID_THP,
sizeof(MJpegDecodeContext),
ff_mjpeg_decode_init,