[FFmpeg-cvslog] mjpeg: fix fliping with emu edges.
Michael Niedermayer
git at videolan.org
Thu Aug 23 22:17:58 CEST 2012
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Aug 23 21:53:10 2012 +0200| [168ddcd33165e8e2f447116c05adf9a4fbeb112e] | committer: Michael Niedermayer
mjpeg: fix fliping with emu edges.
Fixes Ticket121
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=168ddcd33165e8e2f447116c05adf9a4fbeb112e
---
libavcodec/mjpegdec.c | 30 ++++++++++++++++++++++++------
1 file changed, 24 insertions(+), 6 deletions(-)
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 29d47b6..c6297c3 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;
More information about the ffmpeg-cvslog
mailing list