Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit 99bbc781e9c134066887fc521db7a9d3607e3de1)
... | ... |
@@ -24,11 +24,20 @@ |
24 | 24 |
//#define DEBUG |
25 | 25 |
#define RC_VARIANCE 1 // use variance or ssd for fast rc |
26 | 26 |
|
27 |
+#include "libavutil/opt.h" |
|
27 | 28 |
#include "avcodec.h" |
28 | 29 |
#include "dsputil.h" |
29 | 30 |
#include "mpegvideo.h" |
30 | 31 |
#include "dnxhdenc.h" |
31 | 32 |
|
33 |
+#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM |
|
34 |
+ |
|
35 |
+static const AVOption options[]={ |
|
36 |
+ {"nitris_compat", "encode with Avid Nitris compatibility", offsetof(DNXHDEncContext, nitris_compat), FF_OPT_TYPE_INT, 0, 0, 1, VE}, |
|
37 |
+{NULL} |
|
38 |
+}; |
|
39 |
+static const AVClass class = { "dnxhd", av_default_item_name, options, LIBAVUTIL_VERSION_INT }; |
|
40 |
+ |
|
32 | 41 |
int dct_quantize_c(MpegEncContext *s, DCTELEM *block, int n, int qscale, int *overflow); |
33 | 42 |
|
34 | 43 |
#define LAMBDA_FRAC_BITS 10 |
... | ... |
@@ -146,7 +155,7 @@ static int dnxhd_init_rc(DNXHDEncContext *ctx) |
146 | 146 |
if (ctx->m.avctx->mb_decision != FF_MB_DECISION_RD) |
147 | 147 |
FF_ALLOCZ_OR_GOTO(ctx->m.avctx, ctx->mb_cmp, ctx->m.mb_num*sizeof(RCCMPEntry), fail); |
148 | 148 |
|
149 |
- ctx->frame_bits = (ctx->cid_table->coding_unit_size - 640 - 4) * 8; |
|
149 |
+ ctx->frame_bits = (ctx->cid_table->coding_unit_size - 640 - 4 - ctx->min_padding) * 8; |
|
150 | 150 |
ctx->qscale = 1; |
151 | 151 |
ctx->lambda = 2<<LAMBDA_FRAC_BITS; // qscale 2 |
152 | 152 |
return 0; |
... | ... |
@@ -198,6 +207,10 @@ static int dnxhd_encode_init(AVCodecContext *avctx) |
198 | 198 |
if (dnxhd_init_qmat(ctx, ctx->m.intra_quant_bias, 0) < 0) // XXX tune lbias/cbias |
199 | 199 |
return -1; |
200 | 200 |
|
201 |
+ // Avid Nitris hardware decoder requires a minimum amount of padding in the coding unit payload |
|
202 |
+ if (ctx->nitris_compat) |
|
203 |
+ ctx->min_padding = 1600; |
|
204 |
+ |
|
201 | 205 |
if (dnxhd_init_vlc(ctx) < 0) |
202 | 206 |
return -1; |
203 | 207 |
if (dnxhd_init_rc(ctx) < 0) |
... | ... |
@@ -858,4 +871,5 @@ AVCodec ff_dnxhd_encoder = { |
858 | 858 |
dnxhd_encode_end, |
859 | 859 |
.pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV422P, PIX_FMT_NONE}, |
860 | 860 |
.long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"), |
861 |
+ .priv_class = &class, |
|
861 | 862 |
}; |