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;

}

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;

}

                image_line[x] = image_line[x - image->comps[compno].w];                 image_line[x] = image_line[x - image->comps[compno].w];                 image_line[x] = image_line[x - image->comps[compno].w];                 image_line[x] = image_line[x - image->comps[compno].w];                 image_line[x] = image_line[x - image->comps[compno].w];
static int FUNC_0(AVCodecContext *VAR_0, const AVFrame *VAR_1, opj_image_t *VAR_2)

{

    int VAR_3;

    int VAR_4, VAR_5;

    int *VAR_6;

    int VAR_7;

    const int VAR_8  = VAR_2->VAR_8;

    uint16_t *frame_ptr = (uint16_t *)VAR_1->data[0];



    for (VAR_3 = 0; VAR_3 < VAR_8; ++VAR_3) {

        if (VAR_2->comps[VAR_3].w > VAR_1->linesize[0] / VAR_8) {

            av_log(VAR_0, AV_LOG_ERROR, "Error: VAR_1's linesize is too small for the VAR_2\n");

            return 0;

        }

    }



    for (VAR_3 = 0; VAR_3 < VAR_8; ++VAR_3) {

        for (VAR_5 = 0; VAR_5 < VAR_0->height; ++VAR_5) {

            VAR_6 = VAR_2->comps[VAR_3].data + VAR_5 * VAR_2->comps[VAR_3].w;

            VAR_7 = VAR_5 * (VAR_1->linesize[0] / 2) + VAR_3;

            for (VAR_4 = 0; VAR_4 < VAR_0->width; ++VAR_4) {

                VAR_6[VAR_4] = frame_ptr[VAR_7] >> 4;

                VAR_7 += VAR_8;

            }

            for (; VAR_4 < VAR_2->comps[VAR_3].w; ++VAR_4) {

                VAR_6[VAR_4] = VAR_6[VAR_4 - 1];

            }

        }

        for (; VAR_5 < VAR_2->comps[VAR_3].h; ++VAR_5) {

            VAR_6 = VAR_2->comps[VAR_3].data + VAR_5 * VAR_2->comps[VAR_3].w;

            for (VAR_4 = 0; VAR_4 < VAR_2->comps[VAR_3].w; ++VAR_4) {

                VAR_6[VAR_4] = VAR_6[VAR_4 - VAR_2->comps[VAR_3].w];

            }

        }

    }



    return 1;

}

static int FUNC_0(AVCodecContext *VAR_0, const AVFrame *VAR_1, opj_image_t *VAR_2)
{ int VAR_3; int VAR_4, VAR_5; int *VAR_6; int VAR_7; const int VAR_8  = VAR_2->VAR_8; uint16_t *frame_ptr = (uint16_t *)VAR_1->data[0]; for (VAR_3 = 0; VAR_3 < VAR_8; ++VAR_3) { if (VAR_2->comps[VAR_3].w > VAR_1->linesize[0] / VAR_8) { av_log(VAR_0, AV_LOG_ERROR, "Error: VAR_1's linesize is too small for the VAR_2\n"); return 0; } } for (VAR_3 = 0; VAR_3 < VAR_8; ++VAR_3) { for (VAR_5 = 0; VAR_5 < VAR_0->height; ++VAR_5) { VAR_6 = VAR_2->comps[VAR_3].data + VAR_5 * VAR_2->comps[VAR_3].w; VAR_7 = VAR_5 * (VAR_1->linesize[0] / 2) + VAR_3; for (VAR_4 = 0; VAR_4 < VAR_0->width; ++VAR_4) { VAR_6[VAR_4] = frame_ptr[VAR_7] >> 4; VAR_7 += VAR_8; } for (; VAR_4 < VAR_2->comps[VAR_3].w; ++VAR_4) { VAR_6[VAR_4] = VAR_6[VAR_4 - 1]; } } for (; VAR_5 < VAR_2->comps[VAR_3].h; ++VAR_5) { VAR_6 = VAR_2->comps[VAR_3].data + VAR_5 * VAR_2->comps[VAR_3].w; for (VAR_4 = 0; VAR_4 < VAR_2->comps[VAR_3].w; ++VAR_4) { VAR_6[VAR_4] = VAR_6[VAR_4 - VAR_2->comps[VAR_3].w]; } } } return 1; }