Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a specific decode format

2019-04-23 Thread Eoff, Ullysses A
*bump*

> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Mark 
> Thompson
> Sent: Wednesday, February 20, 2019 1:52 PM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a specific 
> decode format
> 
> On 18/02/2019 05:05, Fu, Linjie wrote:
> >> -Original Message-
> >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> >> Of Fu, Linjie
> >> Sent: Friday, November 16, 2018 16:37
> >> To: FFmpeg development discussions and patches  >> de...@ffmpeg.org>
> >> Subject: Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
> >> specific decode format
> >>
> >>> -Original Message-
> >>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> >> Behalf
> >>> Of Mark Thompson
> >>> Sent: Thursday, November 15, 2018 05:48
> >>> To: ffmpeg-devel@ffmpeg.org
> >>> Subject: Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
> >>> specific decode format
> >>>
> >>> On 14/11/18 01:35, Fu, Linjie wrote:
> >>>>> -Original Message-----
> >>>>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> >>> Behalf
> >>>>> Of Mark Thompson
> >>>>> Sent: Wednesday, November 14, 2018 09:11
> >>>>> To: ffmpeg-devel@ffmpeg.org
> >>>>> Subject: Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
> >>>>> specific decode format
> >>>>>
> >>>>> On 14/11/18 00:50, Fu, Linjie wrote:
> >>>>>>> -Original Message-
> >>>>>>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> >>>>> Behalf
> >>>>>>> Of Mark Thompson
> >>>>>>> Sent: Wednesday, November 14, 2018 07:44
> >>>>>>> To: ffmpeg-devel@ffmpeg.org
> >>>>>>> Subject: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
> >>>>> specific
> >>>>>>> decode format
> >>>>>>>
> >>>>>>> Fixes #7519.
> >>>>>>> ---
> >>>>>>>  doc/ffmpeg.texi  | 13 
> >>>>>>>  fftools/ffmpeg.c | 10 ++
> >>>>>>>  fftools/ffmpeg.h |  4 
> >>>>>>>  fftools/ffmpeg_opt.c | 47
> >>>>>>> 
> >>>>>>>  4 files changed, 74 insertions(+)
> >>>>>>>
> >>>>>>> diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
> >>>>>>> index 3717f22d42..d127bc0f0d 100644
> >>>>>>> --- a/doc/ffmpeg.texi
> >>>>>>> +++ b/doc/ffmpeg.texi
> >>>>>>> @@ -920,6 +920,19 @@ would be more efficient.
> >>>>>>>  When doing stream copy, copy also non-key frames found at the
> >>>>>>>  beginning.
> >>>>>>>
> >>>>>>> +@item -decode_format[:@var{stream_specifier}]
> >>>>>>> @var{pixfmt}[,@var{pixfmt}...] (@emph{input,per-stream})
> >>>>>>> +Set the possible output formats to be used by the decoder for this
> >>>>> stream.
> >>>>>>> +If the decoder does not natively support any format in the given list
> >>> for
> >>>>>>> +the input stream then decoding will fail rather than continuing with 
> >>>>>>> a
> >>>>>>> +different format.
> >>>>>>> +
> >>>>>>> +In general this should not be set - the decoder will select an output
> >>>>>>> +format based on the input stream parameters and available
> >>> components,
> >>>>>>> and
> >>>>>>> +that will be automatically converted to whatever the output
> >> requires.
> >>> It
> >>>>>>> +may be useful to force a hardware decoder supporting output in
> >>>>> multiple
> >>>>>>> +different memory types to pick a desired one, or to ensure that a
> >>>>> hardware
> >>>>>>> +decoder is used when software fallback is also available.
> >>>>>>> 

Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a specific decode format

2019-02-20 Thread Mark Thompson
On 18/02/2019 05:05, Fu, Linjie wrote:
>> -Original Message-
>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
>> Of Fu, Linjie
>> Sent: Friday, November 16, 2018 16:37
>> To: FFmpeg development discussions and patches > de...@ffmpeg.org>
>> Subject: Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
>> specific decode format
>>
>>> -Original Message-
>>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
>> Behalf
>>> Of Mark Thompson
>>> Sent: Thursday, November 15, 2018 05:48
>>> To: ffmpeg-devel@ffmpeg.org
>>> Subject: Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
>>> specific decode format
>>>
>>> On 14/11/18 01:35, Fu, Linjie wrote:
>>>>> -Original Message-
>>>>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
>>> Behalf
>>>>> Of Mark Thompson
>>>>> Sent: Wednesday, November 14, 2018 09:11
>>>>> To: ffmpeg-devel@ffmpeg.org
>>>>> Subject: Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
>>>>> specific decode format
>>>>>
>>>>> On 14/11/18 00:50, Fu, Linjie wrote:
>>>>>>> -----Original Message-----
>>>>>>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
>>>>> Behalf
>>>>>>> Of Mark Thompson
>>>>>>> Sent: Wednesday, November 14, 2018 07:44
>>>>>>> To: ffmpeg-devel@ffmpeg.org
>>>>>>> Subject: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
>>>>> specific
>>>>>>> decode format
>>>>>>>
>>>>>>> Fixes #7519.
>>>>>>> ---
>>>>>>>  doc/ffmpeg.texi  | 13 
>>>>>>>  fftools/ffmpeg.c | 10 ++
>>>>>>>  fftools/ffmpeg.h |  4 
>>>>>>>  fftools/ffmpeg_opt.c | 47
>>>>>>> 
>>>>>>>  4 files changed, 74 insertions(+)
>>>>>>>
>>>>>>> diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
>>>>>>> index 3717f22d42..d127bc0f0d 100644
>>>>>>> --- a/doc/ffmpeg.texi
>>>>>>> +++ b/doc/ffmpeg.texi
>>>>>>> @@ -920,6 +920,19 @@ would be more efficient.
>>>>>>>  When doing stream copy, copy also non-key frames found at the
>>>>>>>  beginning.
>>>>>>>
>>>>>>> +@item -decode_format[:@var{stream_specifier}]
>>>>>>> @var{pixfmt}[,@var{pixfmt}...] (@emph{input,per-stream})
>>>>>>> +Set the possible output formats to be used by the decoder for this
>>>>> stream.
>>>>>>> +If the decoder does not natively support any format in the given list
>>> for
>>>>>>> +the input stream then decoding will fail rather than continuing with a
>>>>>>> +different format.
>>>>>>> +
>>>>>>> +In general this should not be set - the decoder will select an output
>>>>>>> +format based on the input stream parameters and available
>>> components,
>>>>>>> and
>>>>>>> +that will be automatically converted to whatever the output
>> requires.
>>> It
>>>>>>> +may be useful to force a hardware decoder supporting output in
>>>>> multiple
>>>>>>> +different memory types to pick a desired one, or to ensure that a
>>>>> hardware
>>>>>>> +decoder is used when software fallback is also available.
>>>>>>> +
>>>>>>>  @item -init_hw_device
>>>>>>> @var{type}[=@var{name}][:@var{device}[,@var{key=value}...]]
>>>>>>>  Initialise a new hardware device of type @var{type} called
>>> @var{name},
>>>>>>> using the
>>>>>>>  given device parameters.
>>>>>>> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
>>>>>>> index 38c21e944a..c651c8d3a8 100644
>>>>>>> --- a/fftools/ffmpeg.c
>>>>>>> +++ b/fftools/ffmpeg.c
>>>>>>> @@ -598,6 +598,7 @@ static void ffmpeg_cleanup(int ret)
>>>>>>>  avsubtitle_free(>prev_sub.subtitle);
>>>>

Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a specific decode format

2019-02-18 Thread Michael Niedermayer
On Tue, Nov 13, 2018 at 11:43:31PM +, Mark Thompson wrote:
> Fixes #7519.
> ---
>  doc/ffmpeg.texi  | 13 
>  fftools/ffmpeg.c | 10 ++
>  fftools/ffmpeg.h |  4 
>  fftools/ffmpeg_opt.c | 47 
>  4 files changed, 74 insertions(+)

i did already "LGTM" this IIRC, but as its being pinged ...
LGTM

thx

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Modern terrorism, a quick summary: Need oil, start war with country that
has oil, kill hundread thousand in war. Let country fall into chaos,
be surprised about raise of fundamantalists. Drop more bombs, kill more
people, be surprised about them taking revenge and drop even more bombs
and strip your own citizens of their rights and freedoms. to be continued


signature.asc
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a specific decode format

2019-02-17 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Fu, Linjie
> Sent: Friday, November 16, 2018 16:37
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
> specific decode format
> 
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > Of Mark Thompson
> > Sent: Thursday, November 15, 2018 05:48
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
> > specific decode format
> >
> > On 14/11/18 01:35, Fu, Linjie wrote:
> > >> -Original Message-
> > >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > Behalf
> > >> Of Mark Thompson
> > >> Sent: Wednesday, November 14, 2018 09:11
> > >> To: ffmpeg-devel@ffmpeg.org
> > >> Subject: Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
> > >> specific decode format
> > >>
> > >> On 14/11/18 00:50, Fu, Linjie wrote:
> > >>>> -Original Message-
> > >>>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > >> Behalf
> > >>>> Of Mark Thompson
> > >>>> Sent: Wednesday, November 14, 2018 07:44
> > >>>> To: ffmpeg-devel@ffmpeg.org
> > >>>> Subject: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
> > >> specific
> > >>>> decode format
> > >>>>
> > >>>> Fixes #7519.
> > >>>> ---
> > >>>>  doc/ffmpeg.texi  | 13 
> > >>>>  fftools/ffmpeg.c | 10 ++
> > >>>>  fftools/ffmpeg.h |  4 
> > >>>>  fftools/ffmpeg_opt.c | 47
> > >>>> 
> > >>>>  4 files changed, 74 insertions(+)
> > >>>>
> > >>>> diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
> > >>>> index 3717f22d42..d127bc0f0d 100644
> > >>>> --- a/doc/ffmpeg.texi
> > >>>> +++ b/doc/ffmpeg.texi
> > >>>> @@ -920,6 +920,19 @@ would be more efficient.
> > >>>>  When doing stream copy, copy also non-key frames found at the
> > >>>>  beginning.
> > >>>>
> > >>>> +@item -decode_format[:@var{stream_specifier}]
> > >>>> @var{pixfmt}[,@var{pixfmt}...] (@emph{input,per-stream})
> > >>>> +Set the possible output formats to be used by the decoder for this
> > >> stream.
> > >>>> +If the decoder does not natively support any format in the given list
> > for
> > >>>> +the input stream then decoding will fail rather than continuing with a
> > >>>> +different format.
> > >>>> +
> > >>>> +In general this should not be set - the decoder will select an output
> > >>>> +format based on the input stream parameters and available
> > components,
> > >>>> and
> > >>>> +that will be automatically converted to whatever the output
> requires.
> > It
> > >>>> +may be useful to force a hardware decoder supporting output in
> > >> multiple
> > >>>> +different memory types to pick a desired one, or to ensure that a
> > >> hardware
> > >>>> +decoder is used when software fallback is also available.
> > >>>> +
> > >>>>  @item -init_hw_device
> > >>>> @var{type}[=@var{name}][:@var{device}[,@var{key=value}...]]
> > >>>>  Initialise a new hardware device of type @var{type} called
> > @var{name},
> > >>>> using the
> > >>>>  given device parameters.
> > >>>> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> > >>>> index 38c21e944a..c651c8d3a8 100644
> > >>>> --- a/fftools/ffmpeg.c
> > >>>> +++ b/fftools/ffmpeg.c
> > >>>> @@ -598,6 +598,7 @@ static void ffmpeg_cleanup(int ret)
> > >>>>  avsubtitle_free(>prev_sub.subtitle);
> > >>>>  av_frame_free(>sub2video.frame);
> > >>>>  av_freep(>filters);
> > >>>> +av_freep(>decode_formats);
> > >>>>  av_freep(>hwaccel_device);
> &

Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a specific decode format

2018-11-16 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Thursday, November 15, 2018 05:48
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
> specific decode format
> 
> On 14/11/18 01:35, Fu, Linjie wrote:
> >> -Original Message-
> >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> >> Of Mark Thompson
> >> Sent: Wednesday, November 14, 2018 09:11
> >> To: ffmpeg-devel@ffmpeg.org
> >> Subject: Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
> >> specific decode format
> >>
> >> On 14/11/18 00:50, Fu, Linjie wrote:
> >>>> -Original Message-
> >>>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> >> Behalf
> >>>> Of Mark Thompson
> >>>> Sent: Wednesday, November 14, 2018 07:44
> >>>> To: ffmpeg-devel@ffmpeg.org
> >>>> Subject: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
> >> specific
> >>>> decode format
> >>>>
> >>>> Fixes #7519.
> >>>> ---
> >>>>  doc/ffmpeg.texi  | 13 
> >>>>  fftools/ffmpeg.c | 10 ++
> >>>>  fftools/ffmpeg.h |  4 
> >>>>  fftools/ffmpeg_opt.c | 47
> >>>> 
> >>>>  4 files changed, 74 insertions(+)
> >>>>
> >>>> diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
> >>>> index 3717f22d42..d127bc0f0d 100644
> >>>> --- a/doc/ffmpeg.texi
> >>>> +++ b/doc/ffmpeg.texi
> >>>> @@ -920,6 +920,19 @@ would be more efficient.
> >>>>  When doing stream copy, copy also non-key frames found at the
> >>>>  beginning.
> >>>>
> >>>> +@item -decode_format[:@var{stream_specifier}]
> >>>> @var{pixfmt}[,@var{pixfmt}...] (@emph{input,per-stream})
> >>>> +Set the possible output formats to be used by the decoder for this
> >> stream.
> >>>> +If the decoder does not natively support any format in the given list
> for
> >>>> +the input stream then decoding will fail rather than continuing with a
> >>>> +different format.
> >>>> +
> >>>> +In general this should not be set - the decoder will select an output
> >>>> +format based on the input stream parameters and available
> components,
> >>>> and
> >>>> +that will be automatically converted to whatever the output requires.
> It
> >>>> +may be useful to force a hardware decoder supporting output in
> >> multiple
> >>>> +different memory types to pick a desired one, or to ensure that a
> >> hardware
> >>>> +decoder is used when software fallback is also available.
> >>>> +
> >>>>  @item -init_hw_device
> >>>> @var{type}[=@var{name}][:@var{device}[,@var{key=value}...]]
> >>>>  Initialise a new hardware device of type @var{type} called
> @var{name},
> >>>> using the
> >>>>  given device parameters.
> >>>> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> >>>> index 38c21e944a..c651c8d3a8 100644
> >>>> --- a/fftools/ffmpeg.c
> >>>> +++ b/fftools/ffmpeg.c
> >>>> @@ -598,6 +598,7 @@ static void ffmpeg_cleanup(int ret)
> >>>>  avsubtitle_free(>prev_sub.subtitle);
> >>>>  av_frame_free(>sub2video.frame);
> >>>>  av_freep(>filters);
> >>>> +av_freep(>decode_formats);
> >>>>  av_freep(>hwaccel_device);
> >>>>  av_freep(>dts_buffer);
> >>>>
> >>>> @@ -2800,6 +2801,15 @@ static enum AVPixelFormat
> >>>> get_format(AVCodecContext *s, const enum AVPixelFormat
> >>>>  const AVCodecHWConfig  *config = NULL;
> >>>>  int i;
> >>>>
> >>>> +if (ist->decode_formats) {
> >>>> +for (i = 0; ist->decode_formats[i] != AV_PIX_FMT_NONE; i++) 
> >>>> {
> >>>> +if (ist->decode_formats[i] == *p)
> >>>> +break;
> >>>> +}
> >>>> +if (ist->decode_formats[i] != *p

Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a specific decode format

2018-11-14 Thread Mark Thompson
On 14/11/18 01:35, Fu, Linjie wrote:
>> -Original Message-
>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
>> Of Mark Thompson
>> Sent: Wednesday, November 14, 2018 09:11
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
>> specific decode format
>>
>> On 14/11/18 00:50, Fu, Linjie wrote:
>>>> -Original Message-
>>>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
>> Behalf
>>>> Of Mark Thompson
>>>> Sent: Wednesday, November 14, 2018 07:44
>>>> To: ffmpeg-devel@ffmpeg.org
>>>> Subject: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
>> specific
>>>> decode format
>>>>
>>>> Fixes #7519.
>>>> ---
>>>>  doc/ffmpeg.texi  | 13 
>>>>  fftools/ffmpeg.c | 10 ++
>>>>  fftools/ffmpeg.h |  4 
>>>>  fftools/ffmpeg_opt.c | 47
>>>> 
>>>>  4 files changed, 74 insertions(+)
>>>>
>>>> diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
>>>> index 3717f22d42..d127bc0f0d 100644
>>>> --- a/doc/ffmpeg.texi
>>>> +++ b/doc/ffmpeg.texi
>>>> @@ -920,6 +920,19 @@ would be more efficient.
>>>>  When doing stream copy, copy also non-key frames found at the
>>>>  beginning.
>>>>
>>>> +@item -decode_format[:@var{stream_specifier}]
>>>> @var{pixfmt}[,@var{pixfmt}...] (@emph{input,per-stream})
>>>> +Set the possible output formats to be used by the decoder for this
>> stream.
>>>> +If the decoder does not natively support any format in the given list for
>>>> +the input stream then decoding will fail rather than continuing with a
>>>> +different format.
>>>> +
>>>> +In general this should not be set - the decoder will select an output
>>>> +format based on the input stream parameters and available components,
>>>> and
>>>> +that will be automatically converted to whatever the output requires.  It
>>>> +may be useful to force a hardware decoder supporting output in
>> multiple
>>>> +different memory types to pick a desired one, or to ensure that a
>> hardware
>>>> +decoder is used when software fallback is also available.
>>>> +
>>>>  @item -init_hw_device
>>>> @var{type}[=@var{name}][:@var{device}[,@var{key=value}...]]
>>>>  Initialise a new hardware device of type @var{type} called @var{name},
>>>> using the
>>>>  given device parameters.
>>>> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
>>>> index 38c21e944a..c651c8d3a8 100644
>>>> --- a/fftools/ffmpeg.c
>>>> +++ b/fftools/ffmpeg.c
>>>> @@ -598,6 +598,7 @@ static void ffmpeg_cleanup(int ret)
>>>>  avsubtitle_free(>prev_sub.subtitle);
>>>>  av_frame_free(>sub2video.frame);
>>>>  av_freep(>filters);
>>>> +av_freep(>decode_formats);
>>>>  av_freep(>hwaccel_device);
>>>>  av_freep(>dts_buffer);
>>>>
>>>> @@ -2800,6 +2801,15 @@ static enum AVPixelFormat
>>>> get_format(AVCodecContext *s, const enum AVPixelFormat
>>>>  const AVCodecHWConfig  *config = NULL;
>>>>  int i;
>>>>
>>>> +if (ist->decode_formats) {
>>>> +for (i = 0; ist->decode_formats[i] != AV_PIX_FMT_NONE; i++) {
>>>> +if (ist->decode_formats[i] == *p)
>>>> +break;
>>>> +}
>>>> +if (ist->decode_formats[i] != *p)
>>>> +continue;
>>>> +}
>>>> +
>>>>  if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
>>>>  break;
>>>>
>>>> diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
>>>> index eb1eaf6363..b06fd18b1c 100644
>>>> --- a/fftools/ffmpeg.h
>>>> +++ b/fftools/ffmpeg.h
>>>> @@ -125,6 +125,8 @@ typedef struct OptionsContext {
>>>>  intnb_ts_scale;
>>>>  SpecifierOpt *dump_attachment;
>>>>  intnb_dump_attachment;
>>>> +SpecifierOpt *decode_formats;
>>>> +intnb_decode_formats;
>>>>  Spec

Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a specific decode format

2018-11-13 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Wednesday, November 14, 2018 09:11
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
> specific decode format
> 
> On 14/11/18 00:50, Fu, Linjie wrote:
> >> -Original Message-
> >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> >> Of Mark Thompson
> >> Sent: Wednesday, November 14, 2018 07:44
> >> To: ffmpeg-devel@ffmpeg.org
> >> Subject: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a
> specific
> >> decode format
> >>
> >> Fixes #7519.
> >> ---
> >>  doc/ffmpeg.texi  | 13 
> >>  fftools/ffmpeg.c | 10 ++
> >>  fftools/ffmpeg.h |  4 
> >>  fftools/ffmpeg_opt.c | 47
> >> 
> >>  4 files changed, 74 insertions(+)
> >>
> >> diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
> >> index 3717f22d42..d127bc0f0d 100644
> >> --- a/doc/ffmpeg.texi
> >> +++ b/doc/ffmpeg.texi
> >> @@ -920,6 +920,19 @@ would be more efficient.
> >>  When doing stream copy, copy also non-key frames found at the
> >>  beginning.
> >>
> >> +@item -decode_format[:@var{stream_specifier}]
> >> @var{pixfmt}[,@var{pixfmt}...] (@emph{input,per-stream})
> >> +Set the possible output formats to be used by the decoder for this
> stream.
> >> +If the decoder does not natively support any format in the given list for
> >> +the input stream then decoding will fail rather than continuing with a
> >> +different format.
> >> +
> >> +In general this should not be set - the decoder will select an output
> >> +format based on the input stream parameters and available components,
> >> and
> >> +that will be automatically converted to whatever the output requires.  It
> >> +may be useful to force a hardware decoder supporting output in
> multiple
> >> +different memory types to pick a desired one, or to ensure that a
> hardware
> >> +decoder is used when software fallback is also available.
> >> +
> >>  @item -init_hw_device
> >> @var{type}[=@var{name}][:@var{device}[,@var{key=value}...]]
> >>  Initialise a new hardware device of type @var{type} called @var{name},
> >> using the
> >>  given device parameters.
> >> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> >> index 38c21e944a..c651c8d3a8 100644
> >> --- a/fftools/ffmpeg.c
> >> +++ b/fftools/ffmpeg.c
> >> @@ -598,6 +598,7 @@ static void ffmpeg_cleanup(int ret)
> >>  avsubtitle_free(>prev_sub.subtitle);
> >>  av_frame_free(>sub2video.frame);
> >>  av_freep(>filters);
> >> +av_freep(>decode_formats);
> >>  av_freep(>hwaccel_device);
> >>  av_freep(>dts_buffer);
> >>
> >> @@ -2800,6 +2801,15 @@ static enum AVPixelFormat
> >> get_format(AVCodecContext *s, const enum AVPixelFormat
> >>  const AVCodecHWConfig  *config = NULL;
> >>  int i;
> >>
> >> +if (ist->decode_formats) {
> >> +for (i = 0; ist->decode_formats[i] != AV_PIX_FMT_NONE; i++) {
> >> +if (ist->decode_formats[i] == *p)
> >> +break;
> >> +}
> >> +if (ist->decode_formats[i] != *p)
> >> +continue;
> >> +}
> >> +
> >>  if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
> >>  break;
> >>
> >> diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
> >> index eb1eaf6363..b06fd18b1c 100644
> >> --- a/fftools/ffmpeg.h
> >> +++ b/fftools/ffmpeg.h
> >> @@ -125,6 +125,8 @@ typedef struct OptionsContext {
> >>  intnb_ts_scale;
> >>  SpecifierOpt *dump_attachment;
> >>  intnb_dump_attachment;
> >> +SpecifierOpt *decode_formats;
> >> +intnb_decode_formats;
> >>  SpecifierOpt *hwaccels;
> >>  intnb_hwaccels;
> >>  SpecifierOpt *hwaccel_devices;
> >> @@ -334,6 +336,8 @@ typedef struct InputStream {
> >>  int top_field_first;
> >>  int guess_layout_max;
> >>
> >> +enum AVPixelFormat *decode_formats;
> >> +
> >> 

Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a specific decode format

2018-11-13 Thread Mark Thompson
On 14/11/18 00:50, Fu, Linjie wrote:
>> -Original Message-
>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
>> Of Mark Thompson
>> Sent: Wednesday, November 14, 2018 07:44
>> To: ffmpeg-devel@ffmpeg.org
>> Subject: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a specific
>> decode format
>>
>> Fixes #7519.
>> ---
>>  doc/ffmpeg.texi  | 13 
>>  fftools/ffmpeg.c | 10 ++
>>  fftools/ffmpeg.h |  4 
>>  fftools/ffmpeg_opt.c | 47
>> 
>>  4 files changed, 74 insertions(+)
>>
>> diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
>> index 3717f22d42..d127bc0f0d 100644
>> --- a/doc/ffmpeg.texi
>> +++ b/doc/ffmpeg.texi
>> @@ -920,6 +920,19 @@ would be more efficient.
>>  When doing stream copy, copy also non-key frames found at the
>>  beginning.
>>
>> +@item -decode_format[:@var{stream_specifier}]
>> @var{pixfmt}[,@var{pixfmt}...] (@emph{input,per-stream})
>> +Set the possible output formats to be used by the decoder for this stream.
>> +If the decoder does not natively support any format in the given list for
>> +the input stream then decoding will fail rather than continuing with a
>> +different format.
>> +
>> +In general this should not be set - the decoder will select an output
>> +format based on the input stream parameters and available components,
>> and
>> +that will be automatically converted to whatever the output requires.  It
>> +may be useful to force a hardware decoder supporting output in multiple
>> +different memory types to pick a desired one, or to ensure that a hardware
>> +decoder is used when software fallback is also available.
>> +
>>  @item -init_hw_device
>> @var{type}[=@var{name}][:@var{device}[,@var{key=value}...]]
>>  Initialise a new hardware device of type @var{type} called @var{name},
>> using the
>>  given device parameters.
>> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
>> index 38c21e944a..c651c8d3a8 100644
>> --- a/fftools/ffmpeg.c
>> +++ b/fftools/ffmpeg.c
>> @@ -598,6 +598,7 @@ static void ffmpeg_cleanup(int ret)
>>  avsubtitle_free(>prev_sub.subtitle);
>>  av_frame_free(>sub2video.frame);
>>  av_freep(>filters);
>> +av_freep(>decode_formats);
>>  av_freep(>hwaccel_device);
>>  av_freep(>dts_buffer);
>>
>> @@ -2800,6 +2801,15 @@ static enum AVPixelFormat
>> get_format(AVCodecContext *s, const enum AVPixelFormat
>>  const AVCodecHWConfig  *config = NULL;
>>  int i;
>>
>> +if (ist->decode_formats) {
>> +for (i = 0; ist->decode_formats[i] != AV_PIX_FMT_NONE; i++) {
>> +if (ist->decode_formats[i] == *p)
>> +break;
>> +}
>> +if (ist->decode_formats[i] != *p)
>> +continue;
>> +}
>> +
>>  if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
>>  break;
>>
>> diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
>> index eb1eaf6363..b06fd18b1c 100644
>> --- a/fftools/ffmpeg.h
>> +++ b/fftools/ffmpeg.h
>> @@ -125,6 +125,8 @@ typedef struct OptionsContext {
>>  intnb_ts_scale;
>>  SpecifierOpt *dump_attachment;
>>  intnb_dump_attachment;
>> +SpecifierOpt *decode_formats;
>> +intnb_decode_formats;
>>  SpecifierOpt *hwaccels;
>>  intnb_hwaccels;
>>  SpecifierOpt *hwaccel_devices;
>> @@ -334,6 +336,8 @@ typedef struct InputStream {
>>  int top_field_first;
>>  int guess_layout_max;
>>
>> +enum AVPixelFormat *decode_formats;
>> +
>>  int autorotate;
>>
>>  int fix_sub_duration;
>> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
>> index d4851a2cd8..63bb05053b 100644
>> --- a/fftools/ffmpeg_opt.c
>> +++ b/fftools/ffmpeg_opt.c
>> @@ -701,6 +701,7 @@ static void add_input_streams(OptionsContext *o,
>> AVFormatContext *ic)
>>  AVStream *st = ic->streams[i];
>>  AVCodecParameters *par = st->codecpar;
>>  InputStream *ist = av_mallocz(sizeof(*ist));
>> +char *decode_formats = NULL;
>>  char *framerate = NULL, *hwaccel_device = NULL;
>>  const char *hwaccel = NULL;
>>  char *hwaccel_output_format = NULL;
>> @@ -797,6 +798,49 @@ static void add_input_streams(Op

Re: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a specific decode format

2018-11-13 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Wednesday, November 14, 2018 07:44
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a specific
> decode format
> 
> Fixes #7519.
> ---
>  doc/ffmpeg.texi  | 13 
>  fftools/ffmpeg.c | 10 ++
>  fftools/ffmpeg.h |  4 
>  fftools/ffmpeg_opt.c | 47
> 
>  4 files changed, 74 insertions(+)
> 
> diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
> index 3717f22d42..d127bc0f0d 100644
> --- a/doc/ffmpeg.texi
> +++ b/doc/ffmpeg.texi
> @@ -920,6 +920,19 @@ would be more efficient.
>  When doing stream copy, copy also non-key frames found at the
>  beginning.
> 
> +@item -decode_format[:@var{stream_specifier}]
> @var{pixfmt}[,@var{pixfmt}...] (@emph{input,per-stream})
> +Set the possible output formats to be used by the decoder for this stream.
> +If the decoder does not natively support any format in the given list for
> +the input stream then decoding will fail rather than continuing with a
> +different format.
> +
> +In general this should not be set - the decoder will select an output
> +format based on the input stream parameters and available components,
> and
> +that will be automatically converted to whatever the output requires.  It
> +may be useful to force a hardware decoder supporting output in multiple
> +different memory types to pick a desired one, or to ensure that a hardware
> +decoder is used when software fallback is also available.
> +
>  @item -init_hw_device
> @var{type}[=@var{name}][:@var{device}[,@var{key=value}...]]
>  Initialise a new hardware device of type @var{type} called @var{name},
> using the
>  given device parameters.
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 38c21e944a..c651c8d3a8 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -598,6 +598,7 @@ static void ffmpeg_cleanup(int ret)
>  avsubtitle_free(>prev_sub.subtitle);
>  av_frame_free(>sub2video.frame);
>  av_freep(>filters);
> +av_freep(>decode_formats);
>  av_freep(>hwaccel_device);
>  av_freep(>dts_buffer);
> 
> @@ -2800,6 +2801,15 @@ static enum AVPixelFormat
> get_format(AVCodecContext *s, const enum AVPixelFormat
>  const AVCodecHWConfig  *config = NULL;
>  int i;
> 
> +if (ist->decode_formats) {
> +for (i = 0; ist->decode_formats[i] != AV_PIX_FMT_NONE; i++) {
> +if (ist->decode_formats[i] == *p)
> +break;
> +}
> +if (ist->decode_formats[i] != *p)
> +continue;
> +}
> +
>  if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
>  break;
> 
> diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
> index eb1eaf6363..b06fd18b1c 100644
> --- a/fftools/ffmpeg.h
> +++ b/fftools/ffmpeg.h
> @@ -125,6 +125,8 @@ typedef struct OptionsContext {
>  intnb_ts_scale;
>  SpecifierOpt *dump_attachment;
>  intnb_dump_attachment;
> +SpecifierOpt *decode_formats;
> +intnb_decode_formats;
>  SpecifierOpt *hwaccels;
>  intnb_hwaccels;
>  SpecifierOpt *hwaccel_devices;
> @@ -334,6 +336,8 @@ typedef struct InputStream {
>  int top_field_first;
>  int guess_layout_max;
> 
> +enum AVPixelFormat *decode_formats;
> +
>  int autorotate;
> 
>  int fix_sub_duration;
> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> index d4851a2cd8..63bb05053b 100644
> --- a/fftools/ffmpeg_opt.c
> +++ b/fftools/ffmpeg_opt.c
> @@ -701,6 +701,7 @@ static void add_input_streams(OptionsContext *o,
> AVFormatContext *ic)
>  AVStream *st = ic->streams[i];
>  AVCodecParameters *par = st->codecpar;
>  InputStream *ist = av_mallocz(sizeof(*ist));
> +char *decode_formats = NULL;
>  char *framerate = NULL, *hwaccel_device = NULL;
>  const char *hwaccel = NULL;
>  char *hwaccel_output_format = NULL;
> @@ -797,6 +798,49 @@ static void add_input_streams(OptionsContext *o,
> AVFormatContext *ic)
>  ist->top_field_first = -1;
>  MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, 
> ic,
> st);
> 
> +MATCH_PER_STREAM_OPT(decode_formats, str, decode_formats, ic,
> st);
> +if (decode_formats) {
> +const char *p, *q;
> +int i, nb_formats;
> +char tmp[32];
> +
> + 

[FFmpeg-devel] [PATCH v2] ffmpeg: Add option to force a specific decode format

2018-11-13 Thread Mark Thompson
Fixes #7519.
---
 doc/ffmpeg.texi  | 13 
 fftools/ffmpeg.c | 10 ++
 fftools/ffmpeg.h |  4 
 fftools/ffmpeg_opt.c | 47 
 4 files changed, 74 insertions(+)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 3717f22d42..d127bc0f0d 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -920,6 +920,19 @@ would be more efficient.
 When doing stream copy, copy also non-key frames found at the
 beginning.
 
+@item -decode_format[:@var{stream_specifier}] @var{pixfmt}[,@var{pixfmt}...] 
(@emph{input,per-stream})
+Set the possible output formats to be used by the decoder for this stream.
+If the decoder does not natively support any format in the given list for
+the input stream then decoding will fail rather than continuing with a
+different format.
+
+In general this should not be set - the decoder will select an output
+format based on the input stream parameters and available components, and
+that will be automatically converted to whatever the output requires.  It
+may be useful to force a hardware decoder supporting output in multiple
+different memory types to pick a desired one, or to ensure that a hardware
+decoder is used when software fallback is also available.
+
 @item -init_hw_device 
@var{type}[=@var{name}][:@var{device}[,@var{key=value}...]]
 Initialise a new hardware device of type @var{type} called @var{name}, using 
the
 given device parameters.
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 38c21e944a..c651c8d3a8 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -598,6 +598,7 @@ static void ffmpeg_cleanup(int ret)
 avsubtitle_free(>prev_sub.subtitle);
 av_frame_free(>sub2video.frame);
 av_freep(>filters);
+av_freep(>decode_formats);
 av_freep(>hwaccel_device);
 av_freep(>dts_buffer);
 
@@ -2800,6 +2801,15 @@ static enum AVPixelFormat get_format(AVCodecContext *s, 
const enum AVPixelFormat
 const AVCodecHWConfig  *config = NULL;
 int i;
 
+if (ist->decode_formats) {
+for (i = 0; ist->decode_formats[i] != AV_PIX_FMT_NONE; i++) {
+if (ist->decode_formats[i] == *p)
+break;
+}
+if (ist->decode_formats[i] != *p)
+continue;
+}
+
 if (!(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))
 break;
 
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index eb1eaf6363..b06fd18b1c 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -125,6 +125,8 @@ typedef struct OptionsContext {
 intnb_ts_scale;
 SpecifierOpt *dump_attachment;
 intnb_dump_attachment;
+SpecifierOpt *decode_formats;
+intnb_decode_formats;
 SpecifierOpt *hwaccels;
 intnb_hwaccels;
 SpecifierOpt *hwaccel_devices;
@@ -334,6 +336,8 @@ typedef struct InputStream {
 int top_field_first;
 int guess_layout_max;
 
+enum AVPixelFormat *decode_formats;
+
 int autorotate;
 
 int fix_sub_duration;
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index d4851a2cd8..63bb05053b 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -701,6 +701,7 @@ static void add_input_streams(OptionsContext *o, 
AVFormatContext *ic)
 AVStream *st = ic->streams[i];
 AVCodecParameters *par = st->codecpar;
 InputStream *ist = av_mallocz(sizeof(*ist));
+char *decode_formats = NULL;
 char *framerate = NULL, *hwaccel_device = NULL;
 const char *hwaccel = NULL;
 char *hwaccel_output_format = NULL;
@@ -797,6 +798,49 @@ static void add_input_streams(OptionsContext *o, 
AVFormatContext *ic)
 ist->top_field_first = -1;
 MATCH_PER_STREAM_OPT(top_field_first, i, ist->top_field_first, ic, 
st);
 
+MATCH_PER_STREAM_OPT(decode_formats, str, decode_formats, ic, st);
+if (decode_formats) {
+const char *p, *q;
+int i, nb_formats;
+char tmp[32];
+
+nb_formats = 0;
+for (p = decode_formats; p; p = strchr(p + 1, ','))
+++nb_formats;
+
+ist->decode_formats =
+av_malloc_array(nb_formats + 1, 
sizeof(*ist->decode_formats));
+if (!ist->decode_formats)
+exit_program(1);
+
+p = decode_formats;
+for (i = 0; i < nb_formats; i++) {
+q = strchr(p, ',');
+if (!q) {
+ist->decode_formats[i] = av_get_pix_fmt(p);
+if (ist->decode_formats[i] == AV_PIX_FMT_NONE)
+break;
+continue;
+}
+if (q - p > sizeof(tmp) - 1)
+break;
+memcpy(tmp, p, q - p);
+tmp[q - p] = 0;
+ist->decode_formats[i]