aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mjpegdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-08-23 21:53:10 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-08-23 21:53:10 +0200
commit168ddcd33165e8e2f447116c05adf9a4fbeb112e (patch)
treedbd99fb4eabdf49ab1461600e6e8e1afaa62a092 /libavcodec/mjpegdec.c
parent628e6d0164febc8e69b0f10dfa487e8a2dd1a28a (diff)
downloadffmpeg-168ddcd33165e8e2f447116c05adf9a4fbeb112e.tar.gz
mjpeg: fix fliping with emu edges.
Fixes Ticket121 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/mjpegdec.c')
-rw-r--r--libavcodec/mjpegdec.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 29d47b6fef..c6297c3b43 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -967,11 +967,6 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah,
if (mb_bitmask)
init_get_bits(&mb_bitmask_gb, mb_bitmask, s->mb_width * s->mb_height);
- 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;
- }
if (s->flipped && s->avctx->lowres) {
av_log(s->avctx, AV_LOG_ERROR, "Can not flip image with lowres\n");
s->flipped = 0;
@@ -983,7 +978,7 @@ static int mjpeg_decode_scan(MJpegDecodeContext *s, int nb_components, int Ah,
reference_data[c] = reference ? reference->data[c] : NULL;
linesize[c] = s->linesize[c];
s->coefs_finished[c] |= 1;
- if (s->flipped) {
+ if (s->flipped && !(s->avctx->flags & CODEC_FLAG_EMU_EDGE)) {
// picture should be flipped upside-down for this codec
int offset = (linesize[c] * (s->v_scount[i] *
(8 * s->mb_height - ((s->height / s->v_max) & 7)) - 1));
@@ -1795,6 +1790,29 @@ the_end:
dst -= s->linesize[s->upscale_v];
}
}
+ if (s->flipped && (s->avctx->flags & CODEC_FLAG_EMU_EDGE)) {
+ int hshift, vshift, j;
+ avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
+ for (index=0; index<4; index++) {
+ uint8_t *dst = s->picture_ptr->data[index];
+ int w = s->width;
+ int h = s->height;
+ if(index && index<3){
+ w = -((-w) >> hshift);
+ h = -((-h) >> vshift);
+ }
+ if(dst){
+ uint8_t *dst2 = dst + s->linesize[index]*(h-1);
+ for (i=0; i<h/2; i++) {
+ for (j=0; j<w; j++)
+ FFSWAP(int, dst[j], dst2[j]);
+ dst += s->linesize[index];
+ dst2 -= s->linesize[index];
+ }
+ }
+ }
+ }
+
av_log(avctx, AV_LOG_DEBUG, "decode frame unused %td bytes\n",
buf_end - buf_ptr);
// return buf_end - buf_ptr;