ffmpeg_hw: Don't ignore key parameters when initializing a hw device
Currently user may use '-init_hw_device type=name' to initialize a hw device, however the key parameter is ignored when use '-init_hw_device type=name,key=value'. After applying this patch, user may set key parameter if needed. Reviewed-by: Soft Works <softworkz@hotmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
7bba0dd638
commit
51a80aacce
|
@ -93,6 +93,8 @@ static char *hw_device_default_name(enum AVHWDeviceType type)
|
||||||
|
|
||||||
int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||||
{
|
{
|
||||||
|
// "type=name"
|
||||||
|
// "type=name,key=value,key2=value2"
|
||||||
// "type=name:device,key=value,key2=value2"
|
// "type=name:device,key=value,key2=value2"
|
||||||
// "type:device,key=value,key2=value2"
|
// "type:device,key=value,key2=value2"
|
||||||
// -> av_hwdevice_ctx_create()
|
// -> av_hwdevice_ctx_create()
|
||||||
|
@ -124,7 +126,7 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*p == '=') {
|
if (*p == '=') {
|
||||||
k = strcspn(p + 1, ":@");
|
k = strcspn(p + 1, ":@,");
|
||||||
|
|
||||||
name = av_strndup(p + 1, k);
|
name = av_strndup(p + 1, k);
|
||||||
if (!name) {
|
if (!name) {
|
||||||
|
@ -190,6 +192,18 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||||
src->device_ref, 0);
|
src->device_ref, 0);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
} else if (*p == ',') {
|
||||||
|
err = av_dict_parse_string(&options, p + 1, "=", ",", 0);
|
||||||
|
|
||||||
|
if (err < 0) {
|
||||||
|
errmsg = "failed to parse options";
|
||||||
|
goto invalid;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = av_hwdevice_ctx_create(&device_ref, type,
|
||||||
|
NULL, options, 0);
|
||||||
|
if (err < 0)
|
||||||
|
goto fail;
|
||||||
} else {
|
} else {
|
||||||
errmsg = "parse error";
|
errmsg = "parse error";
|
||||||
goto invalid;
|
goto invalid;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user