]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/proresenc.c
vp3: Use hpeldsp instead of dsputil for half-pel functions
[ffmpeg] / libavcodec / proresenc.c
index a24b7118c28d7b0e669c240c7f7e61c6c7551aea..5a8cea8e500ceb6c9b08ec89f3a8c0c6a7d46fd2 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "libavutil/opt.h"
 #include "avcodec.h"
+#include "dsputil.h"
 #include "put_bits.h"
 #include "bytestream.h"
 #include "internal.h"
@@ -33,7 +34,7 @@
 
 #define MAX_MBS_PER_SLICE 8
 
-#define MAX_PLANES 3 // should be increased to 4 when there's PIX_FMT_YUV444AP10
+#define MAX_PLANES 3 // should be increased to 4 when there's AV_PIX_FMT_YUV444AP10
 
 enum {
     PRORES_PROFILE_PROXY = 0,
@@ -167,7 +168,7 @@ struct TrellisNode {
 #define MAX_STORED_Q 16
 
 typedef struct ProresThreadData {
-    DECLARE_ALIGNED(16, DCTELEM, blocks)[MAX_PLANES][64 * 4 * MAX_MBS_PER_SLICE];
+    DECLARE_ALIGNED(16, int16_t, blocks)[MAX_PLANES][64 * 4 * MAX_MBS_PER_SLICE];
     DECLARE_ALIGNED(16, uint16_t, emu_buf)[16 * 16];
     int16_t custom_q[64];
     struct TrellisNode *nodes;
@@ -175,7 +176,7 @@ typedef struct ProresThreadData {
 
 typedef struct ProresContext {
     AVClass *class;
-    DECLARE_ALIGNED(16, DCTELEM, blocks)[MAX_PLANES][64 * 4 * MAX_MBS_PER_SLICE];
+    DECLARE_ALIGNED(16, int16_t, blocks)[MAX_PLANES][64 * 4 * MAX_MBS_PER_SLICE];
     DECLARE_ALIGNED(16, uint16_t, emu_buf)[16*16];
     int16_t quants[MAX_STORED_Q][64];
     int16_t custom_q[64];
@@ -210,7 +211,7 @@ typedef struct ProresContext {
 
 static void get_slice_data(ProresContext *ctx, const uint16_t *src,
                            int linesize, int x, int y, int w, int h,
-                           DCTELEM *blocks, uint16_t *emu_buf,
+                           int16_t *blocks, uint16_t *emu_buf,
                            int mbs_per_slice, int blocks_per_mb, int is_chroma)
 {
     const uint16_t *esrc;
@@ -299,8 +300,7 @@ static inline void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int
         exponent = av_log2(val);
 
         put_bits(pb, exponent - exp_order + switch_bits, 0);
-        put_bits(pb, 1, 1);
-        put_bits(pb, exponent, val);
+        put_bits(pb, exponent + 1, val);
     } else {
         exponent = val >> rice_order;
 
@@ -315,7 +315,7 @@ static inline void encode_vlc_codeword(PutBitContext *pb, unsigned codebook, int
 #define GET_SIGN(x)  ((x) >> 31)
 #define MAKE_CODE(x) (((x) << 1) ^ GET_SIGN(x))
 
-static void encode_dcs(PutBitContext *pb, DCTELEM *blocks,
+static void encode_dcs(PutBitContext *pb, int16_t *blocks,
                        int blocks_per_slice, int scale)
 {
     int i;
@@ -341,7 +341,7 @@ static void encode_dcs(PutBitContext *pb, DCTELEM *blocks,
     }
 }
 
-static void encode_acs(PutBitContext *pb, DCTELEM *blocks,
+static void encode_acs(PutBitContext *pb, int16_t *blocks,
                        int blocks_per_slice,
                        int plane_size_factor,
                        const uint8_t *scan, const int16_t *qmat)
@@ -377,7 +377,7 @@ static void encode_acs(PutBitContext *pb, DCTELEM *blocks,
 
 static int encode_slice_plane(ProresContext *ctx, PutBitContext *pb,
                               const uint16_t *src, int linesize,
-                              int mbs_per_slice, DCTELEM *blocks,
+                              int mbs_per_slice, int16_t *blocks,
                               int blocks_per_mb, int plane_size_factor,
                               const int16_t *qmat)
 {
@@ -479,7 +479,7 @@ static inline int estimate_vlc(unsigned codebook, int val)
     }
 }
 
-static int estimate_dcs(int *error, DCTELEM *blocks, int blocks_per_slice,
+static int estimate_dcs(int *error, int16_t *blocks, int blocks_per_slice,
                         int scale)
 {
     int i;
@@ -510,7 +510,7 @@ static int estimate_dcs(int *error, DCTELEM *blocks, int blocks_per_slice,
     return bits;
 }
 
-static int estimate_acs(int *error, DCTELEM *blocks, int blocks_per_slice,
+static int estimate_acs(int *error, int16_t *blocks, int blocks_per_slice,
                         int plane_size_factor,
                         const uint8_t *scan, const int16_t *qmat)
 {
@@ -868,9 +868,6 @@ static av_cold int encode_close(AVCodecContext *avctx)
     ProresContext *ctx = avctx->priv_data;
     int i;
 
-    if (avctx->coded_frame->data[0])
-        avctx->release_buffer(avctx, avctx->coded_frame);
-
     av_freep(&avctx->coded_frame);
 
     if (ctx->tdata) {
@@ -908,7 +905,7 @@ static av_cold int encode_init(AVCodecContext *avctx)
         return AVERROR(EINVAL);
     }
 
-    ctx->chroma_factor = avctx->pix_fmt == PIX_FMT_YUV422P10
+    ctx->chroma_factor = avctx->pix_fmt == AV_PIX_FMT_YUV422P10
                          ? CFACTOR_Y422
                          : CFACTOR_Y444;
     ctx->profile_info  = prores_profile_info + ctx->profile;
@@ -1025,35 +1022,35 @@ static av_cold int encode_init(AVCodecContext *avctx)
 
 static const AVOption options[] = {
     { "mbs_per_slice", "macroblocks per slice", OFFSET(mbs_per_slice),
-        AV_OPT_TYPE_INT, { 8 }, 1, MAX_MBS_PER_SLICE, VE },
+        AV_OPT_TYPE_INT, { .i64 = 8 }, 1, MAX_MBS_PER_SLICE, VE },
     { "profile",       NULL, OFFSET(profile), AV_OPT_TYPE_INT,
-        { PRORES_PROFILE_STANDARD },
+        { .i64 = PRORES_PROFILE_STANDARD },
         PRORES_PROFILE_PROXY, PRORES_PROFILE_HQ, VE, "profile" },
-    { "proxy",         NULL, 0, AV_OPT_TYPE_CONST, { PRORES_PROFILE_PROXY },
+    { "proxy",         NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRORES_PROFILE_PROXY },
         0, 0, VE, "profile" },
-    { "lt",            NULL, 0, AV_OPT_TYPE_CONST, { PRORES_PROFILE_LT },
+    { "lt",            NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRORES_PROFILE_LT },
         0, 0, VE, "profile" },
-    { "standard",      NULL, 0, AV_OPT_TYPE_CONST, { PRORES_PROFILE_STANDARD },
+    { "standard",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRORES_PROFILE_STANDARD },
         0, 0, VE, "profile" },
-    { "hq",            NULL, 0, AV_OPT_TYPE_CONST, { PRORES_PROFILE_HQ },
+    { "hq",            NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRORES_PROFILE_HQ },
         0, 0, VE, "profile" },
     { "vendor", "vendor ID", OFFSET(vendor),
         AV_OPT_TYPE_STRING, { .str = "Lavc" }, CHAR_MIN, CHAR_MAX, VE },
     { "bits_per_mb", "desired bits per macroblock", OFFSET(bits_per_mb),
-        AV_OPT_TYPE_INT, { 0 }, 0, 8192, VE },
+        AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 8192, VE },
     { "quant_mat", "quantiser matrix", OFFSET(quant_sel), AV_OPT_TYPE_INT,
-        { -1 }, -1, QUANT_MAT_DEFAULT, VE, "quant_mat" },
-    { "auto",          NULL, 0, AV_OPT_TYPE_CONST, { -1 },
+        { .i64 = -1 }, -1, QUANT_MAT_DEFAULT, VE, "quant_mat" },
+    { "auto",          NULL, 0, AV_OPT_TYPE_CONST, { .i64 = -1 },
         0, 0, VE, "quant_mat" },
-    { "proxy",         NULL, 0, AV_OPT_TYPE_CONST, { QUANT_MAT_PROXY },
+    { "proxy",         NULL, 0, AV_OPT_TYPE_CONST, { .i64 = QUANT_MAT_PROXY },
         0, 0, VE, "quant_mat" },
-    { "lt",            NULL, 0, AV_OPT_TYPE_CONST, { QUANT_MAT_LT },
+    { "lt",            NULL, 0, AV_OPT_TYPE_CONST, { .i64 = QUANT_MAT_LT },
         0, 0, VE, "quant_mat" },
-    { "standard",      NULL, 0, AV_OPT_TYPE_CONST, { QUANT_MAT_STANDARD },
+    { "standard",      NULL, 0, AV_OPT_TYPE_CONST, { .i64 = QUANT_MAT_STANDARD },
         0, 0, VE, "quant_mat" },
-    { "hq",            NULL, 0, AV_OPT_TYPE_CONST, { QUANT_MAT_HQ },
+    { "hq",            NULL, 0, AV_OPT_TYPE_CONST, { .i64 = QUANT_MAT_HQ },
         0, 0, VE, "quant_mat" },
-    { "default",       NULL, 0, AV_OPT_TYPE_CONST, { QUANT_MAT_DEFAULT },
+    { "default",       NULL, 0, AV_OPT_TYPE_CONST, { .i64 = QUANT_MAT_DEFAULT },
         0, 0, VE, "quant_mat" },
     { NULL }
 };
@@ -1075,8 +1072,8 @@ AVCodec ff_prores_encoder = {
     .encode2        = encode_frame,
     .capabilities   = CODEC_CAP_SLICE_THREADS,
     .long_name      = NULL_IF_CONFIG_SMALL("Apple ProRes (iCodec Pro)"),
-    .pix_fmts       = (const enum PixelFormat[]) {
-                          PIX_FMT_YUV422P10, PIX_FMT_YUV444P10, PIX_FMT_NONE
+    .pix_fmts       = (const enum AVPixelFormat[]) {
+                          AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV444P10, AV_PIX_FMT_NONE
                       },
     .priv_class     = &proresenc_class,
 };