[FFmpeg-cvslog] avcodec/mjpegdec: simplify chroma_height calculation
Michael Niedermayer
git at videolan.org
Tue Oct 21 21:43:03 CEST 2014
ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Tue Oct 21 20:56:17 2014 +0200| [d5a3a20d1e19e819b4f4e17831c30d236407c334] | committer: Michael Niedermayer
avcodec/mjpegdec: simplify chroma_height calculation
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d5a3a20d1e19e819b4f4e17831c30d236407c334
---
libavcodec/mjpegdec.c | 15 +++++++--------
libavcodec/mjpegdec.h | 1 -
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 2f9fe39..17421dd 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -444,12 +444,10 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
s->avctx->pix_fmt = AV_PIX_FMT_GBRAP;
s->upscale_v = 6;
s->upscale_h = 6;
- s->chroma_height = s->height;
} else if (s->adobe_transform == 2 && s->bits <= 8) {
s->avctx->pix_fmt = AV_PIX_FMT_YUVA444P;
s->upscale_v = 6;
s->upscale_h = 6;
- s->chroma_height = s->height;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
} else {
if (s->bits <= 8) s->avctx->pix_fmt = AV_PIX_FMT_YUVA420P;
@@ -466,7 +464,6 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
else
goto unk_pixfmt;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- s->chroma_height = s->height;
break;
case 0x22221100:
case 0x22112200:
@@ -475,7 +472,6 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
else
goto unk_pixfmt;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- s->chroma_height = (s->height + 1) / 2;
break;
case 0x11000000:
case 0x13000000:
@@ -499,7 +495,6 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
else
goto unk_pixfmt;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- s->chroma_height = (s->height + 1) / 2;
break;
case 0x21111100:
if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_YUVJ422P;
@@ -521,7 +516,6 @@ int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
if (pix_fmt_id == 0x42111100) {
s->upscale_h = 6;
- s->chroma_height = (s->height + 1) / 2;
} else if (pix_fmt_id == 0x24111100) {
s->upscale_v = 6;
}
@@ -2103,12 +2097,17 @@ the_end:
for (p = 0; p<4; p++) {
uint8_t *line = s->picture_ptr->data[p];
int w = s->width;
+ int h = s->height;
if (!(s->upscale_h & (1<<p)))
continue;
- if (p==1 || p==2)
+ if (p==1 || p==2) {
w >>= hshift;
+ h = FF_CEIL_RSHIFT(h, vshift);
+ }
+ if (s->upscale_v & (1<<p))
+ h = (h+1)>>1;
av_assert0(w > 0);
- for (i = 0; i < s->chroma_height; i++) {
+ for (i = 0; i < h; i++) {
if (is16bit) ((uint16_t*)line)[w - 1] = ((uint16_t*)line)[(w - 1) / 2];
else line[w - 1] = line[(w - 1) / 2];
for (index = w - 2; index > 0; index--) {
diff --git a/libavcodec/mjpegdec.h b/libavcodec/mjpegdec.h
index 53a412c..deacabe 100644
--- a/libavcodec/mjpegdec.h
+++ b/libavcodec/mjpegdec.h
@@ -63,7 +63,6 @@ typedef struct MJpegDecodeContext {
int progressive;
int rgb;
int upscale_h;
- int chroma_height;
int upscale_v;
int rct; /* standard rct */
int pegasus_rct; /* pegasus reversible colorspace transform */
More information about the ffmpeg-cvslog
mailing list