[FFmpeg-devel] [PATCH] yuv pixel formats support in openjpeg decoder + 10bit support

Michael Niedermayer michaelni at gmx.at
Fri Nov 11 02:20:51 CET 2011


On Thu, Nov 10, 2011 at 02:38:15PM -0800, Alex Zhukov wrote:
> added yuv pixel formats support to libopenjpeg decoder
> supports 8/10bit yuv420/422
> 
> sample 10bit yuv j2k can be found at
> http://dl.dropbox.com/u/1109725/10bit_yuv_j2k.mxf
> note that the sample was cut with dd to be 10MB so last frame is broken

your code breaks rgb24 j2k

[...]
> @@ -39,14 +40,80 @@ typedef struct {
>      AVFrame image;
>  } LibOpenJPEGContext;
>  
> -static int check_image_attributes(opj_image_t *image)
> +static enum PixelFormat check_image_attributes(AVCodecContext *avctx, opj_image_t *image)
>  {
> -    return image->comps[0].dx == image->comps[1].dx &&
> -           image->comps[1].dx == image->comps[2].dx &&
> -           image->comps[0].dy == image->comps[1].dy &&
> -           image->comps[1].dy == image->comps[2].dy &&
> -           image->comps[0].prec == image->comps[1].prec &&
> -           image->comps[1].prec == image->comps[2].prec;
> +    opj_image_comp_t c0 = image->comps[0];
> +    opj_image_comp_t c1 = image->comps[1];
> +    opj_image_comp_t c2 = image->comps[2];

> +    int compRatio = c0.dx << 15 | c0.dy << 12;
> +    compRatio |= c1.dx << 9 | c1.dy << 6;
> +    compRatio |= c2.dx << 3 | c2.dy << 0;

can these fields have more than 3 bit ? if yes, then this should
allocate more space to them


> +    //av_log(avctx, AV_LOG_ERROR, "%o\n", compRatio);
> +    switch(compRatio) {
> +        case 0111111: goto libopenjpeg_yuv444_rgb;
> +        case 0112121: goto libopenjpeg_yuv422;
> +        case 0112222: goto libopenjpeg_yuv420;
> +        default: return PIX_FMT_RGB24;
> +    }
> +    
> +libopenjpeg_yuv420:

please remove trailing whitespace, its not allowed in ffmpeg


[...]

> +static inline void libopenjpeg_copyto16(AVFrame *picture, opj_image_t *image) {
> +    int *comp_data;
> +    uint16_t *img_ptr;
> +    int index, x, y;
> +    for(index = 0; index < image->numcomps; index++) {
> +        comp_data = image->comps[index].data;
> +        img_ptr = (uint16_t*) picture->data[index];
> +        for(y = 0; y < image->comps[index].h; y++) {
> +            for(x = 0; x < image->comps[index].w; x++) {
> +                *img_ptr = (uint16_t) *comp_data;
> +                img_ptr++;
> +                comp_data++;

Is there no way to make libopenjpeg return 8bit or 16bit data ?

and the cast is unneeded

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is what and why we do it that matters, not just one of them.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111111/1020d586/attachment.asc>


More information about the ffmpeg-devel mailing list