mirror of
https://github.com/kkroening/ffmpeg-python.git
synced 2025-08-07 18:39:47 +08:00
Detect: Add NVidia decoders data
This commit is contained in:
parent
8982e9fff2
commit
9f00ffd995
@ -38,7 +38,11 @@ API_TO_HWACCEL = {
|
||||
NVIDIA_GPU_MATRIX_URL = (
|
||||
'https://developer.nvidia.com/video-encode-decode-gpu-support-matrix')
|
||||
NVIDIA_LINE_SUFFIXES = {'geforce': ['gtx titan', 'gtx', 'gt', 'rtx']}
|
||||
NVIDIA_CODEC_COLUMN_PREFIXES = {'h.264': 'h264', 'h.265': 'hevc'}
|
||||
NVIDIA_CODEC_COLUMN_PREFIXES = {
|
||||
'mpeg-1': 'mpeg1video', 'mpeg-2': 'mpeg2video',
|
||||
'vc-1': 'vc1',
|
||||
'vp8': 'vp8', 'vp9': 'vp9',
|
||||
'h.264': 'h264', 'h.265': 'hevc'}
|
||||
|
||||
|
||||
def get_hwaccel_data():
|
||||
@ -75,14 +79,18 @@ def get_nvidia_data():
|
||||
(
|
||||
nvenc_recent, nvenc_consumer, nvenc_workstation, nvenc_virt,
|
||||
nvdec_recent, nvdec_consumer, nvdec_workstation, nvdec_virt) = tables
|
||||
nvidia = collections.OrderedDict(
|
||||
lines=[], model_lines=collections.OrderedDict(),
|
||||
boards=collections.OrderedDict())
|
||||
nv_coders = dict(
|
||||
encoders=(
|
||||
nvenc_recent, nvenc_consumer, nvenc_workstation, nvenc_virt),
|
||||
decoders=(
|
||||
nvdec_recent, nvdec_consumer, nvdec_workstation, nvdec_virt))
|
||||
nvidia = collections.OrderedDict(lines=[])
|
||||
|
||||
# Compile aggregate data needed to parse individual rows
|
||||
for nvenc_table in (
|
||||
nvenc_recent, nvenc_consumer, nvenc_workstation, nvenc_virt):
|
||||
for board in nvenc_table['BOARD']:
|
||||
for nv_coder_table in tables:
|
||||
for board in nv_coder_table['BOARD']:
|
||||
if board == 'BOARD':
|
||||
continue
|
||||
line = board.replace('\xa0', ' ').split(None, 1)[0].lower()
|
||||
if line not in nvidia['lines']:
|
||||
nvidia['lines'].append(line)
|
||||
@ -90,62 +98,79 @@ def get_nvidia_data():
|
||||
for line_suffix in reversed(line_suffixes):
|
||||
nvidia['lines'].insert(0, ' '.join((line, line_suffix)))
|
||||
|
||||
for nvenc_table in (
|
||||
nvenc_recent, nvenc_consumer, nvenc_workstation, nvenc_virt):
|
||||
for nvenc_row_idx, nvenc_row in nvenc_table.iterrows():
|
||||
nvenc_row_values = {
|
||||
idx: cell for idx, cell in enumerate(nvenc_row[1:]) if (
|
||||
cell and
|
||||
not (isinstance(cell, float) and math.isnan(cell)))}
|
||||
if not nvenc_row_values:
|
||||
# Divider row
|
||||
continue
|
||||
for coder_type, nv_coder_tables in nv_coders.items():
|
||||
coder_data = nvidia[coder_type] = collections.OrderedDict(
|
||||
model_lines=collections.OrderedDict(),
|
||||
boards=collections.OrderedDict())
|
||||
for nv_coder_table in nv_coder_tables:
|
||||
for nv_coder_row_idx, nv_coder_row in nv_coder_table.iterrows():
|
||||
nv_coder_row_values = {
|
||||
idx: cell for idx, cell in enumerate(nv_coder_row[1:]) if (
|
||||
cell and
|
||||
not (isinstance(cell, float) and math.isnan(cell)))}
|
||||
if not nv_coder_row_values:
|
||||
# Divider row
|
||||
continue
|
||||
|
||||
# Assemble the data for this row to use for each model or range
|
||||
model_data = collections.OrderedDict()
|
||||
for key, value in nvenc_row.items():
|
||||
if value in {'YES', 'NO'}:
|
||||
model_data[key] = value == 'YES'
|
||||
else:
|
||||
model_data[key] = value
|
||||
model_data['BOARD'] = model_data['BOARD'].replace('\xa0', ' ')
|
||||
# Add keys for the data for the ffmpeg codec names for fast lookup
|
||||
for codec_prefix, codec in NVIDIA_CODEC_COLUMN_PREFIXES.items():
|
||||
for column_idx, column in enumerate(nvenc_row.keys()):
|
||||
if column.lower().startswith(codec_prefix):
|
||||
model_data[codec] = nvenc_row[column_idx] == 'YES'
|
||||
break
|
||||
nvidia['boards'][model_data['BOARD']] = model_data
|
||||
# Assemble the data for this row to use for each model or range
|
||||
model_data = collections.OrderedDict()
|
||||
for key, value in nv_coder_row.items():
|
||||
if isinstance(key, tuple):
|
||||
if key[0] == key[1]:
|
||||
key = key[0]
|
||||
else:
|
||||
key = ' '.join(key)
|
||||
if value in {'YES', 'NO'}:
|
||||
model_data[key] = value == 'YES'
|
||||
else:
|
||||
model_data[key] = value
|
||||
model_data['BOARD'] = model_data['BOARD'].replace('\xa0', ' ')
|
||||
# Add keys for the ffmpeg codec names for fast lookup
|
||||
for codec_prefix, codec in (
|
||||
NVIDIA_CODEC_COLUMN_PREFIXES.items()):
|
||||
for column_idx, column in enumerate(nv_coder_row.keys()):
|
||||
if isinstance(column, tuple):
|
||||
if column[0] == column[1]:
|
||||
column = column[0]
|
||||
else:
|
||||
column = ' '.join(column)
|
||||
if column.lower().startswith(codec_prefix):
|
||||
model_data[codec] = nv_coder_row[
|
||||
column_idx] == 'YES'
|
||||
break
|
||||
coder_data['boards'][model_data['BOARD']] = model_data
|
||||
|
||||
_detect._parse_models(
|
||||
model_lines=nvidia['lines'],
|
||||
boards=model_data['BOARD'].lower(),
|
||||
model_data=model_data['BOARD'],
|
||||
model_lines_data=nvidia['model_lines'])
|
||||
_detect._parse_models(
|
||||
model_lines=nvidia['lines'],
|
||||
boards=model_data['BOARD'].lower(),
|
||||
model_data=model_data['BOARD'],
|
||||
model_lines_data=coder_data['model_lines'])
|
||||
|
||||
# Clean up some annoying clashes between the titan model line and GeForce
|
||||
# GTX model numbers
|
||||
for model_line, model_line_suffixes in NVIDIA_LINE_SUFFIXES.items():
|
||||
models_data = nvidia['model_lines'][model_line]['models']
|
||||
for model_num in list(models_data):
|
||||
for model_line_suffix in model_line_suffixes:
|
||||
if model_num.startswith(model_line_suffix + ' '):
|
||||
models_data[model_num[
|
||||
len(model_line_suffix + ' '):]] = models_data.pop(
|
||||
model_num)
|
||||
for titan_model_num in {'black', 'xp'}:
|
||||
nvidia['model_lines']['geforce gtx']['models'][
|
||||
'titan ' + titan_model_num] = nvidia['model_lines'][
|
||||
'titan']['models'].pop(titan_model_num)
|
||||
for titan_model_num in list(nvidia['model_lines'][
|
||||
'geforce gtx titan']['models'].keys()):
|
||||
nvidia['model_lines']['geforce gtx']['models'][
|
||||
'titan ' + titan_model_num] = nvidia['model_lines'][
|
||||
'geforce gtx titan']['models'].pop(titan_model_num)
|
||||
nvidia['model_lines']['geforce gtx']['models']['titan'] = nvidia[
|
||||
'model_lines']['geforce gtx']['models']['titan black']
|
||||
del nvidia['model_lines']['geforce gtx']['models']['titan ']
|
||||
del nvidia['model_lines']['geforce gtx titan']
|
||||
# Cleanup any deviations from the convention where models from
|
||||
# multiple lines are in the same BOARD cell
|
||||
for model_line, model_line_data in coder_data['model_lines'].items():
|
||||
for line, line_suffixes in NVIDIA_LINE_SUFFIXES.items():
|
||||
if not model_line.startswith(line):
|
||||
continue
|
||||
for model_num, boards in list(
|
||||
model_line_data['models'].items()):
|
||||
for line_suffix in line_suffixes:
|
||||
if not model_num.startswith(line_suffix + ' '):
|
||||
continue
|
||||
coder_data['model_lines'][
|
||||
' '.join((line, line_suffix))]['models'][
|
||||
model_num[len(line_suffix + ' '):]
|
||||
] = model_line_data['models'].pop(model_num)
|
||||
# Clean up some annoying clashes between the titan model line and
|
||||
# GeForce GTX model numbers
|
||||
del coder_data['model_lines']['geforce gtx titan']['models']['']
|
||||
coder_data['model_lines']['geforce gtx titan']['models'][
|
||||
'xp'] = coder_data['model_lines']['titan']['models'].pop('xp')
|
||||
coder_data['model_lines']['geforce gtx titan']['models'][
|
||||
'black'] = titan_black = coder_data['model_lines'][
|
||||
'titan']['models'].pop('black')
|
||||
coder_data['model_lines']['geforce gtx']['models'][
|
||||
'titan'] = titan_black
|
||||
|
||||
return nvidia
|
||||
|
||||
|
7331
ffmpeg/detect.json
7331
ffmpeg/detect.json
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user