#include "libavutil/opt.h"
#include "avcodec.h"
+#include "dsputil.h"
#include "put_bits.h"
#include "bytestream.h"
#include "internal.h"
#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,
#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;
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];
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;
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;
#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;
}
}
-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)
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)
{
}
}
-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;
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)
{
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) {
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;
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 }
};
.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,
};