Commit 643fc8f1 authored by Carl Eugen Hoyos's avatar Carl Eugen Hoyos

Flip (M)JPEG frames encoded by Intel JPEG library.

Fixes issues 1464 and 1468.

Originally committed as revision 20312 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 11eb3cea
...@@ -105,6 +105,8 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx) ...@@ -105,6 +105,8 @@ av_cold int ff_mjpeg_decode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_DEBUG, "mjpeg bottom field first\n"); av_log(avctx, AV_LOG_DEBUG, "mjpeg bottom field first\n");
} }
} }
if (avctx->codec->id == CODEC_ID_AMV)
s->flipped = 1;
return 0; return 0;
} }
...@@ -773,7 +775,7 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, i ...@@ -773,7 +775,7 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah, i
data[c] = s->picture.data[c]; data[c] = s->picture.data[c];
linesize[c]=s->linesize[c]; linesize[c]=s->linesize[c];
s->coefs_finished[c] |= 1; s->coefs_finished[c] |= 1;
if(s->avctx->codec->id==CODEC_ID_AMV) { if(s->flipped) {
//picture should be flipped upside-down for this codec //picture should be flipped upside-down for this codec
assert(!(s->avctx->flags & CODEC_FLAG_EMU_EDGE)); 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 )); data[c] += (linesize[c] * (s->v_scount[i] * (8 * s->mb_height -((s->height/s->v_max)&7)) - 1 ));
...@@ -1176,6 +1178,9 @@ static int mjpeg_decode_com(MJpegDecodeContext *s) ...@@ -1176,6 +1178,9 @@ static int mjpeg_decode_com(MJpegDecodeContext *s)
else if(!strcmp(cbuf, "CS=ITU601")){ else if(!strcmp(cbuf, "CS=ITU601")){
s->cs_itu601= 1; s->cs_itu601= 1;
} }
else if(len > 20 && !strncmp(cbuf, "Intel(R) JPEG Library", 21)){
s->flipped = 1;
}
av_free(cbuf); av_free(cbuf);
} }
......
...@@ -101,6 +101,7 @@ typedef struct MJpegDecodeContext { ...@@ -101,6 +101,7 @@ typedef struct MJpegDecodeContext {
int mjpb_skiptosod; int mjpb_skiptosod;
int cur_scan; /* current scan, used by JPEG-LS */ int cur_scan; /* current scan, used by JPEG-LS */
int flipped; /* true if picture is flipped */
} MJpegDecodeContext; } MJpegDecodeContext;
int ff_mjpeg_decode_init(AVCodecContext *avctx); int ff_mjpeg_decode_init(AVCodecContext *avctx);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment