[FFmpeg-devel] Apple Prores Encoder

Michael Niedermayer michaelni at gmx.at
Sat Oct 29 00:31:44 CEST 2011


Hi

On Fri, Oct 28, 2011 at 01:43:57PM -0700, Wasserman Anatoliy wrote:
> Hello,
> 
> I have developed Apple Prores Encoder.
> It has rate-control for 4 profiles: 'apch' - 185mbps, 'apcn' - 112mbps, 'apcs' - 75mbps, 'apco' - 36mbps.
> The profiles are triggered from ffmpeg command line via '-profile' option ( 0 - apco, 1 - apcs, 2 - apcn, 3 - apch), the default profile is apch.
> It accepts yuv422p10le pix format frames.
> It's not yet multithreaded.
> 
[...]
> diff --git a/libavcodec/proresenc.c b/libavcodec/proresenc.c
> new file mode 100644
> index 0000000..42df560
> --- /dev/null
> +++ b/libavcodec/proresenc.c
> @@ -0,0 +1,558 @@
> +/*
> + * Apple ProRes encoder
> + *
> + * Copyright (c) 2010-2011 Anatoliy Wasserman
> + *
> + * This file is part of Libav.
> + *
> + * Libav is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * Libav is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with Libav; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

Is it ok with you if we replace the Libav by FFmpeg ?

[...]
> +static av_cold int prores_encode_init(AVCodecContext *avctx)
> +{
> +    int i;
> +    ProresContext* ctx = (ProresContext*)avctx->priv_data;
> +
> +    if (avctx->pix_fmt != PIX_FMT_YUV422P10LE) {
> +        av_log(avctx, AV_LOG_ERROR, "prores: need YUV422P10\n");
> +        return -1;
> +    }
> +    if (avctx->width & 0x1) {
> +        av_log(avctx, AV_LOG_ERROR, "prores: frame width needs to be multiple of 2\n");
> +        return -1;
> +    }
> +
> +    memset(ctx, 0, sizeof(ProresContext));
> +    if ((avctx->height & 0xf) || (avctx->width & 0xf)) {
> +        ctx->fill_y = av_malloc(DEFAULT_SLICE_MB_WIDTH << 9);
> +        ctx->fill_u = av_malloc(DEFAULT_SLICE_MB_WIDTH << 8);
> +        ctx->fill_v = av_malloc(DEFAULT_SLICE_MB_WIDTH << 8);
> +    }
> +    if (avctx->profile == FF_PROFILE_UNKNOWN)
> +        avctx->profile = FF_PROFILE_PRORES_HQ;
> +    else if (avctx->profile < FF_PROFILE_PRORES_PROXY || avctx->profile > FF_PROFILE_PRORES_HQ) {
> +        av_log(avctx, AV_LOG_ERROR, "prores: unknown profile %d, use [0 - apco, 1 - apcs, 2 - apcn, 3 - apch]\n",
> +                avctx->profile);
> +        return -1;
> +    }

> +    avctx->codec_tag = *((const int*)profiles[avctx->profile].name);

AV_RL/B32() otherwise it wont work on big endian


> +
> +    for(i = 1; i <= 16; i++) {
> +        scale_mat(QMAT_LUMA[avctx->profile], ctx->qmat_luma[i - 1], i);
> +        scale_mat(QMAT_CHROMA[avctx->profile], ctx->qmat_chroma[i - 1], i);
> +    }
> +
> +    avctx->coded_frame = avcodec_alloc_frame();
> +    avctx->coded_frame->key_frame = 1;
> +    avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
> +
> +    return 0;
> +}
> +
> +static av_cold int prores_encode_close(AVCodecContext *avctx)
> +{
> +    ProresContext* ctx = (ProresContext*)avctx->priv_data;
> +    av_freep(&avctx->coded_frame);

> +    if (ctx->fill_y != NULL)
> +        av_free(ctx->fill_y);
> +    if (ctx->fill_u != NULL)
> +        av_free(ctx->fill_u);
> +    if (ctx->fill_v != NULL)
> +        av_free(ctx->fill_v);

the if() are unneeded

Also, very nice work, thank you alot for the contribution!


[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20111029/b0b59853/attachment.asc>


More information about the ffmpeg-devel mailing list