func: static int libopenjpeg_copy_packed12(AVCodecContext *avctx, const AVFrame *frame, opj_image_t *image)
  
  {
  
      int compno;
  
      int x, y;
  
      int *image_line;
  
      int frame_index;
  
      const int numcomps  = image->numcomps;
  
      uint16_t *frame_ptr = (uint16_t *)frame->data[0];
  
  
  
      for (compno = 0; compno < numcomps; ++compno) {
  
          if (image->comps[compno].w > frame->linesize[0] / numcomps) {
  
              av_log(avctx, AV_LOG_ERROR, "Error: frame's linesize is too small for the image\n");
  
              return 0;
  
          }
  
      }
  
  
  
      for (compno = 0; compno < numcomps; ++compno) {
  
          for (y = 0; y < avctx->height; ++y) {
  
              image_line = image->comps[compno].data + y * image->comps[compno].w;
  
              frame_index = y * (frame->linesize[0] / 2) + compno;
  
              for (x = 0; x < avctx->width; ++x) {
  
                  image_line[x] = frame_ptr[frame_index] >> 4;
  
                  frame_index += numcomps;
  
              }
  
              for (; x < image->comps[compno].w; ++x) {
  
                  image_line[x] = image_line[x - 1];
  
              }
  
          }
  
          for (; y < image->comps[compno].h; ++y) {
  
              image_line = image->comps[compno].data + y * image->comps[compno].w;
  
              for (x = 0; x < image->comps[compno].w; ++x) {
  
                  image_line[x] = image_line[x - image->comps[compno].w];
  
              }
  
          }
  
      }
  
  
  
      return 1;
  
  }
  