On Sun, Dec 04, 2011 at 01:42:50PM -0500, Derek Buitenhuis wrote:
> Port the ProRes encoder by "Anatoliy Wasserman", and include
> the fixes by Michael Niedermayer and Reimar Döffinger.
Just use "Apple ProRes encoder" or something similar as log message.
> ---
> Changelog | 1 +
> doc/general.texi | 2 +-
> libavcodec/Makefile | 1 +
> libavcodec/allcodecs.c | 2 +-
> libavcodec/proresenc.c | 599
> ++++++++++++++++++++++++++++++++++++++++++++++++
> 5 files changed, 603 insertions(+), 2 deletions(-)
> create mode 100644 libavcodec/proresenc.c
libavcodec version bump is missing; please see the new formats checklist
in the developer docs and make sure you address all points.
> --- a/Changelog
> +++ b/Changelog
> @@ -105,6 +105,7 @@ easier to use. The changes are:
> - Playstation Portable PMP format demuxer
> - PCM format support in OMA demuxer
> +- Prores encoder
ProRes
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -298,6 +298,7 @@ OBJS-$(CONFIG_PNG_ENCODER) += png.o pngenc.o
> OBJS-$(CONFIG_PPM_ENCODER) += pnmenc.o pnm.o
> OBJS-$(CONFIG_PRORES_DECODER) += proresdec.o proresdsp.o
> +OBJS-$(CONFIG_PRORES_ENCODER) += proresenc.o
> OBJS-$(CONFIG_PTX_DECODER) += ptx.o
Did you make sure it compiles standalone?
> --- /dev/null
> +++ b/libavcodec/proresenc.c
> @@ -0,0 +1,599 @@
> +/**
> + * @file libavcodec/proresenc.c
Drop the filename.
> +static void encode_codeword(PutBitContext *pb, int val, int codebook)
> +{
> + unsigned int rice_order, exp_order, switch_bits, first_exp, exp, zeros,
> + mask;
funky indentation
> + first_exp = ((switch_bits + 1) << rice_order);
one, arguably two, sets of pointless parentheses
> + } else if (rice_order) {
> + mask = (1 << rice_order) - 1;
> + put_bits(pb, (val >> rice_order), 0);
pointless parentheses
> +static void encode_dc_coeffs(PutBitContext *pb, DCTELEM *in,
> + int blocks_per_slice, int *qmat)
Indentation is off.
> +static const uint8_t run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29,
> + 0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C };
> +static const uint8_t lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28,
> + 0x28, 0x28, 0x28, 0x4C };
ditto
> +static void encode_ac_coeffs(AVCodecContext *avctx, PutBitContext *pb,
> + DCTELEM *in, int blocks_per_slice, int *qmat)
ditto
> + int prev_run = 4;
> + int prev_level = 2;
nit: = could be aligned
> +static void get(uint8_t *pixels, int stride, DCTELEM* block)
inconsistent star placement
> + for (i = 0; i < 8; i++) {
> + for (j = 0; j < 8; j++) {
> + block[j] = p[j];
> + }
drop the {} for one-line for statements, more below
> +static void fdct_get(uint8_t *pixels, int stride, DCTELEM* block)
ditto
> +static int encode_slice_plane(AVCodecContext *avctx, int mb_count,
> + uint8_t *src, int src_stride, uint8_t *buf, unsigned buf_size,
> + int *qmat, int chroma)
indentation
> + block += (256 >> chroma);
> + src += (32 >> chroma);
pointless ()
> +static av_always_inline unsigned encode_slice_data(AVCodecContext *avctx,
> + uint8_t *dest_y, uint8_t *dest_u, uint8_t *dest_v, int luma_stride,
> + int chroma_stride, unsigned mb_count, uint8_t *buf, unsigned
> data_size,
> + unsigned* y_data_size, unsigned* u_data_size, unsigned* v_data_size,
> + int qp)
indentation, more below
> + *y_data_size = encode_slice_plane(avctx, mb_count, dest_y, luma_stride,
> + buf, data_size, ctx->qmat_luma[qp - 1], 0);
indentation, more below
> + if (avctx->pix_fmt != PIX_FMT_YUV422P10) {
> + av_log(avctx, AV_LOG_ERROR, "need YUV422P10\n");
> + return -1;
> + }
The message is a tad terse; you could return a more sensible value
here I think.
> + if (avctx->width & 0x1) {
> + av_log(avctx, AV_LOG_ERROR,
> + "frame width needs to be multiple of 2\n");
> + return -1;
ditto and indentation is off
> + if (avctx->profile == FF_PROFILE_UNKNOWN) {
> + avctx->profile = FF_PROFILE_PRORES_STANDARD;
> + av_log(avctx, AV_LOG_INFO,
> + "encoding with ProRes standard (apcn) profile\n");
indentation
> + } else if (avctx->profile < FF_PROFILE_PRORES_PROXY
> + || avctx->profile > FF_PROFILE_PRORES_HQ) {
> + av_log(
> + avctx,
> + AV_LOG_ERROR,
> + "unknown profile %d, use [0 - apco, 1 - apcs, 2 - apcn
> (default), 3 - apch]\n",
> + avctx->profile);
/* no comment */
> + avctx->coded_frame = avcodec_alloc_frame();
> + avctx->coded_frame->key_frame = 1;
> + avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
align the =
> +static av_cold int prores_encode_close(AVCodecContext *avctx)
> +{
> + ProresContext* ctx = avctx->priv_data;
Place the star with the variable name.
> +AVCodec ff_prores_encoder = {
> + .name = "prores",
> + .type = AVMEDIA_TYPE_VIDEO,
> + .id = CODEC_ID_PRORES,
> + .priv_data_size = sizeof(ProresContext),
> + .init = prores_encode_init,
> + .close = prores_encode_close,
> + .encode = prores_encode_frame,
> + .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV422P10,
> PIX_FMT_NONE},
> + .long_name = NULL_IF_CONFIG_SMALL("Apple ProRes"),
> + .capabilities = 0,
> + .profiles = profiles
Drop the 0 initialization.
Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel