[FFmpeg-trac] #2943(avcodec:open): libopenjpeg: black output

FFmpeg trac at avcodec.org
Thu Sep 12 08:35:31 CEST 2013


#2943: libopenjpeg: black output
-------------------------------------+-------------------------------------
             Reporter:  ami_stuff    |                    Owner:
                 Type:  defect       |                   Status:  open
             Priority:  normal       |                Component:  avcodec
              Version:  git-master   |               Resolution:
             Keywords:  libopenjpeg  |               Blocked By:
  j2k                                |  Reproduced by developer:  1
             Blocking:               |
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------

Comment (by mbradshaw):

 Replying to [comment:4 cehoyos]:
 > Possible patch attached, there may be another solution.

 The right solution is the one you mentioned off list: adding `adjust[]` to
 `libopenjpeg_copyto16()`. I've tested with following diff and it works.
 Without this, other pixel formats with bpp >8 and < 16 might turn out
 black too.
 {{{
 diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c
 index c331b59..27fb56e 100644
 --- a/libavcodec/libopenjpegdec.c
 +++ b/libavcodec/libopenjpegdec.c
 @@ -207,12 +207,16 @@ static inline void libopenjpeg_copyto16(AVFrame
 *picture, opj_image_t *image) {
      int *comp_data;
      uint16_t *img_ptr;
      int index, x, y;
 +    int adjust[4];
 +    for (x = 0; x < image->numcomps; x++)
 +        adjust[x] = FFMAX(FFMIN(16 - image->comps[x].prec, 8), 0);
 +
      for (index = 0; index < image->numcomps; index++) {
          comp_data = image->comps[index].data;
          for (y = 0; y < image->comps[index].h; y++) {
              img_ptr = (uint16_t*) (picture->data[index] + y *
 picture->linesize[index]);
              for (x = 0; x < image->comps[index].w; x++) {
 -                *img_ptr = *comp_data;
 +                *img_ptr = *comp_data << adjust[index];
                  img_ptr++;
                  comp_data++;
              }
 }}}

-- 
Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/2943#comment:5>
FFmpeg <http://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list