[FFmpeg-devel] [PATCH] yuv pixel formats support in openjpeg decoder + 10bit support
Alex Zhukov
zhukov.alex at gmail.com
Fri Nov 11 12:31:50 CET 2011
On Thu, Nov 10, 2011 at 5:20 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> 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
code path for rgb24 would be:
compRatio = 0111111 //all components of equal size
libopenjpeg_yuv444_rgb: //it can be either yuv444 or rgb
switch (c0.prec)
case 8: return PIX_FMT_RGB24; // if precision is 8bpp assume it's rgb24
why would it break 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
well these are component size ratios
i have not seen a pixel format where components will have any ratio
other than 1/1 or 1/2
that is not to say there isn't such one of course
tell me if i'm wrong
i think leaving it the way it is will serve all practical purposes
>
>
>> + //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
done
>
>
> [...]
>
>> +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 ?
not that i know of
they just have *int data in the component struct
> and the cast is unneeded
removed
>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> It is what and why we do it that matters, not just one of them.
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-yuv-pixel-formats-support-in-openjpeg-decoder-10bit-.patch
Type: application/octet-stream
Size: 6361 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111111/a97fa128/attachment.obj>
More information about the ffmpeg-devel
mailing list