⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcl.c.svn-base

📁 ffmpeg是一个大项目
💻 SVN-BASE
📖 第 1 页 / 共 3 页
字号:
                c->zstream.next_in = encoded + 8 + mthread_inlen;                c->zstream.avail_in = len - mthread_inlen;                c->zstream.next_out = c->decomp_buf + mthread_outlen;                c->zstream.avail_out = c->decomp_size - mthread_outlen;                zret = inflate(&(c->zstream), Z_FINISH);                if ((zret != Z_OK) && (zret != Z_STREAM_END)) {                    av_log(avctx, AV_LOG_ERROR, "Mthread2 inflate error: %d\n", zret);                    return -1;                }                if (mthread_outlen != (unsigned int)(c->zstream.total_out)) {                    av_log(avctx, AV_LOG_ERROR, "Mthread2 decoded size differs (%d != %lu)\n",                           mthread_outlen, c->zstream.total_out);                    return -1;                }            } else {                c->zstream.next_in = encoded;                c->zstream.avail_in = len;                c->zstream.next_out = c->decomp_buf;                c->zstream.avail_out = c->decomp_size;                zret = inflate(&(c->zstream), Z_FINISH);                if ((zret != Z_OK) && (zret != Z_STREAM_END)) {                    av_log(avctx, AV_LOG_ERROR, "Inflate error: %d\n", zret);                    return -1;                }                if (c->decomp_size != (unsigned int)(c->zstream.total_out)) {                    av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %lu)\n",                           c->decomp_size, c->zstream.total_out);                    return -1;                }            }            encoded = c->decomp_buf;            len = c->decomp_size;;#else            av_log(avctx, AV_LOG_ERROR, "BUG! Zlib support not compiled in frame decoder.\n");            return -1;#endif            break;        default:            av_log(avctx, AV_LOG_ERROR, "BUG! Unknown codec in frame decoder compression switch.\n");            return -1;    }    /* Apply PNG filter */    if ((avctx->codec_id == CODEC_ID_ZLIB) && (c->flags & FLAG_PNGFILTER)) {        switch (c->imgtype) {            case IMGTYPE_YUV111:            case IMGTYPE_RGB24:                for (row = 0; row < height; row++) {                    pixel_ptr = row * width * 3;                    yq = encoded[pixel_ptr++];                    uqvq = encoded[pixel_ptr++];                    uqvq+=(encoded[pixel_ptr++] << 8);                    for (col = 1; col < width; col++) {                        encoded[pixel_ptr] = yq -= encoded[pixel_ptr];                        uqvq -= (encoded[pixel_ptr+1] | (encoded[pixel_ptr+2]<<8));                        encoded[pixel_ptr+1] = (uqvq) & 0xff;                        encoded[pixel_ptr+2] = ((uqvq)>>8) & 0xff;                        pixel_ptr += 3;                    }                }                break;            case IMGTYPE_YUV422:                for (row = 0; row < height; row++) {                    pixel_ptr = row * width * 2;                    yq = uq = vq =0;                    for (col = 0; col < width/4; col++) {                        encoded[pixel_ptr] = yq -= encoded[pixel_ptr];                        encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];                        encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2];                        encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3];                        encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];                        encoded[pixel_ptr+5] = uq -= encoded[pixel_ptr+5];                        encoded[pixel_ptr+6] = vq -= encoded[pixel_ptr+6];                        encoded[pixel_ptr+7] = vq -= encoded[pixel_ptr+7];                        pixel_ptr += 8;                    }                }                break;            case IMGTYPE_YUV411:                for (row = 0; row < height; row++) {                    pixel_ptr = row * width / 2 * 3;                    yq = uq = vq =0;                    for (col = 0; col < width/4; col++) {                        encoded[pixel_ptr] = yq -= encoded[pixel_ptr];                        encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];                        encoded[pixel_ptr+2] = yq -= encoded[pixel_ptr+2];                        encoded[pixel_ptr+3] = yq -= encoded[pixel_ptr+3];                        encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];                        encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5];                        pixel_ptr += 6;                    }                }                break;            case IMGTYPE_YUV211:                for (row = 0; row < height; row++) {                    pixel_ptr = row * width * 2;                    yq = uq = vq =0;                    for (col = 0; col < width/2; col++) {                        encoded[pixel_ptr] = yq -= encoded[pixel_ptr];                        encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];                        encoded[pixel_ptr+2] = uq -= encoded[pixel_ptr+2];                        encoded[pixel_ptr+3] = vq -= encoded[pixel_ptr+3];                        pixel_ptr += 4;                    }                }                break;            case IMGTYPE_YUV420:                for (row = 0; row < height/2; row++) {                    pixel_ptr = row * width * 3;                    yq = y1q = uq = vq =0;                    for (col = 0; col < width/2; col++) {                        encoded[pixel_ptr] = yq -= encoded[pixel_ptr];                        encoded[pixel_ptr+1] = yq -= encoded[pixel_ptr+1];                        encoded[pixel_ptr+2] = y1q -= encoded[pixel_ptr+2];                        encoded[pixel_ptr+3] = y1q -= encoded[pixel_ptr+3];                        encoded[pixel_ptr+4] = uq -= encoded[pixel_ptr+4];                        encoded[pixel_ptr+5] = vq -= encoded[pixel_ptr+5];                        pixel_ptr += 6;                    }                }                break;            default:                av_log(avctx, AV_LOG_ERROR, "BUG! Unknown imagetype in pngfilter switch.\n");                return -1;        }    }    /* Convert colorspace */    switch (c->imgtype) {        case IMGTYPE_YUV111:            for (row = height - 1; row >= 0; row--) {                pixel_ptr = row * c->pic.linesize[0];                for (col = 0; col < width; col++) {                    outptr[pixel_ptr++] = get_b(encoded[0], encoded[1]);                    outptr[pixel_ptr++] = get_g(encoded[0], encoded[1], encoded[2]);                    outptr[pixel_ptr++] = get_r(encoded[0], encoded[2]);                    encoded += 3;                }            }            break;        case IMGTYPE_YUV422:            for (row = height - 1; row >= 0; row--) {                pixel_ptr = row * c->pic.linesize[0];                for (col = 0; col < width/4; col++) {                    outptr[pixel_ptr++] = get_b(encoded[0], encoded[4]);                    outptr[pixel_ptr++] = get_g(encoded[0], encoded[4], encoded[6]);                    outptr[pixel_ptr++] = get_r(encoded[0], encoded[6]);                    outptr[pixel_ptr++] = get_b(encoded[1], encoded[4]);                    outptr[pixel_ptr++] = get_g(encoded[1], encoded[4], encoded[6]);                    outptr[pixel_ptr++] = get_r(encoded[1], encoded[6]);                    outptr[pixel_ptr++] = get_b(encoded[2], encoded[5]);                    outptr[pixel_ptr++] = get_g(encoded[2], encoded[5], encoded[7]);                    outptr[pixel_ptr++] = get_r(encoded[2], encoded[7]);                    outptr[pixel_ptr++] = get_b(encoded[3], encoded[5]);                    outptr[pixel_ptr++] = get_g(encoded[3], encoded[5], encoded[7]);                    outptr[pixel_ptr++] = get_r(encoded[3], encoded[7]);                    encoded += 8;                }            }            break;        case IMGTYPE_RGB24:            for (row = height - 1; row >= 0; row--) {                pixel_ptr = row * c->pic.linesize[0];                for (col = 0; col < width; col++) {                    outptr[pixel_ptr++] = encoded[0];                    outptr[pixel_ptr++] = encoded[1];                    outptr[pixel_ptr++] = encoded[2];                    encoded += 3;                }            }            break;        case IMGTYPE_YUV411:            for (row = height - 1; row >= 0; row--) {                pixel_ptr = row * c->pic.linesize[0];                for (col = 0; col < width/4; col++) {                    outptr[pixel_ptr++] = get_b(encoded[0], encoded[4]);                    outptr[pixel_ptr++] = get_g(encoded[0], encoded[4], encoded[5]);                    outptr[pixel_ptr++] = get_r(encoded[0], encoded[5]);                    outptr[pixel_ptr++] = get_b(encoded[1], encoded[4]);                    outptr[pixel_ptr++] = get_g(encoded[1], encoded[4], encoded[5]);                    outptr[pixel_ptr++] = get_r(encoded[1], encoded[5]);                    outptr[pixel_ptr++] = get_b(encoded[2], encoded[4]);                    outptr[pixel_ptr++] = get_g(encoded[2], encoded[4], encoded[5]);                    outptr[pixel_ptr++] = get_r(encoded[2], encoded[5]);                    outptr[pixel_ptr++] = get_b(encoded[3], encoded[4]);                    outptr[pixel_ptr++] = get_g(encoded[3], encoded[4], encoded[5]);                    outptr[pixel_ptr++] = get_r(encoded[3], encoded[5]);                    encoded += 6;                }            }            break;        case IMGTYPE_YUV211:            for (row = height - 1; row >= 0; row--) {                pixel_ptr = row * c->pic.linesize[0];                for (col = 0; col < width/2; col++) {                    outptr[pixel_ptr++] = get_b(encoded[0], encoded[2]);                    outptr[pixel_ptr++] = get_g(encoded[0], encoded[2], encoded[3]);                    outptr[pixel_ptr++] = get_r(encoded[0], encoded[3]);                    outptr[pixel_ptr++] = get_b(encoded[1], encoded[2]);                    outptr[pixel_ptr++] = get_g(encoded[1], encoded[2], encoded[3]);                    outptr[pixel_ptr++] = get_r(encoded[1], encoded[3]);                    encoded += 4;                }            }            break;        case IMGTYPE_YUV420:            for (row = height / 2 - 1; row >= 0; row--) {                pixel_ptr = 2 * row * c->pic.linesize[0];                for (col = 0; col < width/2; col++) {                    outptr[pixel_ptr] = get_b(encoded[0], encoded[4]);                    outptr[pixel_ptr+1] = get_g(encoded[0], encoded[4], encoded[5]);                    outptr[pixel_ptr+2] = get_r(encoded[0], encoded[5]);                    outptr[pixel_ptr+3] = get_b(encoded[1], encoded[4]);                    outptr[pixel_ptr+4] = get_g(encoded[1], encoded[4], encoded[5]);                    outptr[pixel_ptr+5] = get_r(encoded[1], encoded[5]);                    outptr[pixel_ptr-c->pic.linesize[0]] = get_b(encoded[2], encoded[4]);                    outptr[pixel_ptr-c->pic.linesize[0]+1] = get_g(encoded[2], encoded[4], encoded[5]);                    outptr[pixel_ptr-c->pic.linesize[0]+2] = get_r(encoded[2], encoded[5]);                    outptr[pixel_ptr-c->pic.linesize[0]+3] = get_b(encoded[3], encoded[4]);                    outptr[pixel_ptr-c->pic.linesize[0]+4] = get_g(encoded[3], encoded[4], encoded[5]);                    outptr[pixel_ptr-c->pic.linesize[0]+5] = get_r(encoded[3], encoded[5]);                    pixel_ptr += 6;                    encoded += 6;                }            }            break;        default:            av_log(avctx, AV_LOG_ERROR, "BUG! Unknown imagetype in image decoder.\n");            return -1;    }    *data_size = sizeof(AVFrame);    *(AVFrame*)data = c->pic;    /* always report that the buffer was completely consumed */    return buf_size;}/* * * Encode a frame * */static int encode_frame(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){    LclContext *c = avctx->priv_data;    AVFrame *pict = data;    AVFrame * const p = &c->pic;    int i;    int zret; // Zlib return code#ifndef CONFIG_ZLIB    av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled in.\n");    return -1;#else    init_put_bits(&c->pb, buf, buf_size);    *p = *pict;    p->pict_type= FF_I_TYPE;    p->key_frame= 1;    if(avctx->pix_fmt != PIX_FMT_BGR24){        av_log(avctx, AV_LOG_ERROR, "Format not supported!\n");        return -1;    }    zret = deflateReset(&(c->zstream));    if (zret != Z_OK) {        av_log(avctx, AV_LOG_ERROR, "Deflate reset error: %d\n", zret);        return -1;    }    c->zstream.next_out = c->comp_buf;    c->zstream.avail_out = c->max_comp_size;    for(i = avctx->height - 1; i >= 0; i--) {        c->zstream.next_in = p->data[0]+p->linesize[0]*i;        c->zstream.avail_in = avctx->width*3;        zret = deflate(&(c->zstream), Z_NO_FLUSH);        if (zret != Z_OK) {            av_log(avctx, AV_LOG_ERROR, "Deflate error: %d\n", zret);            return -1;        }    }    zret = deflate(&(c->zstream), Z_FINISH);    if (zret != Z_STREAM_END) {        av_log(avctx, AV_LOG_ERROR, "Deflate error: %d\n", zret);        return -1;    }    for (i = 0; i < c->zstream.total_out; i++)        put_bits(&c->pb, 8, c->comp_buf[i]);    flush_put_bits(&c->pb);    return c->zstream.total_out;#endif}/* * * Init lcl decoder * */static int decode_init(AVCodecContext *avctx)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -