Browse code

DNxHD: Add support for id 1258 (DNx100 960x720@8)

Signed-off-by: Vittorio Giovara <vittorio.giovara@gmail.com>

Vittorio Giovara authored on 2015/01/28 05:56:20
Showing 3 changed files
... ...
@@ -11,6 +11,7 @@ version <next>:
11 11
 - RTP/mpegts muxer
12 12
 - VP8 in Ogg demuxing
13 13
 - OpenH264 encoder wrapper
14
+- Support DNx100 (960x720@8)
14 15
 
15 16
 
16 17
 version 11:
... ...
@@ -231,6 +231,28 @@ static const uint8_t dnxhd_1256_chroma_weight[] = {
231 231
     34, 37, 39, 44, 51, 56, 61, 70,
232 232
 };
233 233
 
234
+static const uint8_t dnxhd_1258_luma_weight[] = {
235
+     0, 32, 36, 36,  40,  40, 55, 60,
236
+    34, 36, 37, 40,  41,  48, 57, 82,
237
+    35, 36, 41, 41,  46,  52, 73, 82,
238
+    37, 40, 42, 45,  50,  65, 80, 87,
239
+    39, 41, 44, 49,  62,  78, 88, 90,
240
+    41, 44, 49, 58,  73,  90, 95, 95,
241
+    43, 52, 55, 68,  90, 100, 97, 93,
242
+    52, 53, 71, 82, 107, 103, 99, 99,
243
+};
244
+
245
+static const uint8_t dnxhd_1258_chroma_weight[] = {
246
+     0, 32, 37,  38,  49,  53,  65,  66,
247
+    35, 37, 40,  49,  56,  64,  65,  82,
248
+    36, 42, 50,  56,  64,  67,  73,  85,
249
+    46, 50, 57,  63,  71,  72,  89,  87,
250
+    49, 58, 65,  72,  78,  88,  88,  90,
251
+    60, 64, 74,  81,  84,  90,  95, 134,
252
+    62, 74, 77,  80,  90, 114, 129, 125,
253
+    74, 74, 90, 100, 128, 125, 116, 116,
254
+};
255
+
234 256
 static const uint8_t dnxhd_1237_dc_codes[12] = {
235 257
     0, 12, 13, 1, 2, 3, 4, 5, 14, 30, 62, 63,
236 258
 };
... ...
@@ -1073,6 +1095,14 @@ static const uint8_t dnxhd_1252_ac_index_flag[257] = {
1073 1073
     1,
1074 1074
 };
1075 1075
 
1076
+static const uint8_t dnxhd_1258_dc_codes[14] = {
1077
+    0, 12, 13, 1, 2, 3, 4, 5, 14, 30, 62, 63, 0, 0,
1078
+};
1079
+
1080
+static const uint8_t dnxhd_1258_dc_bits[14] = {
1081
+    3, 4, 4, 3, 3, 3, 3, 3, 4, 5, 6, 6, 0, 0,
1082
+};
1083
+
1076 1084
 const CIDEntry ff_dnxhd_cid_table[] = {
1077 1085
     { 1235, 1920, 1080, 0, 917504, 917504, 6, 10,
1078 1086
       dnxhd_1235_luma_weight, dnxhd_1235_chroma_weight,
... ...
@@ -1151,6 +1181,13 @@ const CIDEntry ff_dnxhd_cid_table[] = {
1151 1151
       dnxhd_1235_1241_ac_run_flag, dnxhd_1235_1241_ac_index_flag,
1152 1152
       dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1235_1241_run,
1153 1153
       { 350, 390, 440, 730, 880 } },
1154
+    { 1258, 960, 720, 0, 212992, 212992, 4, 8,
1155
+      dnxhd_1258_luma_weight, dnxhd_1258_chroma_weight,
1156
+      dnxhd_1258_dc_codes, dnxhd_1258_dc_bits,
1157
+      dnxhd_1252_ac_codes, dnxhd_1252_ac_bits, dnxhd_1252_ac_level,
1158
+      dnxhd_1252_ac_run_flag, dnxhd_1252_ac_index_flag,
1159
+      dnxhd_1251_run_codes, dnxhd_1251_run_bits, dnxhd_1251_run,
1160
+      { 42, 60, 75, 115 } },
1154 1161
 };
1155 1162
 
1156 1163
 int ff_dnxhd_get_cid_table(int cid)
... ...
@@ -165,6 +165,15 @@ static int dnxhd_decode_header(DNXHDContext *ctx, AVFrame *frame,
165 165
     if ((ret = dnxhd_init_vlc(ctx, cid)) < 0)
166 166
         return ret;
167 167
 
168
+    // make sure profile size constraints are respected
169
+    // DNx100 allows 1920->1440 and 1280->960 subsampling
170
+    if (ctx->width != ctx->cid_table->width) {
171
+        av_reduce(&ctx->avctx->sample_aspect_ratio.num,
172
+                  &ctx->avctx->sample_aspect_ratio.den,
173
+                  ctx->width, ctx->cid_table->width, 255);
174
+        ctx->width = ctx->cid_table->width;
175
+    }
176
+
168 177
     if (buf_size < ctx->cid_table->coding_unit_size) {
169 178
         av_log(ctx->avctx, AV_LOG_ERROR, "incorrect frame size (%d < %d).\n",
170 179
                buf_size, ctx->cid_table->coding_unit_size);