]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/dnxhddata.c
nvenc: Allow different const qps for I, P and B frames
[ffmpeg] / libavcodec / dnxhddata.c
index 0f2f06325b1e166ad13e29207cb0ae51de0c9c54..55272e9cf36faea1f5670f4fb4918e45adf5404a 100644 (file)
 #include "dnxhddata.h"
 #include "libavutil/common.h"
 
+/* The quantization tables below are in zigzag order! */
+
+/* Used in CID 1235, 1256 */
 static const uint8_t dnxhd_1235_luma_weight[] = {
-     0, 32, 32, 32, 33, 35, 38, 39,
-    32, 33, 32, 33, 36, 36, 39, 42,
-    32, 32, 33, 36, 35, 37, 41, 43,
-    31, 33, 34, 36, 36, 40, 42, 48,
-    32, 34, 36, 37, 39, 42, 46, 51,
-    36, 37, 37, 39, 41, 46, 51, 55,
-    37, 39, 41, 41, 47, 50, 55, 56,
-    41, 42, 41, 44, 50, 53, 60, 60
+     0, 32, 32, 32, 33, 32, 32, 32,
+    32, 31, 32, 33, 33, 33, 33, 35,
+    36, 36, 34, 34, 36, 37, 37, 36,
+    36, 35, 36, 38, 39, 39, 37, 36,
+    37, 37, 39, 41, 42, 41, 39, 39,
+    40, 41, 42, 43, 42, 42, 41, 41,
+    41, 44, 47, 46, 46, 48, 51, 51,
+    50, 50, 53, 55, 55, 56, 60, 60,
 };
 
+/* Used in CID 1235, 1256 */
 static const uint8_t dnxhd_1235_chroma_weight[] = {
-     0, 32, 33, 34, 39, 41, 54, 59,
-    33, 34, 35, 38, 43, 49, 58, 84,
-    34, 37, 39, 44, 46, 55, 74, 87,
-    40, 42, 47, 48, 58, 70, 87, 86,
-    43, 50, 56, 63, 72, 94, 91, 82,
-    55, 63, 65, 75, 93, 89, 85, 73,
-    61, 67, 82, 81, 83, 90, 79, 73,
-    74, 84, 75, 78, 90, 85, 73, 73
+     0, 32, 33, 34, 34, 33, 34, 35,
+    37, 40, 43, 42, 39, 38, 39, 41,
+    43, 44, 47, 50, 55, 61, 63, 56,
+    48, 46, 49, 54, 59, 58, 55, 58,
+    63, 65, 67, 74, 84, 82, 75, 72,
+    70, 74, 84, 87, 87, 94, 93, 81,
+    75, 78, 83, 89, 91, 86, 82, 85,
+    90, 90, 85, 79, 73, 73, 73, 73,
 };
 
+/* Used in CID 1237, 1253, 1259 */
 static const uint8_t dnxhd_1237_luma_weight[] = {
      0,  32,  33,  34, 34, 36, 37, 36,
     36,  37,  38,  38, 38, 39, 41, 44,
@@ -56,6 +61,7 @@ static const uint8_t dnxhd_1237_luma_weight[] = {
     97, 100, 104, 102, 98, 98, 99, 99,
 };
 
+/* Used in CID 1237, 1253, 1259 */
 static const uint8_t dnxhd_1237_chroma_weight[] = {
      0,  32,  36,  39, 39, 38, 39,  41,
     45,  51,  57,  58, 53, 48, 47,  51,
@@ -156,25 +162,25 @@ static const uint8_t dnxhd_1243_chroma_weight[] = {
 };
 
 static const uint8_t dnxhd_1250_luma_weight[] = {
-     0, 32, 35, 35, 36, 36, 41, 43,
-    32, 34, 35, 36, 37, 39, 43, 47,
-    33, 34, 36, 38, 38, 42, 42, 50,
-    34, 36, 38, 38, 41, 40, 47, 54,
-    35, 38, 39, 40, 39, 45, 49, 58,
-    38, 39, 40, 39, 46, 47, 54, 60,
-    38, 39, 41, 46, 46, 48, 57, 62,
-    40, 41, 44, 45, 49, 54, 63, 63
+     0, 32, 32, 33, 34, 35, 35, 35,
+    34, 34, 35, 36, 36, 36, 36, 36,
+    37, 38, 38, 38, 38, 38, 39, 39,
+    38, 38, 39, 41, 43, 43, 42, 41,
+    40, 40, 39, 40, 41, 41, 39, 39,
+    40, 42, 47, 50, 47, 45, 46, 46,
+    44, 45, 46, 47, 49, 54, 58, 54,
+    48, 49, 54, 57, 60, 62, 63, 63,
 };
 
 static const uint8_t dnxhd_1250_chroma_weight[] = {
-     0, 32, 35, 36, 40, 42, 51, 51,
-    35, 36, 39, 39, 43, 51, 52, 55,
-    36, 41, 41, 43, 51, 53, 54, 56,
-    43, 44, 45, 50, 54, 54, 55, 57,
-    45, 48, 50, 51, 55, 58, 59, 58,
-    49, 52, 49, 57, 58, 62, 58, 60,
-    51, 51, 56, 58, 62, 61, 59, 62,
-    52, 52, 60, 61, 59, 59, 63, 63
+     0, 32, 35, 36, 36, 35, 36, 39,
+    41, 43, 45, 44, 41, 39, 40, 42,
+    43, 43, 45, 48, 49, 51, 52, 50,
+    50, 51, 51, 51, 51, 52, 53, 54,
+    51, 49, 51, 52, 52, 56, 57, 55,
+    54, 54, 55, 56, 55, 58, 58, 58,
+    60, 61, 62, 62, 59, 57, 58, 58,
+    61, 59, 59, 59, 60, 62, 63, 63,
 };
 
 static const uint8_t dnxhd_1251_luma_weight[] = {
@@ -199,6 +205,7 @@ static const uint8_t dnxhd_1251_chroma_weight[] = {
     61, 59, 59, 59, 61, 62, 62, 62,
 };
 
+/* Used in CID 1252, 1258 */
 static const uint8_t dnxhd_1252_luma_weight[] = {
       0,  32,  34, 35, 36, 36, 36, 37,
      36,  37,  39, 40, 41, 40, 40, 40,
@@ -209,6 +216,8 @@ static const uint8_t dnxhd_1252_luma_weight[] = {
      71,  82,  90, 90, 88, 87, 90, 95,
     100, 107, 103, 97, 95, 93, 99, 99,
 };
+
+/* Used in CID 1252, 1258 */
 static const uint8_t dnxhd_1252_chroma_weight[] = {
       0,  32,  35,  36,  37,  37,  38,  40,
      42,  46,  49,  50,  50,  49,  49,  53,
@@ -220,47 +229,49 @@ static const uint8_t dnxhd_1252_chroma_weight[] = {
     114, 128, 125, 129, 134, 125, 116, 116,
 };
 
-static const uint8_t dnxhd_1256_chroma_weight[] = {
-     0, 32, 32, 32, 32, 32, 32, 33,
-    32, 32, 32, 32, 32, 32, 32, 34,
-    32, 32, 32, 32, 32, 32, 33, 37,
-    32, 32, 32, 32, 32, 32, 36, 39,
-    32, 32, 32, 32, 32, 34, 39, 44,
-    32, 37, 32, 32, 35, 40, 43, 49,
-    32, 33, 36, 36, 40, 43, 50, 60,
-    34, 37, 39, 44, 51, 56, 61, 70,
+static const uint8_t dnxhd_1260_luma_weight[] = {
+     0, 32, 33, 34, 36, 37, 37, 36,
+    34, 33, 34, 35, 37, 38, 40, 41,
+    40, 39, 38, 37, 34, 33, 34, 37,
+    40, 44, 48, 52, 53, 49, 47, 45,
+    42, 38, 36, 36, 38, 41, 43, 44,
+    46, 49, 52, 54, 54, 49, 44, 44,
+    44, 47, 51, 51, 52, 51, 48, 50,
+    52, 53, 53, 50, 50, 54, 54, 54,
 };
 
-static const uint8_t dnxhd_1258_luma_weight[] = {
-     0, 32, 36, 36,  40,  40, 55, 60,
-    34, 36, 37, 40,  41,  48, 57, 82,
-    35, 36, 41, 41,  46,  52, 73, 82,
-    37, 40, 42, 45,  50,  65, 80, 87,
-    39, 41, 44, 49,  62,  78, 88, 90,
-    41, 44, 49, 58,  73,  90, 95, 95,
-    43, 52, 55, 68,  90, 100, 97, 93,
-    52, 53, 71, 82, 107, 103, 99, 99,
+static const uint8_t dnxhd_1260_chroma_weight[] = {
+     0, 32, 34, 38, 42, 40, 38, 36,
+    35, 35, 38, 42, 43, 43, 42, 40,
+    38, 39, 43, 43, 42, 41, 43, 43,
+    42, 44, 46, 45, 45, 46, 47, 46,
+    44, 44, 45, 46, 46, 46, 50, 50,
+    47, 47, 49, 49, 49, 49, 51, 53,
+    51, 49, 53, 57, 56, 52, 50, 52,
+    56, 56, 53, 53, 53, 54, 58, 58,
 };
 
-static const uint8_t dnxhd_1258_chroma_weight[] = {
-     0, 32, 37,  38,  49,  53,  65,  66,
-    35, 37, 40,  49,  56,  64,  65,  82,
-    36, 42, 50,  56,  64,  67,  73,  85,
-    46, 50, 57,  63,  71,  72,  89,  87,
-    49, 58, 65,  72,  78,  88,  88,  90,
-    60, 64, 74,  81,  84,  90,  95, 134,
-    62, 74, 77,  80,  90, 114, 129, 125,
-    74, 74, 90, 100, 128, 125, 116, 116,
+/* Used in CID 1235, 1241, 1250, 1256 */
+static const uint8_t dnxhd_1235_dc_codes[14] = {
+    10, 62, 11, 12, 13, 0, 1, 2, 3, 4, 14, 30, 126, 127,
+};
+
+/* Used in CID 1235, 1241, 1250, 1256 */
+static const uint8_t dnxhd_1235_dc_bits[14] = {
+    4, 6, 4, 4, 4, 3, 3, 3, 3, 3, 4, 5, 7, 7,
 };
 
+/* Used in CID 1237, 1238, 1242, 1243, 1251, 1252, 1253, 1258, 1259, 1260 */
 static const uint8_t dnxhd_1237_dc_codes[12] = {
     0, 12, 13, 1, 2, 3, 4, 5, 14, 30, 62, 63,
 };
 
+/* Used in CID 1237, 1238, 1242, 1243, 1251, 1252, 1253, 1258, 1259, 1260 */
 static const uint8_t dnxhd_1237_dc_bits[12] = {
     3, 4, 4, 3, 3, 3, 3, 3, 4, 5, 6, 6,
 };
 
+/* Used in CID 1237, 1242, 1253, 1259, 1260 */
 static const uint16_t dnxhd_1237_ac_codes[257] = {
         0,     1,     4,     5,    12,    26,    27,    56,
        57,    58,    59,   120,   121,   244,   245,   246,
@@ -297,6 +308,7 @@ static const uint16_t dnxhd_1237_ac_codes[257] = {
     65535,
 };
 
+/* Used in CID 1237, 1242, 1253, 1259, 1260 */
 static const uint8_t dnxhd_1237_ac_bits[257] = {
      2,  2,  3,  3,  4,  5,  5,  6,  6,  6,  6,  7,  7,  8,  8,  8,
      8,  8,  9,  9,  9,  9,  9, 10, 10, 10, 10, 10, 10, 11, 11, 11,
@@ -317,6 +329,7 @@ static const uint8_t dnxhd_1237_ac_bits[257] = {
     16,
 };
 
+/* Used in CID 1237, 1242, 1253, 1259, 1260 */
 static const uint8_t dnxhd_1237_ac_level[257] = {
      1,  1,  2,  0,  3,  4,  2,  5,  6,  7,  3,  8,  9, 10, 11, 12,
      4,  5, 13, 14, 15, 16,  6, 17, 18, 19, 20, 21,  7, 22, 23, 24,
@@ -337,6 +350,7 @@ static const uint8_t dnxhd_1237_ac_level[257] = {
     64,
 };
 
+/* Used in CID 1237, 1242, 1253, 1259, 1260 */
 static const uint8_t dnxhd_1237_ac_run_flag[257] = {
     0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0,
     1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0,
@@ -357,6 +371,7 @@ static const uint8_t dnxhd_1237_ac_run_flag[257] = {
     1,
 };
 
+/* Used in CID 1237, 1242, 1253, 1259, 1260 */
 static const uint8_t dnxhd_1237_ac_index_flag[257] = {
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -377,39 +392,7 @@ static const uint8_t dnxhd_1237_ac_index_flag[257] = {
     1,
 };
 
-static const uint16_t dnxhd_1237_run_codes[62] = {
-       0,    4,   10,   11,   24,   25,   26,   54,
-      55,   56,   57,   58,  118,  119,  240,  482,
-     483,  484,  485,  486,  487,  488,  489,  490,
-     491,  492,  493,  494,  990,  991,  992,  993,
-     994,  995,  996,  997,  998,  999, 1000, 1001,
-    1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009,
-    1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017,
-    1018, 1019, 1020, 1021, 1022, 1023,
-};
-
-static const uint8_t dnxhd_1237_run_bits[62] = {
-     1,  3,  4,  4,  5,  5,  5,  6,  6,  6,  6,  6,  7,  7,  8,  9,
-     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9, 10, 10, 10, 10,
-    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
-    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
-};
-
-static const uint8_t dnxhd_1237_run[62] = {
-     1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
-    17, 18, 19, 20, 21, 53, 57, 58, 59, 60, 61, 62, 22, 23, 24, 25,
-    26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
-    42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 54, 55, 56,
-};
-
-static const uint8_t dnxhd_1238_dc_codes[12] = {
-    0, 12, 13, 1, 2, 3, 4, 5, 14, 30, 62, 63,
-};
-
-static const uint8_t dnxhd_1238_dc_bits[12] = {
-    3, 4, 4, 3, 3, 3, 3, 3, 4, 5, 6, 6,
-};
-
+/* Used in CID 1238, 1243 */
 static const uint16_t dnxhd_1238_ac_codes[257] = {
         0,     1,     4,    10,    11,    24,    25,    26,
        54,    55,    56,    57,   116,   117,   118,   119,
@@ -446,6 +429,7 @@ static const uint16_t dnxhd_1238_ac_codes[257] = {
     65535,
 };
 
+/* Used in CID 1238, 1243 */
 static const uint8_t dnxhd_1238_ac_bits[257] = {
      2,  2,  3,  4,  4,  5,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7,
      8,  8,  8,  8,  8,  8,  9,  9,  9,  9,  9,  9,  9,  9, 10, 10,
@@ -466,6 +450,7 @@ static const uint8_t dnxhd_1238_ac_bits[257] = {
     16,
 };
 
+/* Used in CID 1238, 1243 */
 static const uint8_t dnxhd_1238_ac_level[257] = {
      1,  1,  2,  3,  0,  4,  5,  2,  6,  7,  8,  3,  9, 10, 11,  4,
     12, 13, 14, 15, 16,  5, 17, 18, 19, 20, 21, 22,  6,  7, 23, 24,
@@ -486,6 +471,7 @@ static const uint8_t dnxhd_1238_ac_level[257] = {
     64,
 }; /* 0 is EOB */
 
+/* Used in CID 1238, 1243 */
 static const uint8_t dnxhd_1238_ac_run_flag[257] = {
     0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1,
     0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0,
@@ -506,6 +492,7 @@ static const uint8_t dnxhd_1238_ac_run_flag[257] = {
     1,
 };
 
+/* Used in CID 1238, 1243 */
 static const uint8_t dnxhd_1238_ac_index_flag[257] = {
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -526,40 +513,8 @@ static const uint8_t dnxhd_1238_ac_index_flag[257] = {
     1,
 };
 
-static const uint16_t dnxhd_1235_1238_1241_run_codes[62] = {
-       0,    4,   10,   11,   24,   25,   26,   27,
-      56,   57,   58,   59,  120,  242,  486,  487,
-     488,  489,  980,  981,  982,  983,  984,  985,
-     986,  987,  988,  989,  990,  991,  992,  993,
-     994,  995,  996,  997,  998,  999, 1000, 1001,
-    1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009,
-    1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017,
-    1018, 1019, 1020, 1021, 1022, 1023,
-};
-
-static const uint8_t dnxhd_1235_1238_1241_run_bits[62] = {
-     1,  3,  4,  4,  5,  5,  5,  5,  6,  6,  6,  6,  7,  8,  9,  9,
-     9,  9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
-    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
-    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
-};
-
-static const uint8_t dnxhd_1238_run[62] = {
-     1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
-    20, 21, 17, 18, 19, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
-    33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
-    49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
-};
-
-static const uint8_t dnxhd_1235_1241_dc_codes[14] = {
-    10, 62, 11, 12, 13, 0, 1, 2, 3, 4, 14, 30, 126, 127,
-};
-
-static const uint8_t dnxhd_1235_1241_dc_bits[14] = {
-    4, 6, 4, 4, 4, 3, 3, 3, 3, 3, 4, 5, 7, 7,
-};
-
-static const uint16_t dnxhd_1235_1241_ac_codes[257] = {
+/* Used in CID 1235, 1241, 1256 */
+static const uint16_t dnxhd_1235_ac_codes[257] = {
         0,     1,     4,    10,    11,    24,    25,    26,
        54,    55,    56,    57,   116,   117,   118,   119,
       240,   241,   242,   243,   244,   245,   492,   493,
@@ -595,7 +550,8 @@ static const uint16_t dnxhd_1235_1241_ac_codes[257] = {
     65535,
 };
 
-static const uint8_t dnxhd_1235_1241_ac_bits[257] = {
+/* Used in CID 1235, 1241, 1256 */
+static const uint8_t dnxhd_1235_ac_bits[257] = {
      2,  2,  3,  4,  4,  5,  5,  5,  6,  6,  6,  6,  7,  7,  7,  7,
      8,  8,  8,  8,  8,  8,  9,  9,  9,  9,  9,  9,  9, 10, 10, 10,
     10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11,
@@ -615,7 +571,8 @@ static const uint8_t dnxhd_1235_1241_ac_bits[257] = {
     16,
 };
 
-static const uint8_t dnxhd_1235_1241_ac_level[257] = {
+/* Used in CID 1235, 1241, 1256 */
+static const uint8_t dnxhd_1235_ac_level[257] = {
      1,  1,  2,  3,  0,  4,  5,  2,  6,  7,  8,  3,  9, 10, 11,  4,
     12, 13, 14, 15, 16,  5, 17, 18, 19, 20, 21,  6,  7, 22, 23, 24,
     25, 26, 27, 28, 29,  8,  9, 30, 31, 32, 33, 34, 35, 36, 37, 38,
@@ -635,7 +592,8 @@ static const uint8_t dnxhd_1235_1241_ac_level[257] = {
     64,
 };
 
-static const uint8_t dnxhd_1235_1241_ac_run_flag[257] = {
+/* Used in CID 1235, 1241, 1256 */
+static const uint8_t dnxhd_1235_ac_run_flag[257] = {
     0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1,
     0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0,
     0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -655,7 +613,8 @@ static const uint8_t dnxhd_1235_1241_ac_run_flag[257] = {
     1,
 };
 
-static const uint8_t dnxhd_1235_1241_ac_index_flag[257] = {
+/* Used in CID 1235, 1241, 1256 */
+static const uint8_t dnxhd_1235_ac_index_flag[257] = {
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -675,19 +634,6 @@ static const uint8_t dnxhd_1235_1241_ac_index_flag[257] = {
     1,
 };
 
-static const uint8_t dnxhd_1235_1241_run[62] = {
-     1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
-    18, 20, 17, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
-    33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
-    49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
-};
-
-static const uint8_t dnxhd_1250_dc_codes[14] = {
-    10, 62, 11, 12, 13, 0, 1, 2, 3, 4, 14, 30, 126, 127
-};
-static const uint8_t dnxhd_1250_dc_bits[14] = {
-    4, 6, 4, 4, 4, 3, 3, 3, 3, 3, 4, 5, 7, 7
-};
 static const uint16_t dnxhd_1250_ac_codes[257] = {
         0,     1,     4,    10,    11,    24,    25,    26,
        54,    55,    56,    57,   116,   117,   118,   119,
@@ -799,36 +745,6 @@ static const uint8_t dnxhd_1250_ac_index_flag[257] = {
     1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
     1
 };
-static const uint16_t dnxhd_1250_run_codes[62] = {
-       0,    4,    5,   12,   26,   27,   28,   58,
-     118,  119,  120,  242,  486,  487,  976,  977,
-     978,  979,  980,  981,  982,  983,  984,  985,
-     986,  987,  988,  989,  990,  991,  992,  993,
-     994,  995,  996,  997,  998,  999, 1000, 1001,
-    1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009,
-    1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017,
-    1018, 1019, 1020, 1021, 1022, 1023
-};
-static const uint8_t dnxhd_1250_run_bits[62] = {
-     1,  3,  3,  4,  5,  5,  5,  6,  7,  7,  7,  8,  9,  9, 10, 10,
-    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
-    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
-    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
-};
-static const uint8_t dnxhd_1250_run[62] = {
-     1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
-    17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
-    33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
-    49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62
-};
-
-static const uint8_t dnxhd_1251_dc_codes[12] = {
-    0, 12, 13, 1, 2, 3, 4, 5, 14, 30, 62, 63,
-};
-
-static const uint8_t dnxhd_1251_dc_bits[12] = {
-    3, 4, 4, 3, 3, 3, 3, 3, 4, 5, 6, 6,
-};
 
 static const uint16_t dnxhd_1251_ac_codes[257] = {
         0,     1,     4,    10,    11,    24,    25,    26,
@@ -946,39 +862,7 @@ static const uint8_t dnxhd_1251_ac_index_flag[257] = {
     1,
 };
 
-static const uint16_t dnxhd_1251_run_codes[62] = {
-       0,    4,    5,   12,   26,   27,   28,   58,
-     118,  119,  120,  242,  486,  487,  976,  977,
-     978,  979,  980,  981,  982,  983,  984,  985,
-     986,  987,  988,  989,  990,  991,  992,  993,
-     994,  995,  996,  997,  998,  999, 1000, 1001,
-    1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009,
-    1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017,
-    1018, 1019, 1020, 1021, 1022, 1023,
-};
-
-static const uint8_t dnxhd_1251_run_bits[62] = {
-     1,  3,  3,  4,  5,  5,  5,  6,  7,  7,  7,  8,  9,  9, 10, 10,
-    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
-    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
-    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
-};
-
-static const uint8_t dnxhd_1251_run[62] = {
-     1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
-    17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
-    33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
-    49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
-};
-
-static const uint8_t dnxhd_1252_dc_codes[12] = {
-    0, 12, 13, 1, 2, 3, 4, 5, 14, 30, 62, 63,
-};
-
-static const uint8_t dnxhd_1252_dc_bits[12] = {
-    3, 4, 4, 3, 3, 3, 3, 3, 4, 5, 6, 6,
-};
-
+/* Used in CID 1252, 1258 */
 static const uint16_t dnxhd_1252_ac_codes[257] = {
         0,     1,     4,    10,    11,    12,    26,    27,
        56,    57,    58,   118,   119,   120,   242,   243,
@@ -1015,6 +899,7 @@ static const uint16_t dnxhd_1252_ac_codes[257] = {
     65535,
 };
 
+/* Used in CID 1252, 1258 */
 static const uint8_t dnxhd_1252_ac_bits[257] = {
      2,  2,  3,  4,  4,  4,  5,  5,  6,  6,  6,  7,  7,  7,  8,  8,
      8,  8,  8,  8,  9,  9,  9,  9,  9, 10, 10, 10, 10, 10, 10, 10,
@@ -1035,6 +920,7 @@ static const uint8_t dnxhd_1252_ac_bits[257] = {
     16,
 };
 
+/* Used in CID 1252, 1258 */
 static const uint8_t dnxhd_1252_ac_level[257] = {
      1,  1,  2,  3,  2,  0,  4,  5,  6,  7,  3,  8,  9, 10, 11, 12,
     13, 14,  4,  5, 15, 16, 17, 18,  6, 19, 20, 21, 22, 23, 24,  7,
@@ -1055,6 +941,7 @@ static const uint8_t dnxhd_1252_ac_level[257] = {
     64,
 };
 
+/* Used in CID 1252, 1258 */
 static const uint8_t dnxhd_1252_ac_run_flag[257] = {
     0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
     0, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1,
@@ -1075,6 +962,7 @@ static const uint8_t dnxhd_1252_ac_run_flag[257] = {
     1,
 };
 
+/* Used in CID 1252, 1258 */
 static const uint8_t dnxhd_1252_ac_index_flag[257] = {
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -1095,21 +983,104 @@ static const uint8_t dnxhd_1252_ac_index_flag[257] = {
     1,
 };
 
-static const uint8_t dnxhd_1258_dc_codes[14] = {
-    0, 12, 13, 1, 2, 3, 4, 5, 14, 30, 62, 63, 0, 0,
+/* Used in CID 1235, 1238, 1241, 1256 */
+static const uint16_t dnxhd_1235_run_codes[62] = {
+       0,    4,   10,   11,   24,   25,   26,   27,
+      56,   57,   58,   59,  120,  242,  486,  487,
+     488,  489,  980,  981,  982,  983,  984,  985,
+     986,  987,  988,  989,  990,  991,  992,  993,
+     994,  995,  996,  997,  998,  999, 1000, 1001,
+    1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009,
+    1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017,
+    1018, 1019, 1020, 1021, 1022, 1023,
+};
+
+/* Used in CID 1235, 1238, 1241, 1243, 1256 */
+static const uint8_t dnxhd_1235_run_bits[62] = {
+     1,  3,  4,  4,  5,  5,  5,  5,  6,  6,  6,  6,  7,  8,  9,  9,
+     9,  9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+};
+
+/* Used in CID 1235, 1241, 1256 */
+static const uint8_t dnxhd_1235_run[62] = {
+     1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
+    18, 20, 17, 19, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
+    33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
+    49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
+};
+
+/* Used in CID 1237, 1242, 1253, 1259, 1260 */
+static const uint16_t dnxhd_1237_run_codes[62] = {
+       0,    4,   10,   11,   24,   25,   26,   54,
+      55,   56,   57,   58,  118,  119,  240,  482,
+     483,  484,  485,  486,  487,  488,  489,  490,
+     491,  492,  493,  494,  990,  991,  992,  993,
+     994,  995,  996,  997,  998,  999, 1000, 1001,
+    1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009,
+    1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017,
+    1018, 1019, 1020, 1021, 1022, 1023,
+};
+
+/* Used in CID 1237, 1242, 1253, 1259, 1260 */
+static const uint8_t dnxhd_1237_run_bits[62] = {
+     1,  3,  4,  4,  5,  5,  5,  6,  6,  6,  6,  6,  7,  7,  8,  9,
+     9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9, 10, 10, 10, 10,
+    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+};
+
+/* Used in CID 1237, 1242, 1253, 1259, 1260 */
+static const uint8_t dnxhd_1237_run[62] = {
+     1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
+    17, 18, 19, 20, 21, 53, 57, 58, 59, 60, 61, 62, 22, 23, 24, 25,
+    26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
+    42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 54, 55, 56,
+};
+
+static const uint8_t dnxhd_1238_run[62] = {
+     1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
+    20, 21, 17, 18, 19, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
+    33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
+    49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
+};
+
+/* Used in CID 1250, 1251, 1252, 1258 */
+static const uint16_t dnxhd_1250_run_codes[62] = {
+       0,    4,    5,   12,   26,   27,   28,   58,
+     118,  119,  120,  242,  486,  487,  976,  977,
+     978,  979,  980,  981,  982,  983,  984,  985,
+     986,  987,  988,  989,  990,  991,  992,  993,
+     994,  995,  996,  997,  998,  999, 1000, 1001,
+    1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009,
+    1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017,
+    1018, 1019, 1020, 1021, 1022, 1023,
 };
 
-static const uint8_t dnxhd_1258_dc_bits[14] = {
-    3, 4, 4, 3, 3, 3, 3, 3, 4, 5, 6, 6, 0, 0,
+/* Used in CID 1250, 1251, 1252, 1258 */
+static const uint8_t dnxhd_1250_run_bits[62] = {
+     1,  3,  3,  4,  5,  5,  5,  6,  7,  7,  7,  8,  9,  9, 10, 10,
+    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+    10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+};
+
+/* Used in CID 1250, 1251, 1252, 1258 */
+static const uint8_t dnxhd_1250_run[62] = {
+     1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
+    17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
+    33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
+    49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62,
 };
 
 const CIDEntry ff_dnxhd_cid_table[] = {
     { 1235, 1920, 1080, 0, 917504, 917504, 6, 10,
       dnxhd_1235_luma_weight, dnxhd_1235_chroma_weight,
-      dnxhd_1235_1241_dc_codes, dnxhd_1235_1241_dc_bits,
-      dnxhd_1235_1241_ac_codes, dnxhd_1235_1241_ac_bits, dnxhd_1235_1241_ac_level,
-      dnxhd_1235_1241_ac_run_flag, dnxhd_1235_1241_ac_index_flag,
-      dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1235_1241_run,
+      dnxhd_1235_dc_codes, dnxhd_1235_dc_bits,
+      dnxhd_1235_ac_codes, dnxhd_1235_ac_bits, dnxhd_1235_ac_level,
+      dnxhd_1235_ac_run_flag, dnxhd_1235_ac_index_flag,
+      dnxhd_1235_run_codes, dnxhd_1235_run_bits, dnxhd_1235_run,
       { 175, 185, 365, 440 } },
     { 1237, 1920, 1080, 0, 606208, 606208, 4, 8,
       dnxhd_1237_luma_weight, dnxhd_1237_chroma_weight,
@@ -1120,17 +1091,17 @@ const CIDEntry ff_dnxhd_cid_table[] = {
       { 115, 120, 145, 240, 290 } },
     { 1238, 1920, 1080, 0, 917504, 917504, 4, 8,
       dnxhd_1238_luma_weight, dnxhd_1238_chroma_weight,
-      dnxhd_1238_dc_codes, dnxhd_1238_dc_bits,
+      dnxhd_1237_dc_codes, dnxhd_1237_dc_bits,
       dnxhd_1238_ac_codes, dnxhd_1238_ac_bits, dnxhd_1238_ac_level,
       dnxhd_1238_ac_run_flag, dnxhd_1238_ac_index_flag,
-      dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1238_run,
+      dnxhd_1235_run_codes, dnxhd_1235_run_bits, dnxhd_1238_run,
       { 175, 185, 220, 365, 440 } },
     { 1241, 1920, 1080, 1, 917504, 458752, 6, 10,
       dnxhd_1241_luma_weight, dnxhd_1241_chroma_weight,
-      dnxhd_1235_1241_dc_codes, dnxhd_1235_1241_dc_bits,
-      dnxhd_1235_1241_ac_codes, dnxhd_1235_1241_ac_bits, dnxhd_1235_1241_ac_level,
-      dnxhd_1235_1241_ac_run_flag, dnxhd_1235_1241_ac_index_flag,
-      dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1235_1241_run,
+      dnxhd_1235_dc_codes, dnxhd_1235_dc_bits,
+      dnxhd_1235_ac_codes, dnxhd_1235_ac_bits, dnxhd_1235_ac_level,
+      dnxhd_1235_ac_run_flag, dnxhd_1235_ac_index_flag,
+      dnxhd_1235_run_codes, dnxhd_1235_run_bits, dnxhd_1235_run,
       { 185, 220 } },
     { 1242, 1920, 1080, 1, 606208, 303104, 4, 8,
       dnxhd_1242_luma_weight, dnxhd_1242_chroma_weight,
@@ -1141,31 +1112,31 @@ const CIDEntry ff_dnxhd_cid_table[] = {
       { 120, 145 } },
     { 1243, 1920, 1080, 1, 917504, 458752, 4, 8,
       dnxhd_1243_luma_weight, dnxhd_1243_chroma_weight,
-      dnxhd_1238_dc_codes, dnxhd_1238_dc_bits,
+      dnxhd_1237_dc_codes, dnxhd_1237_dc_bits,
       dnxhd_1238_ac_codes, dnxhd_1238_ac_bits, dnxhd_1238_ac_level,
       dnxhd_1238_ac_run_flag, dnxhd_1238_ac_index_flag,
-      dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1238_run,
+      dnxhd_1235_run_codes, dnxhd_1235_run_bits, dnxhd_1238_run,
       { 185, 220 } },
     { 1250, 1280,  720, 0, 458752, 458752, 6, 10,
       dnxhd_1250_luma_weight, dnxhd_1250_chroma_weight,
-      dnxhd_1250_dc_codes, dnxhd_1250_dc_bits,
+      dnxhd_1235_dc_codes, dnxhd_1235_dc_bits,
       dnxhd_1250_ac_codes, dnxhd_1250_ac_bits, dnxhd_1250_ac_level,
       dnxhd_1250_ac_run_flag, dnxhd_1250_ac_index_flag,
       dnxhd_1250_run_codes, dnxhd_1250_run_bits, dnxhd_1250_run,
       { 90, 180, 220 } },
     { 1251, 1280,  720, 0, 458752, 458752, 4, 8,
       dnxhd_1251_luma_weight, dnxhd_1251_chroma_weight,
-      dnxhd_1251_dc_codes, dnxhd_1251_dc_bits,
+      dnxhd_1237_dc_codes, dnxhd_1237_dc_bits,
       dnxhd_1251_ac_codes, dnxhd_1251_ac_bits, dnxhd_1251_ac_level,
       dnxhd_1251_ac_run_flag, dnxhd_1251_ac_index_flag,
-      dnxhd_1251_run_codes, dnxhd_1251_run_bits, dnxhd_1251_run,
+      dnxhd_1250_run_codes, dnxhd_1250_run_bits, dnxhd_1250_run,
       { 90, 110, 175, 220 } },
     { 1252, 1280,  720, 0, 303104, 303104, 4, 8,
       dnxhd_1252_luma_weight, dnxhd_1252_chroma_weight,
-      dnxhd_1252_dc_codes, dnxhd_1252_dc_bits,
+      dnxhd_1237_dc_codes, dnxhd_1237_dc_bits,
       dnxhd_1252_ac_codes, dnxhd_1252_ac_bits, dnxhd_1252_ac_level,
       dnxhd_1252_ac_run_flag, dnxhd_1252_ac_index_flag,
-      dnxhd_1251_run_codes, dnxhd_1251_run_bits, dnxhd_1251_run,
+      dnxhd_1250_run_codes, dnxhd_1250_run_bits, dnxhd_1250_run,
       { 60, 75, 115, 145 } },
     { 1253, 1920, 1080, 0, 188416, 188416, 4, 8,
       dnxhd_1237_luma_weight, dnxhd_1237_chroma_weight,
@@ -1175,19 +1146,33 @@ const CIDEntry ff_dnxhd_cid_table[] = {
       dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run,
       { 36, 45, 75, 90 } },
     { 1256, 1920, 1080, 0, 1835008, 1835008, 6, 10,
-      dnxhd_1235_luma_weight, dnxhd_1256_chroma_weight,
-      dnxhd_1235_1241_dc_codes, dnxhd_1235_1241_dc_bits,
-      dnxhd_1235_1241_ac_codes, dnxhd_1235_1241_ac_bits, dnxhd_1235_1241_ac_level,
-      dnxhd_1235_1241_ac_run_flag, dnxhd_1235_1241_ac_index_flag,
-      dnxhd_1235_1238_1241_run_codes, dnxhd_1235_1238_1241_run_bits, dnxhd_1235_1241_run,
+      dnxhd_1235_luma_weight, dnxhd_1235_chroma_weight,
+      dnxhd_1235_dc_codes, dnxhd_1235_dc_bits,
+      dnxhd_1235_ac_codes, dnxhd_1235_ac_bits, dnxhd_1235_ac_level,
+      dnxhd_1235_ac_run_flag, dnxhd_1235_ac_index_flag,
+      dnxhd_1235_run_codes, dnxhd_1235_run_bits, dnxhd_1235_run,
       { 350, 390, 440, 730, 880 } },
     { 1258, 960, 720, 0, 212992, 212992, 4, 8,
-      dnxhd_1258_luma_weight, dnxhd_1258_chroma_weight,
-      dnxhd_1258_dc_codes, dnxhd_1258_dc_bits,
+      dnxhd_1252_luma_weight, dnxhd_1252_chroma_weight,
+      dnxhd_1237_dc_codes, dnxhd_1237_dc_bits,
       dnxhd_1252_ac_codes, dnxhd_1252_ac_bits, dnxhd_1252_ac_level,
       dnxhd_1252_ac_run_flag, dnxhd_1252_ac_index_flag,
-      dnxhd_1251_run_codes, dnxhd_1251_run_bits, dnxhd_1251_run,
+      dnxhd_1250_run_codes, dnxhd_1250_run_bits, dnxhd_1250_run,
       { 42, 60, 75, 115 } },
+    { 1259, 1440, 1080, 0, 417792, 417792, 4, 8,
+      dnxhd_1237_luma_weight, dnxhd_1237_chroma_weight,
+      dnxhd_1237_dc_codes, dnxhd_1237_dc_bits,
+      dnxhd_1237_ac_codes, dnxhd_1237_ac_bits, dnxhd_1237_ac_level,
+      dnxhd_1237_ac_run_flag, dnxhd_1237_ac_index_flag,
+      dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run,
+      { 63, 84, 100, 110 } },
+    { 1260, 1440, 1080, 1, 835584, 417792, 4, 8,
+      dnxhd_1260_luma_weight, dnxhd_1260_chroma_weight,
+      dnxhd_1237_dc_codes, dnxhd_1237_dc_bits,
+      dnxhd_1237_ac_codes, dnxhd_1237_ac_bits, dnxhd_1237_ac_level,
+      dnxhd_1237_ac_run_flag, dnxhd_1237_ac_index_flag,
+      dnxhd_1237_run_codes, dnxhd_1237_run_bits, dnxhd_1237_run,
+      { 80, 90, 100, 110 } },
 };
 
 int ff_dnxhd_get_cid_table(int cid)
@@ -1218,3 +1203,26 @@ int ff_dnxhd_find_cid(AVCodecContext *avctx, int bit_depth)
     }
     return 0;
 }
+
+void ff_dnxhd_list_cid(AVCodecContext *avctx)
+{
+    int i, j;
+
+    for (i = 0; i < FF_ARRAY_ELEMS(ff_dnxhd_cid_table); i++) {
+        const CIDEntry *cid = &ff_dnxhd_cid_table[i];
+        av_log(avctx, AV_LOG_INFO,
+               "cid %d %ux%u %dbits %s bit rates",
+               cid->cid,
+               cid->width, cid->height,
+               cid->bit_depth,
+               cid->interlaced ? "interlaced " :
+                                 "progressive");
+        for (j = 0; j < FF_ARRAY_ELEMS(cid->bit_rates); j++) {
+            if (!cid->bit_rates[j])
+                break;
+            av_log(avctx, AV_LOG_INFO, " %dM",
+                   cid->bit_rates[j]);
+        }
+        av_log(avctx, AV_LOG_INFO, "\n");
+    }
+}