[FFmpeg-devel] using usb hardware h264 encoders

Michael Niedermayer michaelni
Mon Nov 9 12:30:07 CET 2009


On Wed, Nov 04, 2009 at 04:54:17PM +0200, Sergiy wrote:
> Sorry, it was not full. Here is full patch.
> 
> >
> > Ok, here is fixed patch.
> >
> >

>  configure                  |    7 +
>  libavcodec/Makefile        |    1 
>  libavcodec/allcodecs.c     |    1 
>  libavcodec/libcrusher264.c |  264 +++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 273 insertions(+)
> f4a6f6e34161bf9d5c90fd20491aa308037e57c7  libcrusher264.patch
> diff --git a/configure b/configure
> index b876e66..eca21e3 100755
> --- a/configure
> +++ b/configure
[...]
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile

not maintained by me ...


[...]

> +/* parse every qbox, received in codec flushed event */
> +static int add_nals(AVCodecContext *ctx, uint8_t *out_buff, int in_bufsize)

comments should be doxygen compatible


[...]
> +
> +static int CrusherEnc_frame(AVCodecContext *ctx, uint8_t *buf,
> +                                int bufsize, void *data)
> +{
> +    CrusherEncContext *c4 = ctx->priv_data;
> +    AVFrame *frame = data;
> +    int ret = -1;
> +    int datalen = 0;
> +
> +    assert(ctx->pix_fmt == PIX_FMT_YUV420P);
> +
> +    if(frame){
> +        /* Convert planes to the crusher format (UV12 blocked) */

what is UV12 blocked?


> +        if (frame->linesize[1] != frame->linesize[2]) {
> +            av_log(ctx, AV_LOG_ERROR, "U and V stride differ\n");
> +            return -1;
> +        }
> +
> +        c4->converter.y_stride  = frame->linesize[0];
> +        c4->converter.uv_stride = frame->linesize[1];
> +        c4->converter.y = frame->data[0];
> +        c4->converter.u = frame->data[1];
> +        c4->converter.v = frame->data[2];
> +        if (imgConverter_convert(&c4->converter) != CONVERTER_FINISHED) {
> +            av_log(ctx, AV_LOG_ERROR, "Converter failed!\n");
> +            return -1;
> +        }
> +
> +        do  {
> +            ret = crusher_encode(&c4->enc, c4->converter.iyuv_blocked, c4->converter.iyuv_frame_size_d);
> +            if(ret == CODEC_FLUSHED) {
> +                datalen+= add_nals(ctx, buf+datalen, bufsize-datalen);
> +                /* hack: maybe qbox cts can be usable here? */
> +                ctx->coded_frame->pts = frame->pts;

whats a qbox cts ?


> +            }
> +        } while (ret == CODEC_FLUSHED);
> +    } else if(!c4->enc.finished) {

> +        av_log(ctx, AV_LOG_ERROR, "Codec finishing!\n");

doesnt sound like an error


[...]
> +static av_cold int CrusherEnc_init(AVCodecContext *avctx)
> +{
> +    CrusherEncContext *c4 = avctx->priv_data;
> +
> +    crusher_defaults(&c4->enc);
> +    c4->enc.out_format = OUT_FORMAT_QBOX;
> +    c4->enc.width      = avctx->width;
> +    c4->enc.height     = avctx->height;
> +    c4->enc.bitrate    = avctx->bit_rate;
> +    c4->enc.framerate  = avctx->time_base.den;
> +    c4->enc.gopsize    = avctx->gop_size;
> +    if(avctx->rc_buffer_size)
> +        c4->enc.rc_size = avctx->rc_buffer_size;
> +
> +    c4->enc.scenecut_threshold = avctx->scenechange_threshold;
> +    c4->enc.deblock = (avctx->flags & CODEC_FLAG_LOOP_FILTER) ? 1 : 0;
> +    c4->enc.deblock_alpha = avctx->deblockalpha;
> +    c4->enc.deblock_beta = avctx->deblockbeta;
> +

> +    av_log(avctx, AV_LOG_ERROR, "fmt=%d, w=%d, h=%d, br=%d, fr=%d, gop_s=%d, rc_s=%d, sc_newgop=%d, db=%d, db_a=%d, db_b=%d",
> +        c4->enc.out_format, c4->enc.width, c4->enc.height, c4->enc.bitrate, c4->enc.framerate, c4->enc.gopsize,
> +        c4->enc.rc_size, c4->enc.scenecut_threshold, c4->enc.deblock, c4->enc.deblock_alpha, c4->enc.deblock_beta );

dont misuse AV_LOG_ERROR

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is not what we do, but why we do it that matters.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091109/0c753cd9/attachment.pgp>



More information about the ffmpeg-devel mailing list