1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

mjpeg: fix fliping with emu edges.

Fixes Ticket121

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2012-08-23 21:53:10 +02:00
parent 628e6d0164
commit 168ddcd331

View File

@ -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;