[FFmpeg-devel] [PATCH] J2K encoder: fix bpp and add support for 9, 10, and 16 bit YUV

Jean First jeanfirst at gmail.com
Mon Nov 28 22:20:11 CET 2011


On Mon Nov 28 2011 21:33:39 GMT+0100 (CET), Michael Bradshaw wrote:
> Two patches are attached.  One is for fixing the bits per pixel, which
> was incorrectly being set in the first version (according to what I've
> learned from here:
> https://groups.google.com/group/openjpeg/browse_thread/thread/bb6bd9dac3aebaba#
> From b235ef1eeac050495be443a2a8e5a5ab7dda294b Mon Sep 17 00:00:00 2001
> From: Michael Bradshaw <mbradshaw at sorensonmedia.com>
> Date: Mon, 21 Nov 2011 14:58:33 -0700
> Subject: [PATCH 002/103] Fixed incorrectly setting the bits per pixel
>
>
> Signed-off-by: Michael Bradshaw <mbradshaw at sorensonmedia.com>
> ---
>  libavcodec/libopenjpegenc.c |   11 ++---------
>  1 files changed, 2 insertions(+), 9 deletions(-)

ok.

> The other patch is for encoding 9, 10, and 16 bit YUV video.  One
> thing: right now I'm using PIX_FMT_YUV420P9 and the like, rather than
> the specific big endian and little endian versions.  If this is a
> problem, or if it would be better to support both big and little
> endian formats (I don't know what the industry "standard" is), let me
> know and I can add support.  It's pretty slow at encoding, just so you
> know.

> From f3b8d60ecbb745fe3d5c614fa3e59903459a0e85 Mon Sep 17 00:00:00 2001
> From: Michael Bradshaw <mbradshaw at sorensonmedia.com>
> Date: Mon, 28 Nov 2011 13:19:55 -0700
> Subject: [PATCH 103/103] Added support for encoding 9, 10, and 16 bit 
> YUV J2K
>  video
>
>
> Signed-off-by: Michael Bradshaw <mbradshaw at sorensonmedia.com>
> ---
>  libavcodec/libopenjpegenc.c |   67 
> +++++++++++++++++++++++++++++++++++++++++--
>  1 files changed, 64 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/libopenjpegenc.c b/libavcodec/libopenjpegenc.c
> index 8403ca1..dffd6bf 100644
> --- a/libavcodec/libopenjpegenc.c
> +++ b/libavcodec/libopenjpegenc.c
> @@ -93,6 +93,27 @@ static opj_image_t *mj2_create_image(AVCodecContext 
> *avctx, opj_cparameters_t *p
>          color_space = CLRSPC_SYCC;
>          numcomps = 3;
>          break;
> +    case PIX_FMT_YUV420P9:
> +    case PIX_FMT_YUV422P9:
> +    case PIX_FMT_YUV444P9:
> +        color_space = CLRSPC_SYCC;
> +        numcomps = 3;
> +        bpp = 9;
> +        break;
> +    case PIX_FMT_YUV420P10:
> +    case PIX_FMT_YUV422P10:
> +    case PIX_FMT_YUV444P10:
> +    color_space = CLRSPC_SYCC;

indent.

> +        numcomps = 3;
> +        bpp = 10;
> +        break;
> +    case PIX_FMT_YUV420P16:
> +    case PIX_FMT_YUV422P16:
> +    case PIX_FMT_YUV444P16:
> +        color_space = CLRSPC_SYCC;
> +        numcomps = 3;
> +        bpp = 16;
> +        break;
>      default:
>          av_log(avctx, AV_LOG_ERROR, "The requested pixel format '%s' 
> is not supported\n", av_get_pix_fmt_name(avctx->pix_fmt));
>          return NULL;
> @@ -182,7 +203,7 @@ static int libopenjpeg_copy_rgba(AVCodecContext 
> *avctx, AVFrame *frame, opj_imag
>      return 1;
>  }
>
> -static int libopenjpeg_copy_yuv(AVCodecContext *avctx, AVFrame 
> *frame, opj_image_t *image)
> +static int libopenjpeg_copy_yuv8(AVCodecContext *avctx, AVFrame 
> *frame, opj_image_t *image)
>  {
>      int compno;
>      int x;
> @@ -210,6 +231,36 @@ static int libopenjpeg_copy_yuv(AVCodecContext 
> *avctx, AVFrame *frame, opj_image
>      return 1;
>  }
>
> +static int libopenjpeg_copy_yuv16(AVCodecContext *avctx, AVFrame 
> *frame, opj_image_t *image)

libopenjpeg_copy_yuv8 and libopenjpeg_copy_yuv16 look quite similar. 
maybe it's possible to merge them ?

[...]

> @@ -300,6 +362,5 @@ AVCodec ff_libopenjpeg_encoder = {
>      .close = libopenjpeg_encode_close,
>      .decode = NULL,
>      .capabilities = 0,
> -    .pix_fmts = (const enum 
> PixelFormat[]){PIX_FMT_GRAY8,PIX_FMT_RGB24,PIX_FMT_RGBA,PIX_FMT_YUV420P,PIX_FMT_YUV422P,PIX_FMT_YUV440P,PIX_FMT_YUV444P},

why do you remove .pix_fmts ? I'd rather update and reformat it.

>      .long_name = NULL_IF_CONFIG_SMALL("OpenJPEG based JPEG 2000 
> encoder"),
>  } ;
> -- 
> 1.7.7
>

by the way - there are some quite long lines that could be wraped.

jean








More information about the ffmpeg-devel mailing list