Re: [FFmpeg-devel] [PATCH] cmdutils: dont call read_header before listing devices
On Thu, Dec 18, 2014 at 05:11:29PM +0100, Lukasz Marek wrote: On 18 December 2014 at 10:41, Michael Niedermayer michae...@gmx.at wrote: On Thu, Dec 18, 2014 at 01:29:39AM +0100, Lukasz Marek wrote: On 18.12.2014 01:09, Michael Niedermayer wrote: On Wed, Dec 17, 2014 at 10:59:37PM +0100, Lukasz Marek wrote: On 15.12.2014 14:18, Michael Niedermayer wrote: cmdutils.c |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) 8d012a5193b0440717f89d920661913ef160e674 0001-cmdutils-dont-call-read_header-before-listing-device.patch From 332bb7456c498518ea72dfdaa0e8c3e76d383f21 Mon Sep 17 00:00:00 2001 From: Lukasz Marek lukasz.m.lu...@gmail.com Date: Mon, 15 Dec 2014 00:31:42 +0100 Subject: [PATCH] cmdutils: dont call read_header before listing devices List device callback must be able to return valid list without opening device. This callback should return input values for open function, not vice-versa. Read header funtion is very likey to fail without proper configuration provided. should be ok I changed a patch. I wanted to avoid situation where .read_close is called without .read_header being called before. cmdutils.c | 41 +++-- 1 file changed, 35 insertions(+), 6 deletions(-) 9a93c401d795bae3545a6c6112e71abd98ac22ca 0001-cmdutils-dont-call-read_header-before-listing-device.patch From 58fe020b8f1c0e809362e152febe3ad715b1c8fc Mon Sep 17 00:00:00 2001 From: Lukasz Marek lukasz.m.lu...@gmail.com Date: Mon, 15 Dec 2014 00:31:42 +0100 Subject: [PATCH] cmdutils: dont call read_header before listing devices List device callback must be able to return valid list without opening device. This callback should return input values for open function, not vice-versa. Read header funtion is very likey to fail without proper configuration provided. Signed-off-by: Lukasz Marek lukasz.m.lu...@gmail.com --- cmdutils.c | 41 +++-- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index 4e0a406..23a5f77 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -2052,7 +2052,37 @@ void *grow_array(void *array, int elem_size, int *size, int new_size) } #if CONFIG_AVDEVICE -static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts) +static int alloc_input_context(AVFormatContext **avctx, AVInputFormat *iformat) +{ +AVFormatContext *s = avformat_alloc_context(); +int ret = 0; + +*avctx = NULL; +if (!s) +return AVERROR(ENOMEM); + +s-iformat = iformat; +if (s-iformat-priv_data_size 0) { +s-priv_data = av_mallocz(s-iformat-priv_data_size); +if (!s-priv_data) { +ret = AVERROR(ENOMEM); +goto error; +} +if (s-iformat-priv_class) { +*(const AVClass**)s-priv_data= s-iformat-priv_class; +av_opt_set_defaults(s-priv_data); +} +} else +s-priv_data = NULL; + +*avctx = s; +return 0; + error: +avformat_free_context(s); +return ret; +} + +static int print_device_sources(void *pfmt, AVDictionary *opts) { int ret, i; AVFormatContext *dev = NULL; @@ -2069,13 +2099,12 @@ static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts) goto fail; } -/* TODO: avformat_open_input calls read_header callback which is not necessary. - Function like avformat_alloc_output_context2 for input could be helpful here. */ -av_dict_copy(tmp_opts, opts, 0); -if ((ret = avformat_open_input(dev, NULL, fmt, tmp_opts)) 0) { +if ((ret = alloc_input_context(dev, fmt)) 0) { this fails building due to lack of a fmt variable I failed at cherry-pick conflict, thanks. Updated patch is attached. cmdutils.c | 39 ++- 1 file changed, 34 insertions(+), 5 deletions(-) 688f0a3fc7e3a81743bc4ce3cc858b880c648595 0001-cmdutils-dont-call-read_header-before-listing-device.patch From 2b9a20f97687f11eb5d1fd72db3b25e3f2703b73 Mon Sep 17 00:00:00 2001 From: Lukasz Marek lukasz.m.lu...@gmail.com Date: Mon, 15 Dec 2014 00:31:42 +0100 Subject: [PATCH] cmdutils: dont call read_header before listing devices List device callback must be able to return valid list without opening device. This callback should return input values for open function, not vice-versa. Read header funtion is very likey to fail without proper configuration provided. Signed-off-by: Lukasz Marek lukasz.m.lu...@gmail.com --- cmdutils.c | 39 ++- 1 file changed, 34 insertions(+), 5 deletions(-) should be ok, though its a
Re: [FFmpeg-devel] [PATCH] cmdutils: dont call read_header before listing devices
On 15.12.2014 14:18, Michael Niedermayer wrote: cmdutils.c |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) 8d012a5193b0440717f89d920661913ef160e674 0001-cmdutils-dont-call-read_header-before-listing-device.patch From 332bb7456c498518ea72dfdaa0e8c3e76d383f21 Mon Sep 17 00:00:00 2001 From: Lukasz Marek lukasz.m.lu...@gmail.com Date: Mon, 15 Dec 2014 00:31:42 +0100 Subject: [PATCH] cmdutils: dont call read_header before listing devices List device callback must be able to return valid list without opening device. This callback should return input values for open function, not vice-versa. Read header funtion is very likey to fail without proper configuration provided. should be ok I changed a patch. I wanted to avoid situation where .read_close is called without .read_header being called before. From 58fe020b8f1c0e809362e152febe3ad715b1c8fc Mon Sep 17 00:00:00 2001 From: Lukasz Marek lukasz.m.lu...@gmail.com Date: Mon, 15 Dec 2014 00:31:42 +0100 Subject: [PATCH] cmdutils: dont call read_header before listing devices List device callback must be able to return valid list without opening device. This callback should return input values for open function, not vice-versa. Read header funtion is very likey to fail without proper configuration provided. Signed-off-by: Lukasz Marek lukasz.m.lu...@gmail.com --- cmdutils.c | 41 +++-- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index 4e0a406..23a5f77 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -2052,7 +2052,37 @@ void *grow_array(void *array, int elem_size, int *size, int new_size) } #if CONFIG_AVDEVICE -static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts) +static int alloc_input_context(AVFormatContext **avctx, AVInputFormat *iformat) +{ +AVFormatContext *s = avformat_alloc_context(); +int ret = 0; + +*avctx = NULL; +if (!s) +return AVERROR(ENOMEM); + +s-iformat = iformat; +if (s-iformat-priv_data_size 0) { +s-priv_data = av_mallocz(s-iformat-priv_data_size); +if (!s-priv_data) { +ret = AVERROR(ENOMEM); +goto error; +} +if (s-iformat-priv_class) { +*(const AVClass**)s-priv_data= s-iformat-priv_class; +av_opt_set_defaults(s-priv_data); +} +} else +s-priv_data = NULL; + +*avctx = s; +return 0; + error: +avformat_free_context(s); +return ret; +} + +static int print_device_sources(void *pfmt, AVDictionary *opts) { int ret, i; AVFormatContext *dev = NULL; @@ -2069,13 +2099,12 @@ static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts) goto fail; } -/* TODO: avformat_open_input calls read_header callback which is not necessary. - Function like avformat_alloc_output_context2 for input could be helpful here. */ -av_dict_copy(tmp_opts, opts, 0); -if ((ret = avformat_open_input(dev, NULL, fmt, tmp_opts)) 0) { +if ((ret = alloc_input_context(dev, fmt)) 0) { printf(Cannot open device: %s.\n, fmt-name); goto fail; } +av_dict_copy(tmp_opts, opts, 0); +av_opt_set_dict2(dev, tmp_opts, AV_OPT_SEARCH_CHILDREN); if ((ret = avdevice_list_devices(dev, device_list)) 0) { printf(Cannot list sources.\n); @@ -2090,7 +2119,7 @@ static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts) fail: av_dict_free(tmp_opts); avdevice_free_list_devices(device_list); -avformat_close_input(dev); +avformat_free_context(dev); return ret; } -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] cmdutils: dont call read_header before listing devices
On Wed, Dec 17, 2014 at 10:59:37PM +0100, Lukasz Marek wrote: On 15.12.2014 14:18, Michael Niedermayer wrote: cmdutils.c |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) 8d012a5193b0440717f89d920661913ef160e674 0001-cmdutils-dont-call-read_header-before-listing-device.patch From 332bb7456c498518ea72dfdaa0e8c3e76d383f21 Mon Sep 17 00:00:00 2001 From: Lukasz Marek lukasz.m.lu...@gmail.com Date: Mon, 15 Dec 2014 00:31:42 +0100 Subject: [PATCH] cmdutils: dont call read_header before listing devices List device callback must be able to return valid list without opening device. This callback should return input values for open function, not vice-versa. Read header funtion is very likey to fail without proper configuration provided. should be ok I changed a patch. I wanted to avoid situation where .read_close is called without .read_header being called before. cmdutils.c | 41 +++-- 1 file changed, 35 insertions(+), 6 deletions(-) 9a93c401d795bae3545a6c6112e71abd98ac22ca 0001-cmdutils-dont-call-read_header-before-listing-device.patch From 58fe020b8f1c0e809362e152febe3ad715b1c8fc Mon Sep 17 00:00:00 2001 From: Lukasz Marek lukasz.m.lu...@gmail.com Date: Mon, 15 Dec 2014 00:31:42 +0100 Subject: [PATCH] cmdutils: dont call read_header before listing devices List device callback must be able to return valid list without opening device. This callback should return input values for open function, not vice-versa. Read header funtion is very likey to fail without proper configuration provided. Signed-off-by: Lukasz Marek lukasz.m.lu...@gmail.com --- cmdutils.c | 41 +++-- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index 4e0a406..23a5f77 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -2052,7 +2052,37 @@ void *grow_array(void *array, int elem_size, int *size, int new_size) } #if CONFIG_AVDEVICE -static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts) +static int alloc_input_context(AVFormatContext **avctx, AVInputFormat *iformat) +{ +AVFormatContext *s = avformat_alloc_context(); +int ret = 0; + +*avctx = NULL; +if (!s) +return AVERROR(ENOMEM); + +s-iformat = iformat; +if (s-iformat-priv_data_size 0) { +s-priv_data = av_mallocz(s-iformat-priv_data_size); +if (!s-priv_data) { +ret = AVERROR(ENOMEM); +goto error; +} +if (s-iformat-priv_class) { +*(const AVClass**)s-priv_data= s-iformat-priv_class; +av_opt_set_defaults(s-priv_data); +} +} else +s-priv_data = NULL; + +*avctx = s; +return 0; + error: +avformat_free_context(s); +return ret; +} + +static int print_device_sources(void *pfmt, AVDictionary *opts) { int ret, i; AVFormatContext *dev = NULL; @@ -2069,13 +2099,12 @@ static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts) goto fail; } -/* TODO: avformat_open_input calls read_header callback which is not necessary. - Function like avformat_alloc_output_context2 for input could be helpful here. */ -av_dict_copy(tmp_opts, opts, 0); -if ((ret = avformat_open_input(dev, NULL, fmt, tmp_opts)) 0) { +if ((ret = alloc_input_context(dev, fmt)) 0) { this fails building due to lack of a fmt variable [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Awnsering whenever a program halts or runs forever is On a turing machine, in general impossible (turings halting problem). On any real computer, always possible as a real computer has a finite number of states N, and will either halt in less than N cycles or never halt. signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] cmdutils: dont call read_header before listing devices
On 18.12.2014 01:09, Michael Niedermayer wrote: On Wed, Dec 17, 2014 at 10:59:37PM +0100, Lukasz Marek wrote: On 15.12.2014 14:18, Michael Niedermayer wrote: cmdutils.c |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) 8d012a5193b0440717f89d920661913ef160e674 0001-cmdutils-dont-call-read_header-before-listing-device.patch From 332bb7456c498518ea72dfdaa0e8c3e76d383f21 Mon Sep 17 00:00:00 2001 From: Lukasz Marek lukasz.m.lu...@gmail.com Date: Mon, 15 Dec 2014 00:31:42 +0100 Subject: [PATCH] cmdutils: dont call read_header before listing devices List device callback must be able to return valid list without opening device. This callback should return input values for open function, not vice-versa. Read header funtion is very likey to fail without proper configuration provided. should be ok I changed a patch. I wanted to avoid situation where .read_close is called without .read_header being called before. cmdutils.c | 41 +++-- 1 file changed, 35 insertions(+), 6 deletions(-) 9a93c401d795bae3545a6c6112e71abd98ac22ca 0001-cmdutils-dont-call-read_header-before-listing-device.patch From 58fe020b8f1c0e809362e152febe3ad715b1c8fc Mon Sep 17 00:00:00 2001 From: Lukasz Marek lukasz.m.lu...@gmail.com Date: Mon, 15 Dec 2014 00:31:42 +0100 Subject: [PATCH] cmdutils: dont call read_header before listing devices List device callback must be able to return valid list without opening device. This callback should return input values for open function, not vice-versa. Read header funtion is very likey to fail without proper configuration provided. Signed-off-by: Lukasz Marek lukasz.m.lu...@gmail.com --- cmdutils.c | 41 +++-- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index 4e0a406..23a5f77 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -2052,7 +2052,37 @@ void *grow_array(void *array, int elem_size, int *size, int new_size) } #if CONFIG_AVDEVICE -static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts) +static int alloc_input_context(AVFormatContext **avctx, AVInputFormat *iformat) +{ +AVFormatContext *s = avformat_alloc_context(); +int ret = 0; + +*avctx = NULL; +if (!s) +return AVERROR(ENOMEM); + +s-iformat = iformat; +if (s-iformat-priv_data_size 0) { +s-priv_data = av_mallocz(s-iformat-priv_data_size); +if (!s-priv_data) { +ret = AVERROR(ENOMEM); +goto error; +} +if (s-iformat-priv_class) { +*(const AVClass**)s-priv_data= s-iformat-priv_class; +av_opt_set_defaults(s-priv_data); +} +} else +s-priv_data = NULL; + +*avctx = s; +return 0; + error: +avformat_free_context(s); +return ret; +} + +static int print_device_sources(void *pfmt, AVDictionary *opts) { int ret, i; AVFormatContext *dev = NULL; @@ -2069,13 +2099,12 @@ static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts) goto fail; } -/* TODO: avformat_open_input calls read_header callback which is not necessary. - Function like avformat_alloc_output_context2 for input could be helpful here. */ -av_dict_copy(tmp_opts, opts, 0); -if ((ret = avformat_open_input(dev, NULL, fmt, tmp_opts)) 0) { +if ((ret = alloc_input_context(dev, fmt)) 0) { this fails building due to lack of a fmt variable I failed at cherry-pick conflict, thanks. Updated patch is attached. From 2b9a20f97687f11eb5d1fd72db3b25e3f2703b73 Mon Sep 17 00:00:00 2001 From: Lukasz Marek lukasz.m.lu...@gmail.com Date: Mon, 15 Dec 2014 00:31:42 +0100 Subject: [PATCH] cmdutils: dont call read_header before listing devices List device callback must be able to return valid list without opening device. This callback should return input values for open function, not vice-versa. Read header funtion is very likey to fail without proper configuration provided. Signed-off-by: Lukasz Marek lukasz.m.lu...@gmail.com --- cmdutils.c | 39 ++- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index 4e0a406..eb504a6 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -2052,6 +2052,36 @@ void *grow_array(void *array, int elem_size, int *size, int new_size) } #if CONFIG_AVDEVICE +static int alloc_input_context(AVFormatContext **avctx, AVInputFormat *iformat) +{ +AVFormatContext *s = avformat_alloc_context(); +int ret = 0; + +*avctx = NULL; +if (!s) +return AVERROR(ENOMEM); + +s-iformat = iformat; +if (s-iformat-priv_data_size 0) { +s-priv_data = av_mallocz(s-iformat-priv_data_size); +if (!s-priv_data) { +ret = AVERROR(ENOMEM); +goto error; +} +if (s-iformat-priv_class) { +*(const AVClass**)s-priv_data= s-iformat-priv_class; +
Re: [FFmpeg-devel] [PATCH] cmdutils: dont call read_header before listing devices
On Mon, Dec 15, 2014 at 12:36:49AM +0100, Lukasz Marek wrote: On 15.12.2014 00:33, Lukasz Marek wrote: List device callback must be able to return valid list without opening device. This callback should return input values for open function, not vice-versa. Read header funtion is very likey to fail without proper configuration provided. Signed-off-by: Lukasz Marek lukasz.m.lu...@gmail.com --- cmdutils.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index 06ce5d5..51fd777 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -2069,9 +2069,8 @@ static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts) goto fail; } -/* TODO: avformat_open_input calls read_header callback which is not necessary. - Function like avformat_alloc_output_context2 for input could be helpful here. */ av_dict_copy(tmp_opts, opts, 0); +dev-flags |= AVFMT_FLAG_PRIV_OPT; if ((ret = avformat_open_input(dev, NULL, fmt, tmp_opts)) 0) { printf(Cannot open device: %s.\n, fmt-name); goto fail; I forgot to amend. Updated patch attached. cmdutils.c |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) 8d012a5193b0440717f89d920661913ef160e674 0001-cmdutils-dont-call-read_header-before-listing-device.patch From 332bb7456c498518ea72dfdaa0e8c3e76d383f21 Mon Sep 17 00:00:00 2001 From: Lukasz Marek lukasz.m.lu...@gmail.com Date: Mon, 15 Dec 2014 00:31:42 +0100 Subject: [PATCH] cmdutils: dont call read_header before listing devices List device callback must be able to return valid list without opening device. This callback should return input values for open function, not vice-versa. Read header funtion is very likey to fail without proper configuration provided. should be ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The real ebay dictionary, page 1 Used only once- Some unspecified defect prevented a second use In good condition - Can be repaird by experienced expert As is - You wouldnt want it even if you were payed for it, if you knew ... signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH] cmdutils: dont call read_header before listing devices
On 15.12.2014 00:33, Lukasz Marek wrote: List device callback must be able to return valid list without opening device. This callback should return input values for open function, not vice-versa. Read header funtion is very likey to fail without proper configuration provided. Signed-off-by: Lukasz Marek lukasz.m.lu...@gmail.com --- cmdutils.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index 06ce5d5..51fd777 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -2069,9 +2069,8 @@ static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts) goto fail; } -/* TODO: avformat_open_input calls read_header callback which is not necessary. - Function like avformat_alloc_output_context2 for input could be helpful here. */ av_dict_copy(tmp_opts, opts, 0); +dev-flags |= AVFMT_FLAG_PRIV_OPT; if ((ret = avformat_open_input(dev, NULL, fmt, tmp_opts)) 0) { printf(Cannot open device: %s.\n, fmt-name); goto fail; I forgot to amend. Updated patch attached. From 332bb7456c498518ea72dfdaa0e8c3e76d383f21 Mon Sep 17 00:00:00 2001 From: Lukasz Marek lukasz.m.lu...@gmail.com Date: Mon, 15 Dec 2014 00:31:42 +0100 Subject: [PATCH] cmdutils: dont call read_header before listing devices List device callback must be able to return valid list without opening device. This callback should return input values for open function, not vice-versa. Read header funtion is very likey to fail without proper configuration provided. Signed-off-by: Lukasz Marek lukasz.m.lu...@gmail.com --- cmdutils.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmdutils.c b/cmdutils.c index 06ce5d5..3e932db 100644 --- a/cmdutils.c +++ b/cmdutils.c @@ -2069,9 +2069,13 @@ static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts) goto fail; } -/* TODO: avformat_open_input calls read_header callback which is not necessary. - Function like avformat_alloc_output_context2 for input could be helpful here. */ av_dict_copy(tmp_opts, opts, 0); +dev = avformat_alloc_context(); +if (!dev) { +ret = AVERROR(ENOMEM); +goto fail; +} +dev-flags |= AVFMT_FLAG_PRIV_OPT; if ((ret = avformat_open_input(dev, NULL, fmt, tmp_opts)) 0) { printf(Cannot open device: %s.\n, fmt-name); goto fail; -- 1.9.1 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel