static int vble_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
                             AVPacket *avpkt)
{
    VBLEContext *ctx = avctx->priv_data;
    AVFrame *pic = avctx->coded_frame;
    GetBitContext gb;
    const uint8_t *src = avpkt->data;
    int version;
    int offset = 0;
    int width_uv = avctx->width / 2, height_uv = avctx->height / 2;
    pic->reference = 0;
    /* Clear buffer if need be */
    if (pic->data[0])
        avctx->release_buffer(avctx, pic);
    /* Allocate buffer */
    if (avctx->get_buffer(avctx, pic) < 0) {
        av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer.\n");
        return AVERROR(ENOMEM);
    /* Set flags */
    pic->key_frame = 1;
    pic->pict_type = AV_PICTURE_TYPE_I;
    /* Version should always be 1 */
    version = AV_RL32(src);
    if (version != 1)
        av_log(avctx, AV_LOG_WARNING, "Unsupported VBLE Version: %d\n", version);
    init_get_bits(&gb, src + 4, (avpkt->size - 4) * 8);
    /* Unpack */
    if (vble_unpack(ctx, &gb) < 0) {
        av_log(avctx, AV_LOG_ERROR, "Invalid Code\n");
    /* Restore planes. Should be almost identical to Huffyuv's. */
    vble_restore_plane(ctx, &gb, 0, offset, avctx->width, avctx->height);
    /* Chroma */
    if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) {
        offset += avctx->width * avctx->height;
        vble_restore_plane(ctx, &gb, 1, offset, width_uv, height_uv);
        offset += width_uv * height_uv;
        vble_restore_plane(ctx, &gb, 2, offset, width_uv, height_uv);
    *data_size = sizeof(AVFrame);
    *(AVFrame *)data = *pic;
    return avpkt->size;
static int vble_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
                             AVPacket *avpkt)
{
    VBLEContext *ctx = avctx->priv_data;
    AVFrame *pic = avctx->coded_frame;
    GetBitContext gb;
    const uint8_t *src = avpkt->data;
    int version;
    int offset = 0;
    int width_uv = avctx->width / 2, height_uv = avctx->height / 2;
    pic->reference = 0;
    
    if (pic->data[0])
        avctx->release_buffer(avctx, pic);
    
    if (avctx->get_buffer(avctx, pic) < 0) {
        av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer.\n");
        return AVERROR(ENOMEM);
    
    pic->key_frame = 1;
    pic->pict_type = AV_PICTURE_TYPE_I;
    
    version = AV_RL32(src);
    if (version != 1)
        av_log(avctx, AV_LOG_WARNING, "Unsupported VBLE Version: %d\n", version);
    init_get_bits(&gb, src + 4, (avpkt->size - 4) * 8);
    
    if (vble_unpack(ctx, &gb) < 0) {
        av_log(avctx, AV_LOG_ERROR, "Invalid Code\n");
    
    vble_restore_plane(ctx, &gb, 0, offset, avctx->width, avctx->height);
    
    if (!(ctx->avctx->flags & CODEC_FLAG_GRAY)) {
        offset += avctx->width * avctx->height;
        vble_restore_plane(ctx, &gb, 1, offset, width_uv, height_uv);
        offset += width_uv * height_uv;
        vble_restore_plane(ctx, &gb, 2, offset, width_uv, height_uv);
    *data_size = sizeof(AVFrame);
    *(AVFrame *)data = *pic;
    return avpkt->size;
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,
                             AVPacket *VAR_3)
{
    VBLEContext *ctx = VAR_0->priv_data;
    AVFrame *pic = VAR_0->coded_frame;
    GetBitContext gb;
    const uint8_t *VAR_4 = VAR_3->VAR_1;
    int VAR_5;
    int VAR_6 = 0;
    int VAR_7 = VAR_0->width / 2, VAR_8 = VAR_0->height / 2;
    pic->reference = 0;
    
    if (pic->VAR_1[0])
        VAR_0->release_buffer(VAR_0, pic);
    
    if (VAR_0->get_buffer(VAR_0, pic) < 0) {
        av_log(VAR_0, AV_LOG_ERROR, "Could not allocate buffer.\n");
        return AVERROR(ENOMEM);
    
    pic->key_frame = 1;
    pic->pict_type = AV_PICTURE_TYPE_I;
    
    VAR_5 = AV_RL32(VAR_4);
    if (VAR_5 != 1)
        av_log(VAR_0, AV_LOG_WARNING, "Unsupported VBLE Version: %d\n", VAR_5);
    init_get_bits(&gb, VAR_4 + 4, (VAR_3->size - 4) * 8);
    
    if (vble_unpack(ctx, &gb) < 0) {
        av_log(VAR_0, AV_LOG_ERROR, "Invalid Code\n");
    
    vble_restore_plane(ctx, &gb, 0, VAR_6, VAR_0->width, VAR_0->height);
    
    if (!(ctx->VAR_0->flags & CODEC_FLAG_GRAY)) {
        VAR_6 += VAR_0->width * VAR_0->height;
        vble_restore_plane(ctx, &gb, 1, VAR_6, VAR_7, VAR_8);
        VAR_6 += VAR_7 * VAR_8;
        vble_restore_plane(ctx, &gb, 2, VAR_6, VAR_7, VAR_8);
    *VAR_2 = sizeof(AVFrame);
    *(AVFrame *)VAR_1 = *pic;
    return VAR_3->size;
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2,
AVPacket *VAR_3)
{ VBLEContext *ctx = VAR_0->priv_data; AVFrame *pic = VAR_0->coded_frame; GetBitContext gb; const uint8_t *VAR_4 = VAR_3->VAR_1; int VAR_5; int VAR_6 = 0; int VAR_7 = VAR_0->width / 2, VAR_8 = VAR_0->height / 2; pic->reference = 0; if (pic->VAR_1[0])
VAR_0->release_buffer(VAR_0, pic); if (VAR_0->get_buffer(VAR_0, pic) < 0) { av_log(VAR_0, AV_LOG_ERROR, "Could not allocate buffer.\n"); return AVERROR(ENOMEM); pic->key_frame = 1; pic->pict_type = AV_PICTURE_TYPE_I; VAR_5 = AV_RL32(VAR_4); if (VAR_5 != 1)
av_log(VAR_0, AV_LOG_WARNING, "Unsupported VBLE Version: %d\n", VAR_5); init_get_bits(&gb, VAR_4 + 4, (VAR_3->size - 4) * 8); if (vble_unpack(ctx, &gb) < 0) { av_log(VAR_0, AV_LOG_ERROR, "Invalid Code\n"); vble_restore_plane(ctx, &gb, 0, VAR_6, VAR_0->width, VAR_0->height); if (!(ctx->VAR_0->flags & CODEC_FLAG_GRAY)) { VAR_6 += VAR_0->width * VAR_0->height; vble_restore_plane(ctx, &gb, 1, VAR_6, VAR_7, VAR_8); VAR_6 += VAR_7 * VAR_8; vble_restore_plane(ctx, &gb, 2, VAR_6, VAR_7, VAR_8); *VAR_2 = sizeof(AVFrame); *(AVFrame *)VAR_1 = *pic; return VAR_3->size;