#include "avcodec.h"
#include "blockdsp.h"
#include "copy_block.h"
+#include "idctdsp.h"
#include "internal.h"
#include "mjpeg.h"
#include "mjpegdec.h"
s->avctx = avctx;
ff_blockdsp_init(&s->bdsp, avctx);
ff_hpeldsp_init(&s->hdsp, avctx->flags);
- ff_dsputil_init(&s->dsp, avctx);
- ff_init_scantable(s->dsp.idct_permutation, &s->scantable, ff_zigzag_direct);
+ ff_idctdsp_init(&s->idsp, avctx);
+ ff_init_scantable(s->idsp.idct_permutation, &s->scantable,
+ ff_zigzag_direct);
s->buffer_size = 0;
s->buffer = NULL;
s->start_code = -1;
if (!(pix_fmt_id & 0x0D0D0D0D))
pix_fmt_id -= (pix_fmt_id & 0x0F0F0F0F) >> 1;
+ for (i = 0; i < 8; i++) {
+ int j = 6 + (i&1) - (i&6);
+ int is = (pix_fmt_id >> (4*i)) & 0xF;
+ int js = (pix_fmt_id >> (4*j)) & 0xF;
+
+ if (is == 1 && js != 2 && (i < 2 || i > 5))
+ js = (pix_fmt_id >> ( 8 + 4*(i&1))) & 0xF;
+ if (is == 1 && js != 2 && (i < 2 || i > 5))
+ js = (pix_fmt_id >> (16 + 4*(i&1))) & 0xF;
+
+ if (is == 1 && js == 2) {
+ if (i & 1) s->upscale_h |= 1 << (j/2);
+ else s->upscale_v |= 1 << (j/2);
+ }
+ }
+
switch (pix_fmt_id) {
case 0x11111100:
if (s->rgb)
break;
case 0x12121100:
case 0x22122100:
- if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
- else
- goto unk_pixfmt;
- s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- s->upscale_v = 4;
- s->upscale_h = 2*(pix_fmt_id == 0x22122100);
- s->chroma_height = s->height;
- break;
case 0x21211100:
case 0x22211200:
if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
else
goto unk_pixfmt;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- s->upscale_v = 2*(pix_fmt_id == 0x22211200);
- s->upscale_h = 4;
s->chroma_height = s->height;
break;
case 0x22221100:
+ case 0x22112200:
+ case 0x11222200:
if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
else
goto unk_pixfmt;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- s->upscale_v = 4;
- s->upscale_h = 4;
s->chroma_height = s->height / 2;
break;
case 0x11000000:
else
goto unk_pixfmt;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- s->upscale_h = 4 * (pix_fmt_id == 0x22211100) + 2 * (pix_fmt_id == 0x22112100);
s->chroma_height = s->height / 2;
break;
case 0x21111100:
else
goto unk_pixfmt;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- s->upscale_v = 2 << (pix_fmt_id == 0x22121100);
break;
case 0x22111100:
case 0x42111100:
default:
unk_pixfmt:
av_log(s->avctx, AV_LOG_ERROR, "Unhandled pixel format 0x%x\n", pix_fmt_id);
+ s->upscale_h = s->upscale_v = 0;
return AVERROR_PATCHWELCOME;
}
if ((s->upscale_h || s->upscale_v) && s->avctx->lowres) {
"error y=%d x=%d\n", mb_y, mb_x);
return AVERROR_INVALIDDATA;
}
- s->dsp.idct_put(ptr, linesize[c], s->block);
+ s->idsp.idct_put(ptr, linesize[c], s->block);
if (s->bits & 7)
shift_output(s, ptr, linesize[c]);
}
}
if (last_scan) {
- s->dsp.idct_put(ptr, linesize, *block);
+ s->idsp.idct_put(ptr, linesize, *block);
if (s->bits & 7)
shift_output(s, ptr, linesize);
ptr += bytes_per_pixel*8 >> s->avctx->lowres;
avctx->pix_fmt == AV_PIX_FMT_GBRAP
);
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
- for (p = 1; p<4; p++) {
+ for (p = 0; p<4; p++) {
uint8_t *line = s->picture_ptr->data[p];
- int w;
+ int w = s->width;
if (!(s->upscale_h & (1<<p)))
continue;
- w = s->width >> hshift;
+ if (p==1 || p==2)
+ w >>= hshift;
for (i = 0; i < s->chroma_height; i++) {
for (index = w - 1; index; index--)
line[index] = (line[index / 2] + line[(index + 1) / 2]) >> 1;
avctx->pix_fmt == AV_PIX_FMT_GBRAP
);
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
- for (p = 1; p < 4; p++) {
+ for (p = 0; p < 4; p++) {
uint8_t *dst = &((uint8_t *)s->picture_ptr->data[p])[(s->height - 1) * s->linesize[p]];
- int w;
+ int w = s->width;
if (!(s->upscale_v & (1<<p)))
continue;
- w = s->width >> hshift;
+ if (p==1 || p==2)
+ w >>= hshift;
for (i = s->height - 1; i; i--) {
uint8_t *src1 = &((uint8_t *)s->picture_ptr->data[p])[i / 2 * s->linesize[p]];
uint8_t *src2 = &((uint8_t *)s->picture_ptr->data[p])[(i + 1) / 2 * s->linesize[p]];