static void to_meta_with_crop(AVCodecContext *avctx, AVFrame *p, int *dest)

{

    int blockx, blocky, x, y;

    int luma = 0;

    int height = FFMIN(avctx->height, C64YRES);

    int width  = FFMIN(avctx->width , C64XRES);

    uint8_t *src = p->data[0];



    for (blocky = 0; blocky < C64YRES; blocky += 8) {

        for (blockx = 0; blockx < C64XRES; blockx += 8) {

            for (y = blocky; y < blocky + 8 && y < C64YRES; y++) {

                for (x = blockx; x < blockx + 8 && x < C64XRES; x += 2) {

                    if(x < width && y < height) {

                        /* build average over 2 pixels */

                        luma = (src[(x + 0 + y * p->linesize[0])] +

                                src[(x + 1 + y * p->linesize[0])]) / 2;

                        /* write blocks as linear data now so they are suitable for elbg */

                        dest[0] = luma;

                    }

                    dest++;

                }

            }

        }

    }

}

static void to_meta_with_crop(AVCodecContext *avctx, AVFrame *p, int *dest)

{

    int blockx, blocky, x, y;

    int luma = 0;

    int height = FFMIN(avctx->height, C64YRES);

    int width  = FFMIN(avctx->width , C64XRES);

    uint8_t *src = p->data[0];



    for (blocky = 0; blocky < C64YRES; blocky += 8) {

        for (blockx = 0; blockx < C64XRES; blockx += 8) {

            for (y = blocky; y < blocky + 8 && y < C64YRES; y++) {

                for (x = blockx; x < blockx + 8 && x < C64XRES; x += 2) {

                    if(x < width && y < height) {

                        

                        luma = (src[(x + 0 + y * p->linesize[0])] +

                                src[(x + 1 + y * p->linesize[0])]) / 2;

                        

                        dest[0] = luma;

                    }

                    dest++;

                }

            }

        }

    }

}

static void FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1, int *VAR_2)

{

    int VAR_3, VAR_4, VAR_5, VAR_6;

    int VAR_7 = 0;

    int VAR_8 = FFMIN(VAR_0->VAR_8, C64YRES);

    int VAR_9  = FFMIN(VAR_0->VAR_9 , C64XRES);

    uint8_t *src = VAR_1->data[0];



    for (VAR_4 = 0; VAR_4 < C64YRES; VAR_4 += 8) {

        for (VAR_3 = 0; VAR_3 < C64XRES; VAR_3 += 8) {

            for (VAR_6 = VAR_4; VAR_6 < VAR_4 + 8 && VAR_6 < C64YRES; VAR_6++) {

                for (VAR_5 = VAR_3; VAR_5 < VAR_3 + 8 && VAR_5 < C64XRES; VAR_5 += 2) {

                    if(VAR_5 < VAR_9 && VAR_6 < VAR_8) {

                        

                        VAR_7 = (src[(VAR_5 + 0 + VAR_6 * VAR_1->linesize[0])] +

                                src[(VAR_5 + 1 + VAR_6 * VAR_1->linesize[0])]) / 2;

                        

                        VAR_2[0] = VAR_7;

                    }

                    VAR_2++;

                }

            }

        }

    }

}

static void FUNC_0(AVCodecContext *VAR_0, AVFrame *VAR_1, int *VAR_2)
{ int VAR_3, VAR_4, VAR_5, VAR_6; int VAR_7 = 0; int VAR_8 = FFMIN(VAR_0->VAR_8, C64YRES); int VAR_9  = FFMIN(VAR_0->VAR_9 , C64XRES); uint8_t *src = VAR_1->data[0]; for (VAR_4 = 0; VAR_4 < C64YRES; VAR_4 += 8) { for (VAR_3 = 0; VAR_3 < C64XRES; VAR_3 += 8) { for (VAR_6 = VAR_4; VAR_6 < VAR_4 + 8 && VAR_6 < C64YRES; VAR_6++) { for (VAR_5 = VAR_3; VAR_5 < VAR_3 + 8 && VAR_5 < C64XRES; VAR_5 += 2) { if(VAR_5 < VAR_9 && VAR_6 < VAR_8) { VAR_7 = (src[(VAR_5 + 0 + VAR_6 * VAR_1->linesize[0])] +
src[(VAR_5 + 1 + VAR_6 * VAR_1->linesize[0])]) / 2; VAR_2[0] = VAR_7; } VAR_2++; } } } } }