static int upload_texture(SDL_Texture *tex, AVFrame *frame, struct SwsContext **img_convert_ctx) {

    int ret = 0;

    switch (frame->format) {

        case AV_PIX_FMT_YUV420P:

            ret = SDL_UpdateYUVTexture(tex, NULL, frame->data[0], frame->linesize[0],

                                                  frame->data[1], frame->linesize[1],

                                                  frame->data[2], frame->linesize[2]);

            break;

        case AV_PIX_FMT_BGRA:

            ret = SDL_UpdateTexture(tex, NULL, frame->data[0], frame->linesize[0]);

            break;

        default:

            /* This should only happen if we are not using avfilter... */

            *img_convert_ctx = sws_getCachedContext(*img_convert_ctx,

                frame->width, frame->height, frame->format, frame->width, frame->height,

                AV_PIX_FMT_BGRA, sws_flags, NULL, NULL, NULL);

            if (*img_convert_ctx != NULL) {

                uint8_t *pixels;

                int pitch;

                if (!SDL_LockTexture(tex, NULL, (void **)&pixels, &pitch)) {

                    sws_scale(*img_convert_ctx, (const uint8_t * const *)frame->data, frame->linesize,

                              0, frame->height, &pixels, &pitch);

                    SDL_UnlockTexture(tex);

                }

            } else {

                av_log(NULL, AV_LOG_FATAL, "Cannot initialize the conversion context\n");

                ret = -1;

            }

            break;

    }

    return ret;

}

static int upload_texture(SDL_Texture *tex, AVFrame *frame, struct SwsContext **img_convert_ctx) {

    int ret = 0;

    switch (frame->format) {

        case AV_PIX_FMT_YUV420P:

            ret = SDL_UpdateYUVTexture(tex, NULL, frame->data[0], frame->linesize[0],

                                                  frame->data[1], frame->linesize[1],

                                                  frame->data[2], frame->linesize[2]);

            break;

        case AV_PIX_FMT_BGRA:

            ret = SDL_UpdateTexture(tex, NULL, frame->data[0], frame->linesize[0]);

            break;

        default:

            

            *img_convert_ctx = sws_getCachedContext(*img_convert_ctx,

                frame->width, frame->height, frame->format, frame->width, frame->height,

                AV_PIX_FMT_BGRA, sws_flags, NULL, NULL, NULL);

            if (*img_convert_ctx != NULL) {

                uint8_t *pixels;

                int pitch;

                if (!SDL_LockTexture(tex, NULL, (void **)&pixels, &pitch)) {

                    sws_scale(*img_convert_ctx, (const uint8_t * const *)frame->data, frame->linesize,

                              0, frame->height, &pixels, &pitch);

                    SDL_UnlockTexture(tex);

                }

            } else {

                av_log(NULL, AV_LOG_FATAL, "Cannot initialize the conversion context\n");

                ret = -1;

            }

            break;

    }

    return ret;

}

            ret = SDL_UpdateTexture(tex, NULL, frame->data[0], frame->linesize[0]);
static int FUNC_0(SDL_Texture *VAR_0, AVFrame *VAR_1, struct SwsContext **VAR_2) {

    int VAR_3 = 0;

    switch (VAR_1->format) {

        case AV_PIX_FMT_YUV420P:

            VAR_3 = SDL_UpdateYUVTexture(VAR_0, NULL, VAR_1->data[0], VAR_1->linesize[0],

                                                  VAR_1->data[1], VAR_1->linesize[1],

                                                  VAR_1->data[2], VAR_1->linesize[2]);

            break;

        case AV_PIX_FMT_BGRA:

            VAR_3 = SDL_UpdateTexture(VAR_0, NULL, VAR_1->data[0], VAR_1->linesize[0]);

            break;

        default:

            

            *VAR_2 = sws_getCachedContext(*VAR_2,

                VAR_1->width, VAR_1->height, VAR_1->format, VAR_1->width, VAR_1->height,

                AV_PIX_FMT_BGRA, sws_flags, NULL, NULL, NULL);

            if (*VAR_2 != NULL) {

                uint8_t *pixels;

                int VAR_4;

                if (!SDL_LockTexture(VAR_0, NULL, (void **)&pixels, &VAR_4)) {

                    sws_scale(*VAR_2, (const uint8_t * const *)VAR_1->data, VAR_1->linesize,

                              0, VAR_1->height, &pixels, &VAR_4);

                    SDL_UnlockTexture(VAR_0);

                }

            } else {

                av_log(NULL, AV_LOG_FATAL, "Cannot initialize the conversion context\n");

                VAR_3 = -1;

            }

            break;

    }

    return VAR_3;

}

static int FUNC_0(SDL_Texture *VAR_0, AVFrame *VAR_1, struct SwsContext **VAR_2) { int VAR_3 = 0; switch (VAR_1->format) { case AV_PIX_FMT_YUV420P:
VAR_3 = SDL_UpdateYUVTexture(VAR_0, NULL, VAR_1->data[0], VAR_1->linesize[0],
VAR_1->data[1], VAR_1->linesize[1],
VAR_1->data[2], VAR_1->linesize[2]); break; case AV_PIX_FMT_BGRA:
VAR_3 = SDL_UpdateTexture(VAR_0, NULL, VAR_1->data[0], VAR_1->linesize[0]); break; default:
*VAR_2 = sws_getCachedContext(*VAR_2,
VAR_1->width, VAR_1->height, VAR_1->format, VAR_1->width, VAR_1->height,
AV_PIX_FMT_BGRA, sws_flags, NULL, NULL, NULL); if (*VAR_2 != NULL) { uint8_t *pixels; int VAR_4; if (!SDL_LockTexture(VAR_0, NULL, (void **)&pixels, &VAR_4)) { sws_scale(*VAR_2, (const uint8_t * const *)VAR_1->data, VAR_1->linesize,
0, VAR_1->height, &pixels, &VAR_4); SDL_UnlockTexture(VAR_0); } } else { av_log(NULL, AV_LOG_FATAL, "Cannot initialize the conversion context\n"); VAR_3 = -1; } break; } return VAR_3; }