static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw, int imgh)

{

    int x, y, Y, U, V, A;

    uint8_t *lum, *cb, *cr;

    int dstx, dsty, dstw, dsth;

    const AVPicture *src = &rect->pict;



    dstw = av_clip(rect->w, 0, imgw);

    dsth = av_clip(rect->h, 0, imgh);

    dstx = av_clip(rect->x, 0, imgw - dstw);

    dsty = av_clip(rect->y, 0, imgh - dsth);

    lum = dst->data[0] + dstx + dsty * dst->linesize[0];

    cb  = dst->data[1] + dstx/2 + (dsty >> 1) * dst->linesize[1];

    cr  = dst->data[2] + dstx/2 + (dsty >> 1) * dst->linesize[2];



    for (y = 0; y<dsth; y++) {

        for (x = 0; x<dstw; x++) {

            Y = src->data[0][x + y*src->linesize[0]];

            A = src->data[3][x + y*src->linesize[3]];

            lum[0] = ALPHA_BLEND(A, lum[0], Y, 0);

            lum++;

        }

        lum += dst->linesize[0] - dstw;

    }



    for (y = 0; y<dsth/2; y++) {

        for (x = 0; x<dstw/2; x++) {

            U = src->data[1][x + y*src->linesize[1]];

            V = src->data[2][x + y*src->linesize[2]];

            A = src->data[3][2*x     +  2*y   *src->linesize[3]]

              + src->data[3][2*x + 1 +  2*y   *src->linesize[3]]

              + src->data[3][2*x + 1 + (2*y+1)*src->linesize[3]]

              + src->data[3][2*x     + (2*y+1)*src->linesize[3]];

            cb[0] = ALPHA_BLEND(A>>2, cb[0], U, 0);

            cr[0] = ALPHA_BLEND(A>>2, cr[0], V, 0);

            cb++;

            cr++;

        }

        cb += dst->linesize[1] - dstw/2;

        cr += dst->linesize[2] - dstw/2;

    }

}

static void blend_subrect(AVPicture *dst, const AVSubtitleRect *rect, int imgw, int imgh)

{

    int x, y, Y, U, V, A;

    uint8_t *lum, *cb, *cr;

    int dstx, dsty, dstw, dsth;

    const AVPicture *src = &rect->pict;



    dstw = av_clip(rect->w, 0, imgw);

    dsth = av_clip(rect->h, 0, imgh);

    dstx = av_clip(rect->x, 0, imgw - dstw);

    dsty = av_clip(rect->y, 0, imgh - dsth);

    lum = dst->data[0] + dstx + dsty * dst->linesize[0];

    cb  = dst->data[1] + dstx/2 + (dsty >> 1) * dst->linesize[1];

    cr  = dst->data[2] + dstx/2 + (dsty >> 1) * dst->linesize[2];



    for (y = 0; y<dsth; y++) {

        for (x = 0; x<dstw; x++) {

            Y = src->data[0][x + y*src->linesize[0]];

            A = src->data[3][x + y*src->linesize[3]];

            lum[0] = ALPHA_BLEND(A, lum[0], Y, 0);

            lum++;

        }

        lum += dst->linesize[0] - dstw;

    }



    for (y = 0; y<dsth/2; y++) {

        for (x = 0; x<dstw/2; x++) {

            U = src->data[1][x + y*src->linesize[1]];

            V = src->data[2][x + y*src->linesize[2]];

            A = src->data[3][2*x     +  2*y   *src->linesize[3]]

              + src->data[3][2*x + 1 +  2*y   *src->linesize[3]]

              + src->data[3][2*x + 1 + (2*y+1)*src->linesize[3]]

              + src->data[3][2*x     + (2*y+1)*src->linesize[3]];

            cb[0] = ALPHA_BLEND(A>>2, cb[0], U, 0);

            cr[0] = ALPHA_BLEND(A>>2, cr[0], V, 0);

            cb++;

            cr++;

        }

        cb += dst->linesize[1] - dstw/2;

        cr += dst->linesize[2] - dstw/2;

    }

}

static void FUNC_0(AVPicture *VAR_0, const AVSubtitleRect *VAR_1, int VAR_2, int VAR_3)

{

    int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;

    uint8_t *lum, *cb, *cr;

    int VAR_10, VAR_11, VAR_12, VAR_13;

    const AVPicture *VAR_14 = &VAR_1->pict;



    VAR_12 = av_clip(VAR_1->w, 0, VAR_2);

    VAR_13 = av_clip(VAR_1->h, 0, VAR_3);

    VAR_10 = av_clip(VAR_1->VAR_4, 0, VAR_2 - VAR_12);

    VAR_11 = av_clip(VAR_1->VAR_5, 0, VAR_3 - VAR_13);

    lum = VAR_0->data[0] + VAR_10 + VAR_11 * VAR_0->linesize[0];

    cb  = VAR_0->data[1] + VAR_10/2 + (VAR_11 >> 1) * VAR_0->linesize[1];

    cr  = VAR_0->data[2] + VAR_10/2 + (VAR_11 >> 1) * VAR_0->linesize[2];



    for (VAR_5 = 0; VAR_5<VAR_13; VAR_5++) {

        for (VAR_4 = 0; VAR_4<VAR_12; VAR_4++) {

            VAR_6 = VAR_14->data[0][VAR_4 + VAR_5*VAR_14->linesize[0]];

            VAR_9 = VAR_14->data[3][VAR_4 + VAR_5*VAR_14->linesize[3]];

            lum[0] = ALPHA_BLEND(VAR_9, lum[0], VAR_6, 0);

            lum++;

        }

        lum += VAR_0->linesize[0] - VAR_12;

    }



    for (VAR_5 = 0; VAR_5<VAR_13/2; VAR_5++) {

        for (VAR_4 = 0; VAR_4<VAR_12/2; VAR_4++) {

            VAR_7 = VAR_14->data[1][VAR_4 + VAR_5*VAR_14->linesize[1]];

            VAR_8 = VAR_14->data[2][VAR_4 + VAR_5*VAR_14->linesize[2]];

            VAR_9 = VAR_14->data[3][2*VAR_4     +  2*VAR_5   *VAR_14->linesize[3]]

              + VAR_14->data[3][2*VAR_4 + 1 +  2*VAR_5   *VAR_14->linesize[3]]

              + VAR_14->data[3][2*VAR_4 + 1 + (2*VAR_5+1)*VAR_14->linesize[3]]

              + VAR_14->data[3][2*VAR_4     + (2*VAR_5+1)*VAR_14->linesize[3]];

            cb[0] = ALPHA_BLEND(VAR_9>>2, cb[0], VAR_7, 0);

            cr[0] = ALPHA_BLEND(VAR_9>>2, cr[0], VAR_8, 0);

            cb++;

            cr++;

        }

        cb += VAR_0->linesize[1] - VAR_12/2;

        cr += VAR_0->linesize[2] - VAR_12/2;

    }

}

static void FUNC_0(AVPicture *VAR_0, const AVSubtitleRect *VAR_1, int VAR_2, int VAR_3)
{ int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9; uint8_t *lum, *cb, *cr; int VAR_10, VAR_11, VAR_12, VAR_13; const AVPicture *VAR_14 = &VAR_1->pict; VAR_12 = av_clip(VAR_1->w, 0, VAR_2); VAR_13 = av_clip(VAR_1->h, 0, VAR_3); VAR_10 = av_clip(VAR_1->VAR_4, 0, VAR_2 - VAR_12); VAR_11 = av_clip(VAR_1->VAR_5, 0, VAR_3 - VAR_13); lum = VAR_0->data[0] + VAR_10 + VAR_11 * VAR_0->linesize[0]; cb  = VAR_0->data[1] + VAR_10/2 + (VAR_11 >> 1) * VAR_0->linesize[1]; cr  = VAR_0->data[2] + VAR_10/2 + (VAR_11 >> 1) * VAR_0->linesize[2]; for (VAR_5 = 0; VAR_5<VAR_13; VAR_5++) { for (VAR_4 = 0; VAR_4<VAR_12; VAR_4++) { VAR_6 = VAR_14->data[0][VAR_4 + VAR_5*VAR_14->linesize[0]]; VAR_9 = VAR_14->data[3][VAR_4 + VAR_5*VAR_14->linesize[3]]; lum[0] = ALPHA_BLEND(VAR_9, lum[0], VAR_6, 0); lum++; } lum += VAR_0->linesize[0] - VAR_12; } for (VAR_5 = 0; VAR_5<VAR_13/2; VAR_5++) { for (VAR_4 = 0; VAR_4<VAR_12/2; VAR_4++) { VAR_7 = VAR_14->data[1][VAR_4 + VAR_5*VAR_14->linesize[1]]; VAR_8 = VAR_14->data[2][VAR_4 + VAR_5*VAR_14->linesize[2]]; VAR_9 = VAR_14->data[3][2*VAR_4     +  2*VAR_5   *VAR_14->linesize[3]]
+ VAR_14->data[3][2*VAR_4 + 1 +  2*VAR_5   *VAR_14->linesize[3]]
+ VAR_14->data[3][2*VAR_4 + 1 + (2*VAR_5+1)*VAR_14->linesize[3]]
+ VAR_14->data[3][2*VAR_4     + (2*VAR_5+1)*VAR_14->linesize[3]]; cb[0] = ALPHA_BLEND(VAR_9>>2, cb[0], VAR_7, 0); cr[0] = ALPHA_BLEND(VAR_9>>2, cr[0], VAR_8, 0); cb++; cr++; } cb += VAR_0->linesize[1] - VAR_12/2; cr += VAR_0->linesize[2] - VAR_12/2; } }