lavc/h265_profile_level: Fix DPB size calculation

The maxDpbPicBuf value which is used in the DPB size calculation depends
on the profile (it's usually 6, but 7 for screen-extended profiles).
This commit is contained in:
Mark Thompson 2019-05-06 22:02:19 +01:00
parent ca576833e4
commit c1a430885d
2 changed files with 44 additions and 43 deletions

View File

@ -43,76 +43,76 @@ static const H265ProfileDescriptor h265_profiles[] = {
// profile_idc 8bit one-picture // profile_idc 8bit one-picture
// HT-profile | 422chroma | lower-bit-rate // HT-profile | 422chroma | lower-bit-rate
// | 14bit | | 420chroma | | CpbVclFactor MinCrScaleFactor // | 14bit | | 420chroma | | CpbVclFactor MinCrScaleFactor
// | | 12bit | | | monochrome| | CpbNalFactor | // | | 12bit | | | monochrome| | CpbNalFactor | maxDpbPicBuf
// | | | 10bit | | | intra | | | FormatCapabilityFactor // | | | 10bit | | | intra | | | FormatCapabilityFactor
{ "Monochrome", // | | | | | | | | | | { "Monochrome", // | | | | | | | | | | |
4, 0, 2, 1, 1, 1, 1, 1, 1, 0, 0, 1, 667, 733, 1.000, 1.0 }, 4, 0, 2, 1, 1, 1, 1, 1, 1, 0, 0, 1, 667, 733, 1.000, 1.0, 6 },
{ "Monochrome 12", { "Monochrome 12",
4, 0, 2, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1000, 1100, 1.500, 1.0 }, 4, 0, 2, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1000, 1100, 1.500, 1.0, 6 },
{ "Monochrome 16", { "Monochrome 16",
4, 0, 2, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1333, 1467, 2.000, 1.0 }, 4, 0, 2, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1333, 1467, 2.000, 1.0, 6 },
{ "Main", { "Main",
1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1000, 1100, 1.500, 1.0 }, 1, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1000, 1100, 1.500, 1.0, 6 },
{ "Screen-Extended Main", { "Screen-Extended Main",
9, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1000, 1100, 1.500, 1.0 }, 9, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1000, 1100, 1.500, 1.0, 7 },
{ "Main 10", { "Main 10",
2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1000, 1100, 1.875, 1.0 }, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1000, 1100, 1.875, 1.0, 6 },
{ "Screen-Extended Main 10", { "Screen-Extended Main 10",
9, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1000, 1100, 1.875, 1.0 }, 9, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1000, 1100, 1.875, 1.0, 7 },
{ "Main 12", { "Main 12",
4, 0, 2, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1500, 1650, 2.250, 1.0 }, 4, 0, 2, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1500, 1650, 2.250, 1.0, 6 },
{ "Main Still Picture", { "Main Still Picture",
3, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1000, 1100, 1.500, 1.0 }, 3, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1000, 1100, 1.500, 1.0, 6 },
{ "Main 4:2:2 10", { "Main 4:2:2 10",
4, 0, 2, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1667, 1833, 2.500, 0.5 }, 4, 0, 2, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1667, 1833, 2.500, 0.5, 6 },
{ "Main 4:2:2 12", { "Main 4:2:2 12",
4, 0, 2, 1, 0, 0, 1, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5 }, 4, 0, 2, 1, 0, 0, 1, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5, 6 },
{ "Main 4:4:4", { "Main 4:4:4",
4, 0, 2, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5 }, 4, 0, 2, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5, 6 },
{ "High Throughput 4:4:4", { "High Throughput 4:4:4",
5, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5 }, 5, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5, 6 },
{ "Screen-Extended Main 4:4:4", { "Screen-Extended Main 4:4:4",
9, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5 }, 9, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5, 7 },
{ "Screen-Extended High Throughput 4:4:4", { "Screen-Extended High Throughput 4:4:4",
9, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5 }, 9, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 2000, 2200, 3.000, 0.5, 7 },
{ "Main 4:4:4 10", { "Main 4:4:4 10",
4, 0, 2, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2500, 2750, 3.750, 0.5 }, 4, 0, 2, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2500, 2750, 3.750, 0.5, 6 },
{ "High Throughput 4:4:4 10", { "High Throughput 4:4:4 10",
5, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2500, 2750, 3.750, 0.5 }, 5, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2500, 2750, 3.750, 0.5, 6 },
{ "Screen-Extended Main 4:4:4 10", { "Screen-Extended Main 4:4:4 10",
9, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2500, 2750, 3.750, 0.5 }, 9, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2500, 2750, 3.750, 0.5, 7 },
{ "Screen-Extended High Throughput 4:4:4 10", { "Screen-Extended High Throughput 4:4:4 10",
9, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2500, 2750, 3.750, 0.5 }, 9, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2500, 2750, 3.750, 0.5, 7 },
{ "Main 4:4:4 12", { "Main 4:4:4 12",
4, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 1, 3000, 3300, 4.500, 0.5 }, 4, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 1, 3000, 3300, 4.500, 0.5, 6 },
{ "High Throughput 4:4:4 14", { "High Throughput 4:4:4 14",
5, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3500, 3850, 5.250, 0.5 }, 5, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3500, 3850, 5.250, 0.5, 6 },
{ "Screen-Extended High Throughput 4:4:4 14", { "Screen-Extended High Throughput 4:4:4 14",
9, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3500, 3850, 5.250, 0.5 }, 9, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3500, 3850, 5.250, 0.5, 7 },
{ "Main Intra", { "Main Intra",
4, 0, 2, 1, 1, 1, 1, 1, 0, 1, 0, 2, 1000, 1100, 1.500, 1.0 }, 4, 0, 2, 1, 1, 1, 1, 1, 0, 1, 0, 2, 1000, 1100, 1.500, 1.0, 6 },
{ "Main 10 Intra", { "Main 10 Intra",
4, 0, 2, 1, 1, 0, 1, 1, 0, 1, 0, 2, 1000, 1100, 1.875, 1.0 }, 4, 0, 2, 1, 1, 0, 1, 1, 0, 1, 0, 2, 1000, 1100, 1.875, 1.0, 6 },
{ "Main 12 Intra", { "Main 12 Intra",
4, 0, 2, 1, 0, 0, 1, 1, 0, 1, 0, 2, 1500, 1650, 2.250, 1.0 }, 4, 0, 2, 1, 0, 0, 1, 1, 0, 1, 0, 2, 1500, 1650, 2.250, 1.0, 6 },
{ "Main 4:2:2 10 Intra", { "Main 4:2:2 10 Intra",
4, 0, 2, 1, 1, 0, 1, 0, 0, 1, 0, 2, 1667, 1833, 2.500, 0.5 }, 4, 0, 2, 1, 1, 0, 1, 0, 0, 1, 0, 2, 1667, 1833, 2.500, 0.5, 6 },
{ "Main 4:2:2 12 Intra", { "Main 4:2:2 12 Intra",
4, 0, 2, 1, 0, 0, 1, 0, 0, 1, 0, 2, 2000, 2200, 3.000, 0.5 }, 4, 0, 2, 1, 0, 0, 1, 0, 0, 1, 0, 2, 2000, 2200, 3.000, 0.5, 6 },
{ "Main 4:4:4 Intra", { "Main 4:4:4 Intra",
4, 0, 2, 1, 1, 1, 0, 0, 0, 1, 0, 2, 2000, 2200, 3.000, 0.5 }, 4, 0, 2, 1, 1, 1, 0, 0, 0, 1, 0, 2, 2000, 2200, 3.000, 0.5, 6 },
{ "Main 4:4:4 10 Intra", { "Main 4:4:4 10 Intra",
4, 0, 2, 1, 1, 0, 0, 0, 0, 1, 0, 2, 2500, 2750, 3.750, 0.5 }, 4, 0, 2, 1, 1, 0, 0, 0, 0, 1, 0, 2, 2500, 2750, 3.750, 0.5, 6 },
{ "Main 4:4:4 12 Intra", { "Main 4:4:4 12 Intra",
4, 0, 2, 1, 0, 0, 0, 0, 0, 1, 0, 2, 3000, 3300, 4.500, 0.5 }, 4, 0, 2, 1, 0, 0, 0, 0, 0, 1, 0, 2, 3000, 3300, 4.500, 0.5, 6 },
{ "Main 4:4:4 16 Intra", { "Main 4:4:4 16 Intra",
4, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 2, 4000, 4400, 6.000, 0.5 }, 4, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 2, 4000, 4400, 6.000, 0.5, 6 },
{ "Main 4:4:4 Still Picture", { "Main 4:4:4 Still Picture",
4, 0, 2, 1, 1, 1, 0, 0, 0, 1, 1, 2, 2000, 2200, 3.000, 0.5 }, 4, 0, 2, 1, 1, 1, 0, 0, 0, 1, 1, 2, 2000, 2200, 3.000, 0.5, 6 },
{ "Main 4:4:4 16 Still Picture", { "Main 4:4:4 16 Still Picture",
4, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 2, 4000, 4400, 6.000, 0.5 }, 4, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 2, 4000, 4400, 6.000, 0.5, 6 },
{ "High Throughput 4:4:4 16 Intra", { "High Throughput 4:4:4 16 Intra",
5, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 4000, 4400, 6.000, 0.5 }, 5, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 4000, 4400, 6.000, 0.5, 6 },
}; };
@ -231,14 +231,14 @@ const H265LevelDescriptor *ff_h265_guess_level(const H265RawProfileTierLevel *pt
if (bitrate > (int64_t)profile->cpb_nal_factor * hbr_factor * max_br) if (bitrate > (int64_t)profile->cpb_nal_factor * hbr_factor * max_br)
continue; continue;
if (pic_size < (level->max_luma_ps >> 2)) if (pic_size <= (level->max_luma_ps >> 2))
max_dpb_size = 16; max_dpb_size = FFMIN(4 * profile->max_dpb_pic_buf, 16);
else if (pic_size < (level->max_luma_ps >> 1)) else if (pic_size <= (level->max_luma_ps >> 1))
max_dpb_size = 14; max_dpb_size = FFMIN(2 * profile->max_dpb_pic_buf, 16);
else if (pic_size < (3 * level->max_luma_ps >> 2)) else if (pic_size <= (3 * level->max_luma_ps >> 2))
max_dpb_size = 9; max_dpb_size = FFMIN(4 * profile->max_dpb_pic_buf / 3, 16);
else else
max_dpb_size = 7; max_dpb_size = profile->max_dpb_pic_buf;
if (max_dec_pic_buffering > max_dpb_size) if (max_dec_pic_buffering > max_dpb_size)
continue; continue;

View File

@ -66,6 +66,7 @@ typedef struct H265ProfileDescriptor {
uint16_t cpb_nal_factor; uint16_t cpb_nal_factor;
float format_capability_factor; float format_capability_factor;
float min_cr_scale_factor; float min_cr_scale_factor;
uint8_t max_dpb_pic_buf;
} H265ProfileDescriptor; } H265ProfileDescriptor;