info->width = c->width;
info->height = c->height;
- info->pix_fmt = c->pix_fmt;
+ switch(c->pix_fmt) {
+ case PIX_FMT_YUV420P:
+ info->pix_fmt = PIX_FMT_YUVJ420P;
+ break;
+ case PIX_FMT_YUV422P:
+ info->pix_fmt = PIX_FMT_YUVJ422P;
+ break;
+ case PIX_FMT_YUV444P:
+ info->pix_fmt = PIX_FMT_YUVJ444P;
+ break;
+ default:
+ return -1;
+ }
ret = jctx->alloc_cb(jctx->opaque, info);
if (ret) {
jctx->ret_code = ret;
}
}
-static void img_copy(UINT8 *dst, int dst_wrap,
- UINT8 *src, int src_wrap,
+static void img_copy(uint8_t *dst, int dst_wrap,
+ uint8_t *src, int src_wrap,
int width, int height)
{
for(;height > 0; height--) {
switch(c->pix_fmt) {
default:
case PIX_FMT_YUV420P:
- w >>= 1;
- h >>= 1;
+ w = (w + 1) >> 1;
+ h = (h + 1) >> 1;
break;
case PIX_FMT_YUV422P:
- w >>= 1;
+ w = (w + 1) >> 1;
break;
case PIX_FMT_YUV444P:
break;
return jctx.ret_code;
}
+#ifdef CONFIG_ENCODERS
static int jpeg_write(ByteIOContext *pb, AVImageInfo *info)
{
AVCodecContext *c;
goto fail2;
c->width = info->width;
c->height = info->height;
- c->pix_fmt = info->pix_fmt;
+ /* XXX: currently move that to the codec ? */
+ switch(info->pix_fmt) {
+ case PIX_FMT_YUVJ420P:
+ c->pix_fmt = PIX_FMT_YUV420P;
+ break;
+ case PIX_FMT_YUVJ422P:
+ c->pix_fmt = PIX_FMT_YUV422P;
+ break;
+ case PIX_FMT_YUVJ444P:
+ c->pix_fmt = PIX_FMT_YUV444P;
+ break;
+ default:
+ goto fail1;
+ }
for(i=0;i<3;i++) {
picture->data[i] = info->pict.data[i];
picture->linesize[i] = info->pict.linesize[i];
av_free(c);
return ret;
}
+#endif //CONFIG_ENCODERS
AVImageFormat jpeg_image_format = {
"jpeg",
"jpg,jpeg",
jpeg_probe,
jpeg_read,
- (1 << PIX_FMT_YUV420P) | (1 << PIX_FMT_YUV422P) | (1 << PIX_FMT_YUV444P),
+ (1 << PIX_FMT_YUVJ420P) | (1 << PIX_FMT_YUVJ422P) | (1 << PIX_FMT_YUVJ444P),
+#ifdef CONFIG_ENCODERS
jpeg_write,
+#else
+ NULL,
+#endif //CONFIG_ENCODERS
};