Exemple #1
0
static av_cold int zerocodec_decode_init(AVCodecContext *avctx)
{
    ZeroCodecContext *zc = avctx->priv_data;
    z_stream *zstream    = &zc->zstream;
    int zret;

    avctx->pix_fmt             = PIX_FMT_UYVY422;
    avctx->bits_per_raw_sample = 8;

    zc->size = avpicture_get_size(avctx->pix_fmt,
                                  avctx->width, avctx->height);

    zstream->zalloc = Z_NULL;
    zstream->zfree  = Z_NULL;
    zstream->opaque = Z_NULL;

    zret = inflateInit(zstream);

    if (zret != Z_OK) {
        av_log(avctx, AV_LOG_ERROR, "Could not initialize inflate: %d\n", zret);
        return AVERROR(ENOMEM);
    }

    avctx->coded_frame = avcodec_alloc_frame();

    if (!avctx->coded_frame) {
        av_log(avctx, AV_LOG_ERROR, "Could not allocate frame buffer.\n");
        zerocodec_decode_close(avctx);
        return AVERROR(ENOMEM);
    }

    return 0;
}
Exemple #2
0
static av_cold int zerocodec_decode_init(AVCodecContext *avctx)
{
    ZeroCodecContext *zc = avctx->priv_data;
    z_stream *zstream    = &zc->zstream;
    int zret;

    avctx->pix_fmt             = AV_PIX_FMT_UYVY422;
    avctx->bits_per_raw_sample = 8;

    zstream->zalloc = Z_NULL;
    zstream->zfree  = Z_NULL;
    zstream->opaque = Z_NULL;

    zret = inflateInit(zstream);
    if (zret != Z_OK) {
        av_log(avctx, AV_LOG_ERROR, "Could not initialize inflate: %d.\n", zret);
        return AVERROR(ENOMEM);
    }

    zc->previous_frame = av_frame_alloc();
    if (!zc->previous_frame) {
        zerocodec_decode_close(avctx);
        return AVERROR(ENOMEM);
    }

    return 0;
}