else
goto unk_pixfmt;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- s->chroma_height = s->height / 2;
+ s->chroma_height = (s->height + 1) / 2;
break;
case 0x11000000:
case 0x13000000:
else
goto unk_pixfmt;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : AVCOL_RANGE_JPEG;
- s->chroma_height = s->height / 2;
+ 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;
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 / 2;
+ s->chroma_height = (s->height + 1) / 2;
}
break;
case 0x41111100:
int start_code;
int i, index;
int ret = 0;
+ int is16bit;
av_dict_free(&s->exif_metadata);
av_freep(&s->stereo3d);
s->got_picture = 0;
return ret;
the_end:
+
+ is16bit = av_pix_fmt_desc_get(s->avctx->pix_fmt)->comp[0].step_minus1;
+
if (s->upscale_h) {
int p;
av_assert0(avctx->pix_fmt == AV_PIX_FMT_YUVJ444P ||
avctx->pix_fmt == AV_PIX_FMT_YUVA444P ||
avctx->pix_fmt == AV_PIX_FMT_YUVJ420P ||
avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
+ avctx->pix_fmt == AV_PIX_FMT_YUV420P16||
avctx->pix_fmt == AV_PIX_FMT_GBRAP
);
avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &hshift, &vshift);
continue;
if (p==1 || p==2)
w >>= hshift;
+ av_assert0(w > 0);
for (i = 0; i < s->chroma_height; i++) {
- for (index = w - 1; index; index--)
- line[index] = (line[index / 2] + line[(index + 1) / 2]) >> 1;
+ 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--) {
+ if (is16bit)
+ ((uint16_t*)line)[index] = (((uint16_t*)line)[index / 2] + ((uint16_t*)line)[(index + 1) / 2]) >> 1;
+ else
+ line[index] = (line[index / 2] + line[(index + 1) / 2]) >> 1;
+ }
line += s->linesize[p];
}
}
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]];
- if (src1 == src2) {
+ if (src1 == src2 || i == s->height - 1) {
memcpy(dst, src1, w);
} else {
for (index = 0; index < w; index++)