Re: [FFmpeg-devel] [PATCH] avformat/mov: adjust skip_samples according to seek timestamp

2021-01-04 Thread Matthieu Bouron
On Mon, Nov 23, 2020 at 05:43:06PM +0100, Matthieu Bouron wrote:
> On Tue, Nov 17, 2020 at 02:18:46PM +0100, Matthieu Bouron wrote:
> > On Mon, Nov 09, 2020 at 06:26:46PM +0100, Matthieu Bouron wrote:
> > > On Mon, Nov 02, 2020 at 12:42:19PM +0100, Matthieu Bouron wrote:
> > > > Currently skip_samples is set to start_pad if sample_time is lesser or
> > > > equal to 0. This can cause issues if the stream starts with packets that
> > > > have negative pts. Calling avformat_seek_file() with ts set to 0 on such
> > > > streams makes the mov demuxer return the right corresponding packets
> > > > (near the 0 timestamp) but set skip_samples to start_pad which is
> > > > incorrect as the audio decoder will discard the returned samples
> > > > according to skip_samples from the first packet it receives (which has
> > > > its timestamp near 0).
> > > > 
> > > > For example, considering the following audio stream with start_pad=1344:
> > > > 
> > > >  [PKT pts=-1344] [PKT pts=-320] [PKT pts=704] [PKT pts=1728] [...]
> > > > 
> > > > Calling avformat_seek_file() with ts=0 makes the next call to
> > > > av_read_frame() return the packet with pts=-320 and a skip samples
> > > > side data set to 1344 (start_pad). This makes the audio decoder
> > > > incorrectly discard (1344 - 320) samples.
> > > > 
> > > > This commit makes the move demuxer adjust skip_samples according to the
> > > > stream start_pad, seek timestamp and first sample timestamp.
> > > > 
> > > > The above example will now result in av_read_frame() still returning the
> > > > packet with pts=-320 but with a skip samples side data set to 320
> > > > (src_pad - (seek_timestamp - first_timestamp)). This makes the audio
> > > > decoder only discard 320 samples (from pts=-320 to pts=0).
> > > > ---
> > > >  libavformat/mov.c | 18 --
> > > >  1 file changed, 16 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > > > index dd0db6bca79..f99cb0df25a 100644
> > > > --- a/libavformat/mov.c
> > > > +++ b/libavformat/mov.c
> > > > @@ -8098,20 +8098,34 @@ static int mov_read_seek(AVFormatContext *s, 
> > > > int stream_index, int64_t sample_ti
> > > >  return sample;
> > > >  
> > > >  if (mc->seek_individually) {
> > > > +MOVStreamContext *sc = s->streams[stream_index]->priv_data;
> > > > +
> > > >  /* adjust seek timestamp to found sample timestamp */
> > > > +int64_t first_timestamp = 
> > > > st->internal->index_entries[0].timestamp;
> > > >  int64_t seek_timestamp = 
> > > > st->internal->index_entries[sample].timestamp;
> > > >  
> > > > +/* adjust skip samples according to stream start_pad, seek 
> > > > timestamp and first timestamp */
> > > > +int64_t skip_samples = FFMAX(sc->start_pad - (seek_timestamp - 
> > > > first_timestamp), 0);
> > > > +st->internal->skip_samples = skip_samples;
> > > > +
> > > >  for (i = 0; i < s->nb_streams; i++) {
> > > >  int64_t timestamp;
> > > >  MOVStreamContext *sc = s->streams[i]->priv_data;
> > > >  st = s->streams[i];
> > > > -st->internal->skip_samples = (sample_time <= 0) ? 
> > > > sc->start_pad : 0;
> > > >  
> > > >  if (stream_index == i)
> > > >  continue;
> > > >  
> > > >  timestamp = av_rescale_q(seek_timestamp, 
> > > > s->streams[stream_index]->time_base, st->time_base);
> > > > -mov_seek_stream(s, st, timestamp, flags);
> > > > +sample = mov_seek_stream(s, st, timestamp, flags);
> > > > +if (sample >= 0) {
> > > > +first_timestamp = 
> > > > st->internal->index_entries[0].timestamp;
> > > > +seek_timestamp = 
> > > > st->internal->index_entries[sample].timestamp;
> > > > +
> > > > +/* adjust skip samples according to stream start_pad, 
> > > > seek timestamp and first timestamp */
> > > > +skip_samples = FFMAX(sc->start_pad - (seek_timestamp - 
> > > > first_timestamp), 0);
> > > > +st->internal->skip_samples = skip_samples;
> > > > +}
> > > >  }
> > > >  } else {
> > > >  for (i = 0; i < s->nb_streams; i++) {
> > > > -- 
> > > > 2.29.2
> > > > 
> > > 
> > > Ping.
> > > 
> > 
> > Ping.
> > 
> 
> Ping.
> 

Ping.

-- 
Matthieu B.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] FFmpeg buying an Apple M1 Mac Mini

2021-01-04 Thread Kieran Kunhya
On Sun, 3 Jan 2021 at 21:53, Josh Dekker  wrote:

> On 2021/01/03 20:18, Michael Niedermayer wrote:
> > On Sun, Jan 03, 2021 at 06:32:11PM +0100, Kieran Kunhya wrote:
> >> Hello,
> >>
> >> As it's 2021 I would like to propose FFmpeg purchase one or more (e.g
> >> FATE + development) Apple M1 Mac Minis and provide access to developers.
> >> This is something I have done a few years ago when AVX2 was a new
> >> instruction set.
> >>
> >> I can host these in the UK 24/7 and provide access and label them as
> >> belonging to the project and not me.
> > < To clarify these will be hosted in a proper datacentre, with proper
> > < connectivity, cooling etc.
> >>
> >> I would propose buying and getting reimbursed one or more of:
> >>
> >> - Apple M1 chip with 8‑core CPU, 8‑core GPU and 16‑core Neural
> Engine
> >> - 16GB unified memory
> >> - 1TB SSD storage
> >> - Gigabit Ethernet
> >>
> >> This is £1,299.00 in the UK right now on the Apple Site.
> >
> > assuming noone has objections or better suggestions
> > LGTM
> >
> > thx
> >
>
> Ok from me too. I would suggest getting 2x, one for only FATE and the
> other for general access & development for FFmpeg developers.
>

I will buy these if nobody objects by the end of the week.

Kieran
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/dolby_e: set constant frame_size

2021-01-04 Thread Nicolas Gaullier
>De : Nicolas Gaullier  
>Envoyé : mardi 15 décembre 2020 18:13
>À : ffmpeg-devel@ffmpeg.org
>Cc : Nicolas Gaullier 
>Objet : [PATCH] avcodec/dolby_e: set constant frame_size
>
>Fixes pts generation.
>
>Setting frame_size in dolby_e_init() or get_audio_frame_duration() can result 
>in a bad duration value for the first packet if dolby_e is muxed in a 
>container having a different sample_rate (ex:
>container @48KHz, DolbyE @44.8KHz).
>Maybe adding a parser to dolby_e would fix the issue and makes it possible to 
>set frame_size at decoder init which seems the best place.
>---
> libavcodec/dolby_e.c | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c index 
>429612ec08..b0e6d6aee3 100644
>--- a/libavcodec/dolby_e.c
>+++ b/libavcodec/dolby_e.c
>@@ -577,6 +577,7 @@ static int filter_frame(DBEContext *s, AVFrame *frame)
> reorder = ch_reorder_n;
> 
> frame->nb_samples = FRAME_SAMPLES;
>+s->avctx->frame_size = FRAME_SAMPLES;
> if ((ret = ff_get_buffer(s->avctx, frame, 0)) < 0)
> return ret;
> 
>--
>2.27.0.windows.1

Hello,
Just a ping for this little patch
Thx
Nicolas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] FFmpeg buying an Apple M1 Mac Mini

2021-01-04 Thread Thilo Borgmann
Am 04.01.21 um 13:22 schrieb Kieran Kunhya:
> On Sun, 3 Jan 2021 at 21:53, Josh Dekker  wrote:
> 
>> On 2021/01/03 20:18, Michael Niedermayer wrote:
>>> On Sun, Jan 03, 2021 at 06:32:11PM +0100, Kieran Kunhya wrote:
 Hello,

 As it's 2021 I would like to propose FFmpeg purchase one or more (e.g
 FATE + development) Apple M1 Mac Minis and provide access to developers.
 This is something I have done a few years ago when AVX2 was a new
 instruction set.

 I can host these in the UK 24/7 and provide access and label them as
 belonging to the project and not me.
>>> < To clarify these will be hosted in a proper datacentre, with proper
>>> < connectivity, cooling etc.

 I would propose buying and getting reimbursed one or more of:

 - Apple M1 chip with 8‑core CPU, 8‑core GPU and 16‑core Neural
>> Engine
 - 16GB unified memory
 - 1TB SSD storage
 - Gigabit Ethernet

 This is £1,299.00 in the UK right now on the Apple Site.
>>>
>>> assuming noone has objections or better suggestions
>>> LGTM
>>>
>>> thx
>>>
>>
>> Ok from me too. I would suggest getting 2x, one for only FATE and the
>> other for general access & development for FFmpeg developers.
>>
> 
> I will buy these if nobody objects by the end of the week.

Totally in favor, also I'd like us to have two machines running.

Thanks for hosting!

-Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [RFC] Event loop

2021-01-04 Thread Nicolas George
Peter Ross (12021-01-04):
> Majority of our demuxers and muxers assume a blocking model. Will they
> need to be rewritten (eventually) to use event-based i/o?

The way I see it, compatibility is ensured: the current API that reads
on protocol should still be supported, by creating a local loop and
running it until a packet is obtained. Exactly what we are doing now,
but with cleaner code and less duplication.

Therefore, muxers and demuxers written for it would continue working.

But muxers and demuxers would also have the option of being rewritten to
use events, and in turn gain better non-blocking operation in the
process.

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [RFC] Event loop

2021-01-04 Thread Nicolas George
Kieran Kunhya (12021-01-02):
> In my opinion we should use libev as the default and make it a submodule
> (possibly as part of some sort of plugin system for event loops). This
> allows us to use modern things such as io_uring as they come.

I can be on board with that, since I like libev very much, and I find it
matches well the philosophy of FFmpeg's coding practices.

But I am afraid I am not the one who will need convincing on this.

Making sure any event loop can be used with a pluggable system is, IMHO,
an absolute requisite. Based on this, providing a basic event loop,
enough to run most of our protocols, would be compatible with FFmpeg's
habits, and not that much work. And libev can be used if available for
more complex protocols or better performance.

But as I said, I would be fine with libev the main, official event loop
for the project.

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 01/27] cbs_h2645: Merge SEI messages in common between codecs

2021-01-04 Thread Nuo Mi
On Sat, Jan 2, 2021 at 5:45 AM Mark Thompson  wrote:

> Make a new template file for common SEI messages - this will also apply
> to H.266.
> ---
>  libavcodec/cbs_h264.h |  37 +--
>  libavcodec/cbs_h2645.c|  24 +++--
>  libavcodec/cbs_h264_syntax_template.c | 106 +---
>  libavcodec/cbs_h265.h |  45 ++---
>  libavcodec/cbs_h265_syntax_template.c | 135 --
>  libavcodec/cbs_sei.h  |  60 
>  libavcodec/cbs_sei_syntax_template.c  | 132 +
>  libavcodec/h264_metadata_bsf.c|   2 +-
>  libavcodec/vaapi_encode_h264.c|   2 +-
>  libavcodec/vaapi_encode_h265.c|  11 ++-
>  10 files changed, 250 insertions(+), 304 deletions(-)
>  create mode 100644 libavcodec/cbs_sei.h
>  create mode 100644 libavcodec/cbs_sei_syntax_template.c
>
> diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
> index a6fe0a6af2..81113f1ad0 100644
> --- a/libavcodec/cbs_h264.h
> +++ b/libavcodec/cbs_h264.h
> @@ -24,6 +24,7 @@
>
>  #include "cbs.h"
>  #include "cbs_h2645.h"
> +#include "cbs_sei.h"
>  #include "h264.h"
>
>
> @@ -274,21 +275,6 @@ typedef struct H264RawSEIPanScanRect {
>  uint16_t pan_scan_rect_repetition_period;
>  } H264RawSEIPanScanRect;
>
> -typedef struct H264RawSEIUserDataRegistered {
> -uint8_t itu_t_t35_country_code;
> -uint8_t itu_t_t35_country_code_extension_byte;
> -uint8_t *data;
> -AVBufferRef *data_ref;
> -size_t   data_length;
> -} H264RawSEIUserDataRegistered;
> -
> -typedef struct H264RawSEIUserDataUnregistered {
> -uint8_t uuid_iso_iec_11578[16];
> -uint8_t *data;
> -AVBufferRef *data_ref;
> -size_t   data_length;
> -} H264RawSEIUserDataUnregistered;
> -
>  typedef struct H264RawSEIRecoveryPoint {
>  uint16_t recovery_frame_cnt;
>  uint8_t exact_match_flag;
> @@ -305,19 +291,6 @@ typedef struct H264RawSEIDisplayOrientation {
>  uint8_t display_orientation_extension_flag;
>  } H264RawSEIDisplayOrientation;
>
> -typedef struct H264RawSEIMasteringDisplayColourVolume {
> -uint16_t display_primaries_x[3];
> -uint16_t display_primaries_y[3];
> -uint16_t white_point_x;
> -uint16_t white_point_y;
> -uint32_t max_display_mastering_luminance;
> -uint32_t min_display_mastering_luminance;
> -} H264RawSEIMasteringDisplayColourVolume;
> -
> -typedef struct H264RawSEIAlternativeTransferCharacteristics {
> -uint8_t preferred_transfer_characteristics;
> -} H264RawSEIAlternativeTransferCharacteristics;
> -
>  typedef struct H264RawSEIPayload {
>  uint32_t payload_type;
>  uint32_t payload_size;
> @@ -326,12 +299,12 @@ typedef struct H264RawSEIPayload {
>  H264RawSEIPicTiming pic_timing;
>  H264RawSEIPanScanRect pan_scan_rect;
>  // H264RawSEIFiller filler -> no fields.
> -H264RawSEIUserDataRegistered user_data_registered;
> -H264RawSEIUserDataUnregistered user_data_unregistered;
> +SEIRawUserDataRegistered user_data_registered;
> +SEIRawUserDataUnregistered user_data_unregistered;
>  H264RawSEIRecoveryPoint recovery_point;
>  H264RawSEIDisplayOrientation display_orientation;
> -H264RawSEIMasteringDisplayColourVolume
> mastering_display_colour_volume;
> -H264RawSEIAlternativeTransferCharacteristics
> +SEIRawMasteringDisplayColourVolume
> mastering_display_colour_volume;
> +SEIRawAlternativeTransferCharacteristics
>  alternative_transfer_characteristics;
>  struct {
>  uint8_t *data;
> diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> index 434322492c..ce58e47a36 100644
> --- a/libavcodec/cbs_h2645.c
> +++ b/libavcodec/cbs_h2645.c
> @@ -253,9 +253,11 @@ static int
> cbs_h265_payload_extension_present(GetBitContext *gbc, uint32_t paylo
>  return err; \
>  } while (0)
>
> -#define FUNC_NAME(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name
> -#define FUNC_H264(rw, name) FUNC_NAME(rw, h264, name)
> -#define FUNC_H265(rw, name) FUNC_NAME(rw, h265, name)
> +#define FUNC_NAME2(rw, codec, name) cbs_ ## codec ## _ ## rw ## _ ## name
> +#define FUNC_NAME1(rw, codec, name) FUNC_NAME2(rw, codec, name)
> +#define FUNC_H264(name) FUNC_NAME1(READWRITE, h264, name)
> +#define FUNC_H265(name) FUNC_NAME1(READWRITE, h265, name)
> +#define FUNC_SEI(name)  FUNC_NAME1(READWRITE, sei,  name)
>
>  #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs,
> __VA_ARGS__ }) : NULL)
>
> @@ -356,11 +358,15 @@ static int
> cbs_h2645_read_more_rbsp_data(GetBitContext *gbc)
>  name = name ## _ref->data; \
>  } while (0)
>
> -#define FUNC(name) FUNC_H264(READWRITE, name)
> +#define FUNC(name) FUNC_SEI(name)
> +#include "cbs_sei_syntax_template.c"
> +#undef FUNC
> +
> +#define FUNC(name) FUNC_H264(name)
>  #include "cbs_h264_syntax_template.c"
>  #undef FUNC
>
> -#define FUNC(name) FUNC_H265(READWRITE

Re: [FFmpeg-devel] [RFC] Event loop

2021-01-04 Thread Xiang Xiao
Nicolas, thank you for bringing up this topic.
My team is working on similar functionality: the event loop is the
central point to integrate protocol, demux/mux, decoder/encoder, avfilter
and avdevice to form a complete multimedia subsystem(like DirectShow or
GStreamer). Without the builtin event loop, it is very hard to support it
with a clean and elegant way outside FFmpeg:

   1. Multiple streaming(either local or network)
   2. Multiple devices(either capture, playback even Bluetooth A2DP/SCO)
   3. Interact and coordinate between the components
   4. Provide a system wide and easy used API to application

We are very excited that the community is considering to provide the
generic event loop support and want to make the contribution.

Thanks
Xiang

On Mon, Jan 4, 2021 at 9:45 PM Nicolas George  wrote:

> Kieran Kunhya (12021-01-02):
> > In my opinion we should use libev as the default and make it a submodule
> > (possibly as part of some sort of plugin system for event loops). This
> > allows us to use modern things such as io_uring as they come.
>
> I can be on board with that, since I like libev very much, and I find it
> matches well the philosophy of FFmpeg's coding practices.
>
> But I am afraid I am not the one who will need convincing on this.
>
> Making sure any event loop can be used with a pluggable system is, IMHO,
> an absolute requisite. Based on this, providing a basic event loop,
> enough to run most of our protocols, would be compatible with FFmpeg's
> habits, and not that much work. And libev can be used if available for
> more complex protocols or better performance.
>
> But as I said, I would be fine with libev the main, official event loop
> for the project.
>
> Regards,
>
> --
>   Nicolas George
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 01/27] cbs_h2645: Merge SEI messages in common between codecs

2021-01-04 Thread James Almer

On 1/4/2021 11:32 AM, Nuo Mi wrote:

+static int FUNC(sei_mastering_display_colour_volume)
+(CodedBitstreamContext *ctx, RWContext *rw,
+ SEIRawMasteringDisplayColourVolume *current)
+{
+int err, c;
+
+HEADER("Mastering Display Colour Volume");
+
+for (c = 0; c < 3; c++) {
+us(16, display_primaries_x[c], 0, 5, 1, c);
+us(16, display_primaries_y[c], 0, 5, 1, c);
+}
+
+u(16, white_point_x, 0, 5);
+u(16, white_point_y, 0, 5);


could you explain more about the 5? it's not in spec.


Check patch 4/27. It was a constrain present in previous revisions of 
the spec.

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2] fate/hevc-conformance: add clip for persistent_rice_adaptation_enabled_flag

2021-01-04 Thread Linjie Fu
On Fri, Jan 1, 2021 at 9:39 PM Linjie Fu  wrote:
>
> On Mon, Dec 14, 2020 at 5:49 PM Guangxin Xu  wrote:
> >
> > Hi Lingjie
> > thanks for the review.
> > The stream has the feature but not used.
> >
> > the decoded yuv's md5 is 3c94b5ebc0aed0abae4e619b9dcca9cc
> > it's matched with the WPP_HIGH_TP_444_8BIT_RExt_Apple_2.md5
> >
>
> Double checked, md5 is matched,  and the related the descriptions in
> 9.3.1 and 9.3.2.4:
> For each Rice parameter initialization state k, each entry of the
> table tableStatCoeffSync is initialized to the corresponding value of
> StatCoeff[ k ].
>
> Would like to push this patch firstly if no objections.
> The fate patch could be applied later if someone helps to upload the sample.
Applied the functional patch, thx.

- linjie
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/libkvazaar: Set default ratecontrol algorithm for libkvazaar

2021-01-04 Thread Linjie Fu
On Fri, Jan 1, 2021 at 9:55 PM Linjie Fu  wrote:
>
> On Thu, Dec 10, 2020 at 3:28 PM Linjie Fu  wrote:
> >
> > On Thu, Dec 10, 2020 at 2:09 PM Joose Sainio  wrote:
> > >
> > > The standalone version of Kvazaar sets a default ratecontrol algorithm 
> > > when
> > > bitrate is set. Mirror this behaviour.
> > >
> > > Signed-off-by: Joose Sainio 
> > > ---
> > >   libavcodec/libkvazaar.c | 3 +++
> > >   1 file changed, 3 insertions(+)
> > >
> > > diff --git a/libavcodec/libkvazaar.c b/libavcodec/libkvazaar.c
> > > index 9032547678..68ce7ad58c 100644
> > > --- a/libavcodec/libkvazaar.c
> > > +++ b/libavcodec/libkvazaar.c
> > > @@ -95,6 +95,9 @@ static av_cold int libkvazaar_init(AVCodecContext 
> > > *avctx)
> > >   cfg->target_bitrate = avctx->bit_rate;
> > >   cfg->vui.sar_width  = avctx->sample_aspect_ratio.num;
> > >   cfg->vui.sar_height = avctx->sample_aspect_ratio.den;
> > > +if(avctx->bit_rate){
> > > +cfg->rc_algorithm = KVZ_LAMBDA;
> > > +}
> > >
> > >   if (ctx->kvz_params) {
> > >   AVDictionary *dict = NULL;
> > >
> > >
> > Looks reasonable,  fixed the encoding failure if explicitly setting
> > bitrate through "-b:v 3M".
> > And the result matches the behaviour of -kvazaar-params "bitrate=300".
> >
> Prefer to apply if no objection.
>
Fixed the coding style, rebased and applied, thx.

- linjie
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 01/27] cbs_h2645: Merge SEI messages in common between codecs

2021-01-04 Thread Nuo Mi
Yeah, thanks for the reminder.

On Mon, Jan 4, 2021 at 10:47 PM James Almer  wrote:

> On 1/4/2021 11:32 AM, Nuo Mi wrote:
> >> +static int FUNC(sei_mastering_display_colour_volume)
> >> +(CodedBitstreamContext *ctx, RWContext *rw,
> >> + SEIRawMasteringDisplayColourVolume *current)
> >> +{
> >> +int err, c;
> >> +
> >> +HEADER("Mastering Display Colour Volume");
> >> +
> >> +for (c = 0; c < 3; c++) {
> >> +us(16, display_primaries_x[c], 0, 5, 1, c);
> >> +us(16, display_primaries_y[c], 0, 5, 1, c);
> >> +}
> >> +
> >> +u(16, white_point_x, 0, 5);
> >> +u(16, white_point_y, 0, 5);
> >>
> > could you explain more about the 5? it's not in spec.
>
> Check patch 4/27. It was a constrain present in previous revisions of
> the spec.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2] fate/hevc-conformance: add clip for persistent_rice_adaptation_enabled_flag

2021-01-04 Thread Guangxin Xu
Awesome, thanks!

On Mon, Jan 4, 2021 at 11:45 PM Linjie Fu 
wrote:

> On Fri, Jan 1, 2021 at 9:39 PM Linjie Fu 
> wrote:
> >
> > On Mon, Dec 14, 2020 at 5:49 PM Guangxin Xu  wrote:
> > >
> > > Hi Lingjie
> > > thanks for the review.
> > > The stream has the feature but not used.
> > >
> > > the decoded yuv's md5 is 3c94b5ebc0aed0abae4e619b9dcca9cc
> > > it's matched with the WPP_HIGH_TP_444_8BIT_RExt_Apple_2.md5
> > >
> >
> > Double checked, md5 is matched,  and the related the descriptions in
> > 9.3.1 and 9.3.2.4:
> > For each Rice parameter initialization state k, each entry of the
> > table tableStatCoeffSync is initialized to the corresponding value of
> > StatCoeff[ k ].
> >
> > Would like to push this patch firstly if no objections.
> > The fate patch could be applied later if someone helps to upload the
> sample.
> Applied the functional patch, thx.
>
> - linjie
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 03/27] cbs_h2645: Merge SEI message handling in common between codecs

2021-01-04 Thread Nuo Mi
On Sat, Jan 2, 2021 at 5:44 AM Mark Thompson  wrote:

> ---
>  libavcodec/Makefile   |   4 +-
>  libavcodec/cbs_h264.h |  50 +---
>  libavcodec/cbs_h2645.c| 300 +++--
>  libavcodec/cbs_h264_syntax_template.c | 173 +---
>  libavcodec/cbs_h265.h |  33 +--
>  libavcodec/cbs_h265_syntax_template.c | 269 +++
>  libavcodec/cbs_sei.c  | 369 ++
>  libavcodec/cbs_sei.h  | 255 ++
>  libavcodec/cbs_sei_syntax_template.c  | 215 +--
>  libavcodec/h264_metadata_bsf.c| 113 
>  libavcodec/vaapi_encode_h264.c|  51 ++--
>  libavcodec/vaapi_encode_h265.c|  38 +--
>  12 files changed, 1107 insertions(+), 763 deletions(-)
>  create mode 100644 libavcodec/cbs_sei.c
>
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 450781886d..6e12a8171d 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -71,8 +71,8 @@ OBJS-$(CONFIG_BSWAPDSP)+= bswapdsp.o
>  OBJS-$(CONFIG_CABAC)   += cabac.o
>  OBJS-$(CONFIG_CBS) += cbs.o
>  OBJS-$(CONFIG_CBS_AV1) += cbs_av1.o
> -OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o h2645_parse.o
> -OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o h2645_parse.o
> +OBJS-$(CONFIG_CBS_H264)+= cbs_h2645.o cbs_sei.o
> h2645_parse.o
> +OBJS-$(CONFIG_CBS_H265)+= cbs_h2645.o cbs_sei.o
> h2645_parse.o
>  OBJS-$(CONFIG_CBS_JPEG)+= cbs_jpeg.o
>  OBJS-$(CONFIG_CBS_MPEG2)   += cbs_mpeg2.o
>  OBJS-$(CONFIG_CBS_VP9) += cbs_vp9.o
> diff --git a/libavcodec/cbs_h264.h b/libavcodec/cbs_h264.h
> index 81113f1ad0..9eb97eae24 100644
> --- a/libavcodec/cbs_h264.h
> +++ b/libavcodec/cbs_h264.h
> @@ -291,34 +291,9 @@ typedef struct H264RawSEIDisplayOrientation {
>  uint8_t display_orientation_extension_flag;
>  } H264RawSEIDisplayOrientation;
>
> -typedef struct H264RawSEIPayload {
> -uint32_t payload_type;
> -uint32_t payload_size;
> -union {
> -H264RawSEIBufferingPeriod buffering_period;
> -H264RawSEIPicTiming pic_timing;
> -H264RawSEIPanScanRect pan_scan_rect;
> -// H264RawSEIFiller filler -> no fields.
> -SEIRawUserDataRegistered user_data_registered;
> -SEIRawUserDataUnregistered user_data_unregistered;
> -H264RawSEIRecoveryPoint recovery_point;
> -H264RawSEIDisplayOrientation display_orientation;
> -SEIRawMasteringDisplayColourVolume
> mastering_display_colour_volume;
> -SEIRawAlternativeTransferCharacteristics
> -alternative_transfer_characteristics;
> -struct {
> -uint8_t *data;
> -AVBufferRef *data_ref;
> -size_t   data_length;
> -} other;
> -} payload;
> -} H264RawSEIPayload;
> -
>  typedef struct H264RawSEI {
>  H264RawNALUnitHeader nal_unit_header;
> -
> -H264RawSEIPayload payload[H264_MAX_SEI_PAYLOADS];
> -uint8_t payload_count;
> +SEIRawMessageListmessage_list;
>  } H264RawSEI;
>
>  typedef struct H264RawSliceHeader {
> @@ -438,27 +413,4 @@ typedef struct CodedBitstreamH264Context {
>  uint8_t last_slice_nal_unit_type;
>  } CodedBitstreamH264Context;
>
> -
> -/**
> - * Add an SEI message to an access unit.
> - *
> - * On success, the payload will be owned by a unit in access_unit;
> - * on failure, the content of the payload will be freed.
> - */
> -int ff_cbs_h264_add_sei_message(CodedBitstreamFragment *access_unit,
> -H264RawSEIPayload *payload);
> -
> -/**
> - * Delete an SEI message from an access unit.
> - *
> - * Deletes from nal_unit, which must be an SEI NAL unit.  If this is the
> - * last message in nal_unit, also deletes it from access_unit.
> - *
> - * Requires nal_unit to be a unit in access_unit and position to be >= 0
> - * and < the payload count of the SEI nal_unit.
> - */
> -void ff_cbs_h264_delete_sei_message(CodedBitstreamFragment *access_unit,
> -CodedBitstreamUnit *nal_unit,
> -int position);
> -
>  #endif /* AVCODEC_CBS_H264_H */
> diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
> index ce58e47a36..a00bc27370 100644
> --- a/libavcodec/cbs_h2645.c
> +++ b/libavcodec/cbs_h2645.c
> @@ -348,6 +348,7 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext
> *gbc)
>
>  #define more_rbsp_data(var) ((var) = cbs_h2645_read_more_rbsp_data(rw))
>
> +#define bit_position(rw)   (get_bits_count(rw))
>  #define byte_alignment(rw) (get_bits_count(rw) % 8)
>
>  #define allocate(name, size) do { \
> @@ -379,6 +380,7 @@ static int cbs_h2645_read_more_rbsp_data(GetBitContext
> *gbc)
>  #undef xse
>  #undef infer
>  #undef more_rbsp_data
> +#undef bit_position
>  #undef byte_alignment
>  #undef allocate
>
> @@ -424,6

Re: [FFmpeg-devel] [PATCH 16/16] avfilter/vsrc_testsrc: Deduplicate options

2021-01-04 Thread Nicolas George
Hi.

Andreas Rheinhardt (12021-01-04):
> Signed-off-by: Andreas Rheinhardt 
> ---
>  libavfilter/vsrc_testsrc.c | 15 +--
>  1 file changed, 5 insertions(+), 10 deletions(-)

IIRC, options tables cannot be de-duplicated, because of some
enumerating code. Or am I confusing with something else?

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 16/16] avfilter/vsrc_testsrc: Deduplicate options

2021-01-04 Thread Andreas Rheinhardt
Nicolas George:
> Hi.
> 
> Andreas Rheinhardt (12021-01-04):
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>  libavfilter/vsrc_testsrc.c | 15 +--
>>  1 file changed, 5 insertions(+), 10 deletions(-)
> 
> IIRC, options tables cannot be de-duplicated, because of some
> enumerating code. Or am I confusing with something else?
> 

What enumerating code? It is actually commonplace that options are
shared (you can find examples in libavfilter by using 'git grep -e
define --and -e options'); pointing into other options and thereby
reusing only a part of other options is not common, but I don't really
see why it shouldn't work.

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 16/16] avfilter/vsrc_testsrc: Deduplicate options

2021-01-04 Thread Nicolas George
Andreas Rheinhardt (12021-01-04):
> What enumerating code? It is actually commonplace that options are
> shared (you can find examples in libavfilter by using 'git grep -e
> define --and -e options'); pointing into other options and thereby
> reusing only a part of other options is not common, but I don't really
> see why it shouldn't work.

Using #define to de-duplicate the source is fine, of course.

But IIRC pointing to the same array, i.e. de-duplicating in the binary,
will lead to the code that enumerate options to loop in some way. I do
not remember the details, and I cannot find a commit that talks about
it, sorry. Maybe somebody here remembers better?

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 16/16] avfilter/vsrc_testsrc: Deduplicate options

2021-01-04 Thread James Almer

On 1/4/2021 4:29 PM, Nicolas George wrote:

Andreas Rheinhardt (12021-01-04):

What enumerating code? It is actually commonplace that options are
shared (you can find examples in libavfilter by using 'git grep -e
define --and -e options'); pointing into other options and thereby
reusing only a part of other options is not common, but I don't really
see why it shouldn't work.


Using #define to de-duplicate the source is fine, of course.

But IIRC pointing to the same array, i.e. de-duplicating in the binary,
will lead to the code that enumerate options to loop in some way. I do
not remember the details, and I cannot find a commit that talks about
it, sorry. Maybe somebody here remembers better?

Regards,


I recall issues with modules sharing a common AVClass, but different 
AVClasses sharing a common array of AVOptions seems to be ok.
See rawdec.h in libavformat, and how ff_raw_options is used in several 
different demuxer AVClasses.





___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 16/16] avfilter/vsrc_testsrc: Deduplicate options

2021-01-04 Thread Andreas Rheinhardt
Nicolas George:
> Andreas Rheinhardt (12021-01-04):
>> What enumerating code? It is actually commonplace that options are
>> shared (you can find examples in libavfilter by using 'git grep -e
>> define --and -e options'); pointing into other options and thereby
>> reusing only a part of other options is not common, but I don't really
>> see why it shouldn't work.
> 
> Using #define to de-duplicate the source is fine, of course.
> 
> But IIRC pointing to the same array, i.e. de-duplicating in the binary,
> will lead to the code that enumerate options to loop in some way. I do
> not remember the details, and I cannot find a commit that talks about
> it, sorry. Maybe somebody here remembers better?
> 
> Regards,
> 
The AVOpt API simply deals with arrays of AVOptions that are terminated
by a { NULL } entry. A pointer that points into such an array still
points into a { NULL } terminated list of options. It is really the same
as with ordinary strings*. Using ffmpeg -h filter=allyuv still shows the
same options.
(Is it possible that you are confusing this with AVFilterPads? Several
of the AVFilterPad arrays are also the same and I have not yet checked
whether they can be safely deduplicated or not.)

- Andreas

*: With the difference that the compiler is not allowed to deduplicate
on its own whereas this is legal for string literals.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 16/16] avfilter/vsrc_testsrc: Deduplicate options

2021-01-04 Thread Andreas Rheinhardt
Nicolas George:
> Andreas Rheinhardt (12021-01-04):
>> What enumerating code? It is actually commonplace that options are
>> shared (you can find examples in libavfilter by using 'git grep -e
>> define --and -e options'); pointing into other options and thereby
>> reusing only a part of other options is not common, but I don't really
>> see why it shouldn't work.
> 
> Using #define to de-duplicate the source is fine, of course.
> 
The examples that this command shows you do not only de-duplicate in the
source (like it is done here in vsrc_testsrc.c), but really in the
binary. And it works (for it not to work the AVOpt API would need to be
modified to e.g. store the addresses of all the AVOption arrays that it
has received so far and compare whether a AVOption * actually points
into an array already known; and of course it would have to error
out/abort for it to matter).

> But IIRC pointing to the same array, i.e. de-duplicating in the binary,
> will lead to the code that enumerate options to loop in some way. I do
> not remember the details, and I cannot find a commit that talks about
> it, sorry. Maybe somebody here remembers better?

- Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avformat/mov: adjust skip_samples according to seek timestamp

2021-01-04 Thread Marton Balint



On Mon, 2 Nov 2020, Matthieu Bouron wrote:


Currently skip_samples is set to start_pad if sample_time is lesser or
equal to 0. This can cause issues if the stream starts with packets that
have negative pts. Calling avformat_seek_file() with ts set to 0 on such
streams makes the mov demuxer return the right corresponding packets
(near the 0 timestamp) but set skip_samples to start_pad which is
incorrect as the audio decoder will discard the returned samples
according to skip_samples from the first packet it receives (which has
its timestamp near 0).

For example, considering the following audio stream with start_pad=1344:

[PKT pts=-1344] [PKT pts=-320] [PKT pts=704] [PKT pts=1728] [...]

Calling avformat_seek_file() with ts=0 makes the next call to
av_read_frame() return the packet with pts=-320 and a skip samples
side data set to 1344 (start_pad). This makes the audio decoder
incorrectly discard (1344 - 320) samples.

This commit makes the move demuxer adjust skip_samples according to the
stream start_pad, seek timestamp and first sample timestamp.

The above example will now result in av_read_frame() still returning the
packet with pts=-320 but with a skip samples side data set to 320
(src_pad - (seek_timestamp - first_timestamp)). This makes the audio
decoder only discard 320 samples (from pts=-320 to pts=0).
---
libavformat/mov.c | 18 --
1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index dd0db6bca79..f99cb0df25a 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -8098,20 +8098,34 @@ static int mov_read_seek(AVFormatContext *s, int 
stream_index, int64_t sample_ti
return sample;

if (mc->seek_individually) {
+MOVStreamContext *sc = s->streams[stream_index]->priv_data;
+
/* adjust seek timestamp to found sample timestamp */
+int64_t first_timestamp = st->internal->index_entries[0].timestamp;
int64_t seek_timestamp = st->internal->index_entries[sample].timestamp;

+/* adjust skip samples according to stream start_pad, seek timestamp 
and first timestamp */
+int64_t skip_samples = FFMAX(sc->start_pad - (seek_timestamp - 
first_timestamp), 0);
+st->internal->skip_samples = skip_samples;
+


Could you factorize this to a function? It seems you are doing exactly the 
same thing here and below.


Thanks,
Marton


for (i = 0; i < s->nb_streams; i++) {
int64_t timestamp;
MOVStreamContext *sc = s->streams[i]->priv_data;
st = s->streams[i];
-st->internal->skip_samples = (sample_time <= 0) ? sc->start_pad : 
0;

if (stream_index == i)
continue;

timestamp = av_rescale_q(seek_timestamp, 
s->streams[stream_index]->time_base, st->time_base);
-mov_seek_stream(s, st, timestamp, flags);
+sample = mov_seek_stream(s, st, timestamp, flags);
+if (sample >= 0) {
+first_timestamp = st->internal->index_entries[0].timestamp;
+seek_timestamp = st->internal->index_entries[sample].timestamp;
+
+/* adjust skip samples according to stream start_pad, seek 
timestamp and first timestamp */
+skip_samples = FFMAX(sc->start_pad - (seek_timestamp - 
first_timestamp), 0);
+st->internal->skip_samples = skip_samples;
+}
}
} else {
for (i = 0; i < s->nb_streams; i++) {
--
2.29.2

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/dolby_e: set constant frame_size

2021-01-04 Thread Marton Balint



On Mon, 4 Jan 2021, Nicolas Gaullier wrote:

De : Nicolas Gaullier  
Envoyé : mardi 15 décembre 2020 18:13

À : ffmpeg-devel@ffmpeg.org
Cc : Nicolas Gaullier 
Objet : [PATCH] avcodec/dolby_e: set constant frame_size

Fixes pts generation.

Setting frame_size in dolby_e_init() or get_audio_frame_duration() can result 
in a bad duration value for the first packet if dolby_e is muxed in a container 
having a different sample_rate (ex:
container @48KHz, DolbyE @44.8KHz).
Maybe adding a parser to dolby_e would fix the issue and makes it possible to 
set frame_size at decoder init which seems the best place.


I am not sure I understand this. It is suprising that you say that 
frame_size cannot be set in dolby_e_init(), why does it matter? It can 
only be FRAME_SAMPLES, no other values can happen. In that sense it is 
similar to sample_fmt, which I also don't see why it is set in every 
decode call, and not only once, in init.



---
libavcodec/dolby_e.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/libavcodec/dolby_e.c b/libavcodec/dolby_e.c index 
429612ec08..b0e6d6aee3 100644
--- a/libavcodec/dolby_e.c
+++ b/libavcodec/dolby_e.c
@@ -577,6 +577,7 @@ static int filter_frame(DBEContext *s, AVFrame *frame)
reorder = ch_reorder_n;

frame->nb_samples = FRAME_SAMPLES;
+s->avctx->frame_size = FRAME_SAMPLES;


If you still believe that setting this is required in every decode call, 
then I'd say it would be cleaner to set this at dolby_e_decode_frame where 
other avctx parameters are also set.


Thanks,
Marton


if ((ret = ff_get_buffer(s->avctx, frame, 0)) < 0)
return ret;

--
2.27.0.windows.1


Hello,
Just a ping for this little patch
Thx
Nicolas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 16/16] avfilter/vsrc_testsrc: Deduplicate options

2021-01-04 Thread Nicolas George
Andreas Rheinhardt (12021-01-04):
> The examples that this command shows you do not only de-duplicate in the
> source (like it is done here in vsrc_testsrc.c), but really in the
> binary. And it works (for it not to work the AVOpt API would need to be
> modified to e.g. store the addresses of all the AVOption arrays that it
> has received so far and compare whether a AVOption * actually points
> into an array already known; and of course it would have to error
> out/abort for it to matter).

It seems I speaking of another issue. Thanks James for clarifying.

No objection, then. Sorry.

Regards,

-- 
  Nicolas George


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 0/1] bug: test pointer to be used.

2021-01-04 Thread James Almer

On 1/4/2021 3:11 PM, AlexisWilke wrote:

It looks like the if() and the following lines disagree on the pointer to
be used.

I would imagine that these have been tested so the:

 f = indev_list[i - size];

and

 f = outdev_list[i - size];

are most certainly right, meaning that what's is wrong would be the condition
on the line prior. There is another location in that same file where a
similar test is used and the if() & following access use the same
pointer.

A proper test should call avpriv_register_devices() four times: with both
pointers set to NULL, both pointers not set to NULL, and twice with one of
the pointers set to NULL. That would allow you to verify this fix properly.


avpriv_register_devices() is an internal function that's called only 
once by avdevice_register_all(), and it will set both pointers to an 
array containing zero or more devices. Nothing else is meant to call it 
at all.
So indev_list and outdev_list will either both be NULL, or point to 
separate device list arrays.


This means there's no chance for a crash, but i agree that to make this 
more robust, the list checked should be the one that's used afterwards, 
in case the above were to be changed.





AlexisWilke (1):
   bug: test pointer to be used.

  libavformat/allformats.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 0/1] bug: test pointer to be used.

2021-01-04 Thread AlexisWilke
It looks like the if() and the following lines disagree on the pointer to
be used.

I would imagine that these have been tested so the:

f = indev_list[i - size];

and

f = outdev_list[i - size];

are most certainly right, meaning that what's is wrong would be the condition
on the line prior. There is another location in that same file where a
similar test is used and the if() & following access use the same
pointer.

A proper test should call avpriv_register_devices() four times: with both
pointers set to NULL, both pointers not set to NULL, and twice with one of
the pointers set to NULL. That would allow you to verify this fix properly.


AlexisWilke (1):
  bug: test pointer to be used.

 libavformat/allformats.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/1] bug: test pointer to be used.

2021-01-04 Thread AlexisWilke
Two tests check the opposite pointer before using it. If only one of these
is set to a valid pointer, one of these functions will crash, the other will
ignore the pointer.
---
 libavformat/allformats.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 0e0caaad39..6990af55f4 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -541,7 +541,7 @@ const AVOutputFormat *av_muxer_iterate(void **opaque)
 
 if (i < size) {
 f = muxer_list[i];
-} else if (indev_list) {
+} else if (outdev_list) {
 f = outdev_list[i - size];
 }
 
@@ -558,7 +558,7 @@ const AVInputFormat *av_demuxer_iterate(void **opaque)
 
 if (i < size) {
 f = demuxer_list[i];
-} else if (outdev_list) {
+} else if (indev_list) {
 f = indev_list[i - size];
 }
 
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 4/6] tools/target_dem_fuzzer.c: Decrease maxblocks

2021-01-04 Thread Michael Niedermayer
On Sun, Dec 27, 2020 at 06:49:36PM +0100, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 
> 28606/clusterfuzz-testcase-minimized-ffmpeg_dem_FRM_fuzzer-5123311424110592
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 

will apply

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

I have often repented speaking, but never of holding my tongue.
-- Xenocrates


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 5/6] avcodec/alsdec: Fix integer overflow with quant_cof

2021-01-04 Thread Michael Niedermayer
On Sun, Dec 27, 2020 at 06:49:37PM +0100, Michael Niedermayer wrote:
> Fixes: signed integer overflow: -210824 * 16384 cannot be represented in type 
> 'int'
> Fixes: 
> 28670/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_ALS_fuzzer-5682310846480384
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 

will apply

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

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/6] avformat/vividas: Check number of audio channels

2021-01-04 Thread Michael Niedermayer
On Sun, Dec 27, 2020 at 06:49:34PM +0100, Michael Niedermayer wrote:
> Fixes: division by 0
> Fixes: 
> 28597/clusterfuzz-testcase-minimized-ffmpeg_dem_VIVIDAS_fuzzer-5752201490333696
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/vividas.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

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

Nations do behave wisely once they have exhausted all other alternatives. 
-- Abba Eban


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [RFC] Event loop

2021-01-04 Thread Steven Liu


> 2021年1月4日 下午9:44,Nicolas George  写道:
> 
> Kieran Kunhya (12021-01-02):
>> In my opinion we should use libev as the default and make it a submodule
>> (possibly as part of some sort of plugin system for event loops). This
>> allows us to use modern things such as io_uring as they come.
> 
> I can be on board with that, since I like libev very much, and I find it
> matches well the philosophy of FFmpeg's coding practices.
> 
> But I am afraid I am not the one who will need convincing on this.
> 
> Making sure any event loop can be used with a pluggable system is, IMHO,
> an absolute requisite. Based on this, providing a basic event loop,
> enough to run most of our protocols, would be compatible with FFmpeg's
> habits, and not that much work. And libev can be used if available for
> more complex protocols or better performance.
> 
> But as I said, I would be fine with libev the main,
Is that mean I must enable libev if I use ffmpeg, or must enable libev if I use 
libav* API?
Or do you mean I can configure by myself if I don’t want use third part lib in 
ffmpeg?

> official event loop
> for the project.
> 
> Regards,
> 
> -- 
>  Nicolas George
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Thanks

Steven Liu



___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/qsvdec_other: refact, use DEFINE_QSV_DECODER to remove duplicate code

2021-01-04 Thread Guangxin Xu
Hi Linjie,
thanks for the review.

On Sat, Jan 2, 2021 at 11:29 AM Linjie Fu 
wrote:

> Guangxin:
>
> On Thu, Nov 26, 2020 at 6:21 PM Xu Guangxin  wrote:
> >
> > ---
> >  libavcodec/qsvdec_other.c | 188 --
> >  1 file changed, 36 insertions(+), 152 deletions(-)
> >
> > diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
> > index 2775e07955..266ac9f2e5 100644
> > --- a/libavcodec/qsvdec_other.c
> > +++ b/libavcodec/qsvdec_other.c
> > @@ -189,170 +189,54 @@ static const AVOption options[] = {
> >  { NULL },
> >  };
> >
> > -#if CONFIG_MPEG2_QSV_DECODER
> > -static const AVClass mpeg2_qsv_class = {
> > -.class_name = "mpeg2_qsv",
> > -.item_name  = av_default_item_name,
> > -.option = options,
> > -.version= LIBAVUTIL_VERSION_INT,
> > -};
> > +#define DEFINE_QSV_DECODER(x, X, bsf_name) \
> > +static const AVClass x##_qsv_class = { \
> > +.class_name = #x "_qsv", \
> > +.item_name  = av_default_item_name, \
> > +.option = options, \
> > +.version= LIBAVUTIL_VERSION_INT, \
> > +}; \
> > +AVCodec ff_##x##_qsv_decoder = { \
> > +.name   = #x "_qsv", \
> > +.long_name  = NULL_IF_CONFIG_SMALL(#X " video (Intel Quick Sync
> Video acceleration)"), \
> > +.priv_data_size = sizeof(QSVOtherContext), \
> > +.type   = AVMEDIA_TYPE_VIDEO, \
> > +.id = AV_CODEC_ID_##X, \
> > +.init   = qsv_decode_init, \
> > +.decode = qsv_decode_frame, \
> > +.flush  = qsv_decode_flush, \
> > +.close  = qsv_decode_close, \
> > +.bsfs   = bsf_name, \
> > +.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 |
> AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID, \
> > +.priv_class = &x##_qsv_class, \
> > +.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, \
> > +AV_PIX_FMT_P010, \
> > +AV_PIX_FMT_QSV, \
> > +AV_PIX_FMT_NONE }, \
> > +.hw_configs = ff_qsv_hw_configs, \
> > +.wrapper_name   = "qsv", \
> > +}; \
> >
> > -AVCodec ff_mpeg2_qsv_decoder = {
> > -.name   = "mpeg2_qsv",
> > -.long_name  = NULL_IF_CONFIG_SMALL("MPEG-2 video (Intel Quick
> Sync Video acceleration)"),
> > -.priv_data_size = sizeof(QSVOtherContext),
> > -.type   = AVMEDIA_TYPE_VIDEO,
> > -.id = AV_CODEC_ID_MPEG2VIDEO,
> > -.init   = qsv_decode_init,
> > -.decode = qsv_decode_frame,
> > -.flush  = qsv_decode_flush,
> > -.close  = qsv_decode_close,
> > -.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 |
> AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
> > -.priv_class = &mpeg2_qsv_class,
> > -.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
> > -AV_PIX_FMT_QSV,
> > -AV_PIX_FMT_NONE },
> > -.hw_configs = ff_qsv_hw_configs,
> > -.wrapper_name   = "qsv",
> > -};
> > +#if CONFIG_MPEG2_QSV_DECODER
> > +DEFINE_QSV_DECODER(mpeg2, MPEG2VIDEO, NULL)
> >  #endif
> >
> >  #if CONFIG_VC1_QSV_DECODER
> > -static const AVClass vc1_qsv_class = {
> > -.class_name = "vc1_qsv",
> > -.item_name  = av_default_item_name,
> > -.option = options,
> > -.version= LIBAVUTIL_VERSION_INT,
> > -};
> > -
> > -AVCodec ff_vc1_qsv_decoder = {
> > -.name   = "vc1_qsv",
> > -.long_name  = NULL_IF_CONFIG_SMALL("VC-1 video (Intel Quick
> Sync Video acceleration)"),
> > -.priv_data_size = sizeof(QSVOtherContext),
> > -.type   = AVMEDIA_TYPE_VIDEO,
> > -.id = AV_CODEC_ID_VC1,
> > -.init   = qsv_decode_init,
> > -.decode = qsv_decode_frame,
> > -.flush  = qsv_decode_flush,
> > -.close  = qsv_decode_close,
> > -.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 |
> AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
> > -.priv_class = &vc1_qsv_class,
> > -.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
> > -AV_PIX_FMT_QSV,
> > -AV_PIX_FMT_NONE },
> > -.hw_configs = ff_qsv_hw_configs,
> > -.wrapper_name   = "qsv",
> > -};
> > -#endif
> > -
> > -#if CONFIG_VP8_QSV_DECODER
> > -static const AVClass vp8_qsv_class = {
> > -.class_name = "vp8_qsv",
> > -.item_name  = av_default_item_name,
> > -.option = options,
> > -.version= LIBAVUTIL_VERSION_INT,
> > -};
> > -
> > -AVCodec ff_vp8_qsv_decoder = {
> > -.name   = "vp8_qsv",
> > -.long_name  = NULL_IF_CONFIG_SMALL("VP8 video (Intel Quick Sync
> Video acceleration)"),
> > -.priv_data_size = s

[FFmpeg-devel] [PATCH v2 1/6] avcodec/qsv_h2645: fix memory leak for plugin load

2021-01-04 Thread Xu Guangxin
---
 libavcodec/qsvdec_h2645.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/qsvdec_h2645.c b/libavcodec/qsvdec_h2645.c
index 02c41883b6..3d6e85230f 100644
--- a/libavcodec/qsvdec_h2645.c
+++ b/libavcodec/qsvdec_h2645.c
@@ -69,6 +69,8 @@ static av_cold int qsv_decode_close(AVCodecContext *avctx)
 {
 QSVH2645Context *s = avctx->priv_data;
 
+av_freep(&s->qsv.load_plugins);
+
 ff_qsv_decode_close(&s->qsv);
 
 qsv_clear_buffers(s);
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v2 2/6] avcodec/qsvdec_other: refact, use DEFINE_QSV_DECODER to remove duplicate code

2021-01-04 Thread Xu Guangxin
---
 libavcodec/qsvdec_other.c | 188 --
 1 file changed, 36 insertions(+), 152 deletions(-)

diff --git a/libavcodec/qsvdec_other.c b/libavcodec/qsvdec_other.c
index 2775e07955..266ac9f2e5 100644
--- a/libavcodec/qsvdec_other.c
+++ b/libavcodec/qsvdec_other.c
@@ -189,170 +189,54 @@ static const AVOption options[] = {
 { NULL },
 };
 
-#if CONFIG_MPEG2_QSV_DECODER
-static const AVClass mpeg2_qsv_class = {
-.class_name = "mpeg2_qsv",
-.item_name  = av_default_item_name,
-.option = options,
-.version= LIBAVUTIL_VERSION_INT,
-};
+#define DEFINE_QSV_DECODER(x, X, bsf_name) \
+static const AVClass x##_qsv_class = { \
+.class_name = #x "_qsv", \
+.item_name  = av_default_item_name, \
+.option = options, \
+.version= LIBAVUTIL_VERSION_INT, \
+}; \
+AVCodec ff_##x##_qsv_decoder = { \
+.name   = #x "_qsv", \
+.long_name  = NULL_IF_CONFIG_SMALL(#X " video (Intel Quick Sync Video 
acceleration)"), \
+.priv_data_size = sizeof(QSVOtherContext), \
+.type   = AVMEDIA_TYPE_VIDEO, \
+.id = AV_CODEC_ID_##X, \
+.init   = qsv_decode_init, \
+.decode = qsv_decode_frame, \
+.flush  = qsv_decode_flush, \
+.close  = qsv_decode_close, \
+.bsfs   = bsf_name, \
+.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | 
AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID, \
+.priv_class = &x##_qsv_class, \
+.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, \
+AV_PIX_FMT_P010, \
+AV_PIX_FMT_QSV, \
+AV_PIX_FMT_NONE }, \
+.hw_configs = ff_qsv_hw_configs, \
+.wrapper_name   = "qsv", \
+}; \
 
-AVCodec ff_mpeg2_qsv_decoder = {
-.name   = "mpeg2_qsv",
-.long_name  = NULL_IF_CONFIG_SMALL("MPEG-2 video (Intel Quick Sync 
Video acceleration)"),
-.priv_data_size = sizeof(QSVOtherContext),
-.type   = AVMEDIA_TYPE_VIDEO,
-.id = AV_CODEC_ID_MPEG2VIDEO,
-.init   = qsv_decode_init,
-.decode = qsv_decode_frame,
-.flush  = qsv_decode_flush,
-.close  = qsv_decode_close,
-.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | 
AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
-.priv_class = &mpeg2_qsv_class,
-.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
-AV_PIX_FMT_QSV,
-AV_PIX_FMT_NONE },
-.hw_configs = ff_qsv_hw_configs,
-.wrapper_name   = "qsv",
-};
+#if CONFIG_MPEG2_QSV_DECODER
+DEFINE_QSV_DECODER(mpeg2, MPEG2VIDEO, NULL)
 #endif
 
 #if CONFIG_VC1_QSV_DECODER
-static const AVClass vc1_qsv_class = {
-.class_name = "vc1_qsv",
-.item_name  = av_default_item_name,
-.option = options,
-.version= LIBAVUTIL_VERSION_INT,
-};
-
-AVCodec ff_vc1_qsv_decoder = {
-.name   = "vc1_qsv",
-.long_name  = NULL_IF_CONFIG_SMALL("VC-1 video (Intel Quick Sync Video 
acceleration)"),
-.priv_data_size = sizeof(QSVOtherContext),
-.type   = AVMEDIA_TYPE_VIDEO,
-.id = AV_CODEC_ID_VC1,
-.init   = qsv_decode_init,
-.decode = qsv_decode_frame,
-.flush  = qsv_decode_flush,
-.close  = qsv_decode_close,
-.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | 
AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
-.priv_class = &vc1_qsv_class,
-.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
-AV_PIX_FMT_QSV,
-AV_PIX_FMT_NONE },
-.hw_configs = ff_qsv_hw_configs,
-.wrapper_name   = "qsv",
-};
-#endif
-
-#if CONFIG_VP8_QSV_DECODER
-static const AVClass vp8_qsv_class = {
-.class_name = "vp8_qsv",
-.item_name  = av_default_item_name,
-.option = options,
-.version= LIBAVUTIL_VERSION_INT,
-};
-
-AVCodec ff_vp8_qsv_decoder = {
-.name   = "vp8_qsv",
-.long_name  = NULL_IF_CONFIG_SMALL("VP8 video (Intel Quick Sync Video 
acceleration)"),
-.priv_data_size = sizeof(QSVOtherContext),
-.type   = AVMEDIA_TYPE_VIDEO,
-.id = AV_CODEC_ID_VP8,
-.init   = qsv_decode_init,
-.decode = qsv_decode_frame,
-.flush  = qsv_decode_flush,
-.close  = qsv_decode_close,
-.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | 
AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
-.priv_class = &vp8_qsv_class,
-.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
-AV_PIX_FMT_QSV,
-   

[FFmpeg-devel] [PATCH v2 3/6] avcodec/qsvdec_h2645: refact, use DEFINE_QSV_DECODER to remove duplicate code

2021-01-04 Thread Xu Guangxin
---
 libavcodec/qsvdec_h2645.c | 89 +++
 1 file changed, 33 insertions(+), 56 deletions(-)

diff --git a/libavcodec/qsvdec_h2645.c b/libavcodec/qsvdec_h2645.c
index 3d6e85230f..974c1b6034 100644
--- a/libavcodec/qsvdec_h2645.c
+++ b/libavcodec/qsvdec_h2645.c
@@ -184,6 +184,36 @@ static void qsv_decode_flush(AVCodecContext *avctx)
 #define OFFSET(x) offsetof(QSVH2645Context, x)
 #define VD AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_DECODING_PARAM
 
+#define DEFINE_QSV_DECODER_WITH_OPTION(x, X, bsf_name, opt) \
+static const AVClass x##_qsv_class = { \
+.class_name = #x "_qsv", \
+.item_name  = av_default_item_name, \
+.option = opt, \
+.version= LIBAVUTIL_VERSION_INT, \
+}; \
+AVCodec ff_##x##_qsv_decoder = { \
+.name   = #x "_qsv", \
+.long_name  = NULL_IF_CONFIG_SMALL(#X " video (Intel Quick Sync Video 
acceleration)"), \
+.priv_data_size = sizeof(QSVH2645Context), \
+.type   = AVMEDIA_TYPE_VIDEO, \
+.id = AV_CODEC_ID_##X, \
+.init   = qsv_decode_init, \
+.decode = qsv_decode_frame, \
+.flush  = qsv_decode_flush, \
+.close  = qsv_decode_close, \
+.bsfs   = bsf_name, \
+.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | 
AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID, \
+.priv_class = &x##_qsv_class, \
+.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, \
+AV_PIX_FMT_P010, \
+AV_PIX_FMT_QSV, \
+AV_PIX_FMT_NONE }, \
+.hw_configs = ff_qsv_hw_configs, \
+.wrapper_name   = "qsv", \
+}; \
+
+#define DEFINE_QSV_DECODER(x, X, bsf_name) DEFINE_QSV_DECODER_WITH_OPTION(x, 
X, bsf_name, options)
+
 #if CONFIG_HEVC_QSV_DECODER
 static const AVOption hevc_options[] = {
 { "async_depth", "Internal parallelization depth, the higher the value the 
higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = 
ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VD },
@@ -202,37 +232,9 @@ static const AVOption hevc_options[] = {
 { "off", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_GPUCOPY_OFF },   
  0, 0, VD, "gpu_copy"},
 { NULL },
 };
-
-static const AVClass hevc_class = {
-.class_name = "hevc_qsv",
-.item_name  = av_default_item_name,
-.option = hevc_options,
-.version= LIBAVUTIL_VERSION_INT,
-};
-
-AVCodec ff_hevc_qsv_decoder = {
-.name   = "hevc_qsv",
-.long_name  = NULL_IF_CONFIG_SMALL("HEVC (Intel Quick Sync Video 
acceleration)"),
-.priv_data_size = sizeof(QSVH2645Context),
-.type   = AVMEDIA_TYPE_VIDEO,
-.id = AV_CODEC_ID_HEVC,
-.init   = qsv_decode_init,
-.decode = qsv_decode_frame,
-.flush  = qsv_decode_flush,
-.close  = qsv_decode_close,
-.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | 
AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
-.priv_class = &hevc_class,
-.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
-AV_PIX_FMT_P010,
-AV_PIX_FMT_QSV,
-AV_PIX_FMT_NONE },
-.hw_configs = ff_qsv_hw_configs,
-.bsfs   = "hevc_mp4toannexb",
-.wrapper_name   = "qsv",
-};
+DEFINE_QSV_DECODER_WITH_OPTION(hevc, HEVC, "hevc_mp4toannexb", hevc_options)
 #endif
 
-#if CONFIG_H264_QSV_DECODER
 static const AVOption options[] = {
 { "async_depth", "Internal parallelization depth, the higher the value the 
higher the latency.", OFFSET(qsv.async_depth), AV_OPT_TYPE_INT, { .i64 = 
ASYNC_DEPTH_DEFAULT }, 1, INT_MAX, VD },
 
@@ -243,31 +245,6 @@ static const AVOption options[] = {
 { NULL },
 };
 
-static const AVClass class = {
-.class_name = "h264_qsv",
-.item_name  = av_default_item_name,
-.option = options,
-.version= LIBAVUTIL_VERSION_INT,
-};
-
-AVCodec ff_h264_qsv_decoder = {
-.name   = "h264_qsv",
-.long_name  = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 
part 10 (Intel Quick Sync Video acceleration)"),
-.priv_data_size = sizeof(QSVH2645Context),
-.type   = AVMEDIA_TYPE_VIDEO,
-.id = AV_CODEC_ID_H264,
-.init   = qsv_decode_init,
-.decode = qsv_decode_frame,
-.flush  = qsv_decode_flush,
-.close  = qsv_decode_close,
-.capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_DR1 | 
AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HYBRID,
-.priv_class = &class,
-.pix_fmts   = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12,
-AV_PIX_FMT_P010,
-AV_PIX_FMT_QSV,
- 

[FFmpeg-devel] [PATCH v2 4/6] avcodec/qsvdec: refact, move qsvdec_h2645.c to qsvdec.c

2021-01-04 Thread Xu Guangxin
---
 libavcodec/Makefile   |   8 +-
 libavcodec/qsvdec.c   | 217 -
 libavcodec/qsvdec_h2645.c | 250 --
 3 files changed, 219 insertions(+), 256 deletions(-)
 delete mode 100644 libavcodec/qsvdec_h2645.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index fea37ef3c9..87b9396681 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -375,7 +375,7 @@ OBJS-$(CONFIG_H264_NVENC_ENCODER)  += nvenc_h264.o
 OBJS-$(CONFIG_NVENC_ENCODER)   += nvenc_h264.o
 OBJS-$(CONFIG_NVENC_H264_ENCODER)  += nvenc_h264.o
 OBJS-$(CONFIG_H264_OMX_ENCODER)+= omx.o
-OBJS-$(CONFIG_H264_QSV_DECODER)+= qsvdec_h2645.o
+OBJS-$(CONFIG_H264_QSV_DECODER)+= qsvdec.o
 OBJS-$(CONFIG_H264_QSV_ENCODER)+= qsvenc_h264.o
 OBJS-$(CONFIG_H264_RKMPP_DECODER)  += rkmppdec.o
 OBJS-$(CONFIG_H264_VAAPI_ENCODER)  += vaapi_encode_h264.o h264_levels.o
@@ -395,7 +395,7 @@ OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) += mediacodecdec.o
 OBJS-$(CONFIG_HEVC_MF_ENCODER) += mfenc.o mf_utils.o
 OBJS-$(CONFIG_HEVC_NVENC_ENCODER)  += nvenc_hevc.o
 OBJS-$(CONFIG_NVENC_HEVC_ENCODER)  += nvenc_hevc.o
-OBJS-$(CONFIG_HEVC_QSV_DECODER)+= qsvdec_h2645.o
+OBJS-$(CONFIG_HEVC_QSV_DECODER)+= qsvdec.o
 OBJS-$(CONFIG_HEVC_QSV_ENCODER)+= qsvenc_hevc.o hevc_ps_enc.o   \
   hevc_data.o
 OBJS-$(CONFIG_HEVC_RKMPP_DECODER)  += rkmppdec.o
@@ -923,14 +923,14 @@ OBJS-$(CONFIG_H263_VIDEOTOOLBOX_HWACCEL)  += 
videotoolbox.o
 OBJS-$(CONFIG_H264_D3D11VA_HWACCEL)   += dxva2_h264.o
 OBJS-$(CONFIG_H264_DXVA2_HWACCEL) += dxva2_h264.o
 OBJS-$(CONFIG_H264_NVDEC_HWACCEL) += nvdec_h264.o
-OBJS-$(CONFIG_H264_QSV_HWACCEL)   += qsvdec_h2645.o
+OBJS-$(CONFIG_H264_QSV_HWACCEL)   += qsvdec.o
 OBJS-$(CONFIG_H264_VAAPI_HWACCEL) += vaapi_h264.o
 OBJS-$(CONFIG_H264_VDPAU_HWACCEL) += vdpau_h264.o
 OBJS-$(CONFIG_H264_VIDEOTOOLBOX_HWACCEL)  += videotoolbox.o
 OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL)   += dxva2_hevc.o
 OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o
 OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o
-OBJS-$(CONFIG_HEVC_QSV_HWACCEL)   += qsvdec_h2645.o
+OBJS-$(CONFIG_HEVC_QSV_HWACCEL)   += qsvdec.o
 OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o h265_profile_level.o
 OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o h265_profile_level.o
 OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL)+= nvdec_mjpeg.o
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index c666aaeb52..18ae288b70 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -31,6 +31,7 @@
 #include "libavutil/hwcontext_qsv.h"
 #include "libavutil/mem.h"
 #include "libavutil/log.h"
+#include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/pixfmt.h"
 #include "libavutil/time.h"
@@ -228,7 +229,7 @@ static int qsv_decode_preinit(AVCodecContext *avctx, 
QSVContext *q, enum AVPixel
 return 0;
  }
 
-static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q, mfxVideoParam 
*param)
+static int qsv_decode_init_context(AVCodecContext *avctx, QSVContext *q, 
mfxVideoParam *param)
 {
 int ret;
 
@@ -615,7 +616,7 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext 
*q,
 }
 
 if (!q->initialized) {
-ret = qsv_decode_init(avctx, q, ¶m);
+ret = qsv_decode_init_context(avctx, q, ¶m);
 if (ret < 0)
 goto reinit_fail;
 q->initialized = 1;
@@ -633,3 +634,215 @@ void ff_qsv_decode_flush(AVCodecContext *avctx, 
QSVContext *q)
 q->orig_pix_fmt = AV_PIX_FMT_NONE;
 q->initialized = 0;
 }
+
+enum LoadPlugin {
+LOAD_PLUGIN_NONE,
+LOAD_PLUGIN_HEVC_SW,
+LOAD_PLUGIN_HEVC_HW,
+};
+
+typedef struct QSVDecContext {
+AVClass *class;
+QSVContext qsv;
+
+int load_plugin;
+
+AVFifoBuffer *packet_fifo;
+
+AVPacket buffer_pkt;
+} QSVDecContext;
+
+static void qsv_clear_buffers(QSVDecContext *s)
+{
+AVPacket pkt;
+while (av_fifo_size(s->packet_fifo) >= sizeof(pkt)) {
+av_fifo_generic_read(s->packet_fifo, &pkt, sizeof(pkt), NULL);
+av_packet_unref(&pkt);
+}
+
+av_packet_unref(&s->buffer_pkt);
+}
+
+static av_cold int qsv_decode_close(AVCodecContext *avctx)
+{
+QSVDecContext *s = avctx->priv_data;
+
+av_freep(&s->qsv.load_plugins);
+
+ff_qsv_decode_close(&s->qsv);
+
+qsv_clear_buffers(s);
+
+av_fifo_free(s->packet_fifo);
+
+return 0;
+}
+
+static av_cold int qsv_decode_init(AVCodecContext *avctx)
+{
+QSVDecContext *s = avctx->priv_data;
+int ret;
+
+if (avctx->codec_id == AV_CODEC_ID_HEVC && s->load_plugin != 
LOAD_PLUGIN_NONE) {
+static const char * const uid_hevcdec_sw = 
"15dd936825ad475ea34e35f3f54217a6";
+static const char * const uid_hevcdec_hw = 
"33a61c0b4c27454ca8d85dde757c6f8e";
+
+if (s->qsv.load_plugins[0]) {
+ 

[FFmpeg-devel] [PATCH v2 5/6] avcodec/qsvdec: refact, move qsvdec_other.c to qsvdec.c

2021-01-04 Thread Xu Guangxin
---
 libavcodec/Makefile   |  14 +--
 libavcodec/qsvdec.c   |  41 ++-
 libavcodec/qsvdec_other.c | 242 --
 3 files changed, 47 insertions(+), 250 deletions(-)
 delete mode 100644 libavcodec/qsvdec_other.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 87b9396681..cd6d8c89b1 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -449,7 +449,7 @@ OBJS-$(CONFIG_METASOUND_DECODER)   += metasound.o 
metasound_data.o \
 OBJS-$(CONFIG_MICRODVD_DECODER)+= microdvddec.o ass.o
 OBJS-$(CONFIG_MIMIC_DECODER)   += mimic.o
 OBJS-$(CONFIG_MJPEG_DECODER)   += mjpegdec.o
-OBJS-$(CONFIG_MJPEG_QSV_DECODER)   += qsvdec_other.o
+OBJS-$(CONFIG_MJPEG_QSV_DECODER)   += qsvdec.o
 OBJS-$(CONFIG_MJPEG_ENCODER)   += mjpegenc.o mjpegenc_common.o \
   mjpegenc_huffman.o
 OBJS-$(CONFIG_MJPEGB_DECODER)  += mjpegbdec.o
@@ -486,7 +486,7 @@ OBJS-$(CONFIG_MPEG1VIDEO_ENCODER)  += mpeg12enc.o 
mpeg12.o
 OBJS-$(CONFIG_MPEG1_CUVID_DECODER) += cuviddec.o
 OBJS-$(CONFIG_MPEG1_V4L2M2M_DECODER)   += v4l2_m2m_dec.o
 OBJS-$(CONFIG_MPEG2_MMAL_DECODER)  += mmaldec.o
-OBJS-$(CONFIG_MPEG2_QSV_DECODER)   += qsvdec_other.o
+OBJS-$(CONFIG_MPEG2_QSV_DECODER)   += qsvdec.o
 OBJS-$(CONFIG_MPEG2_QSV_ENCODER)   += qsvenc_mpeg2.o
 OBJS-$(CONFIG_MPEG2VIDEO_DECODER)  += mpeg12dec.o mpeg12.o mpeg12data.o
 OBJS-$(CONFIG_MPEG2VIDEO_ENCODER)  += mpeg12enc.o mpeg12.o
@@ -688,7 +688,7 @@ OBJS-$(CONFIG_VC1_DECODER) += vc1dec.o 
vc1_block.o vc1_loopfilter.o
   wmv2dsp.o wmv2data.o
 OBJS-$(CONFIG_VC1_CUVID_DECODER)   += cuviddec.o
 OBJS-$(CONFIG_VC1_MMAL_DECODER)+= mmaldec.o
-OBJS-$(CONFIG_VC1_QSV_DECODER) += qsvdec_other.o
+OBJS-$(CONFIG_VC1_QSV_DECODER) += qsvdec.o
 OBJS-$(CONFIG_VC1_V4L2M2M_DECODER) += v4l2_m2m_dec.o
 OBJS-$(CONFIG_VC2_ENCODER) += vc2enc.o vc2enc_dwt.o diractab.o
 OBJS-$(CONFIG_VCR1_DECODER)+= vcr1.o
@@ -707,7 +707,7 @@ OBJS-$(CONFIG_VP7_DECODER) += vp8.o vp56rac.o
 OBJS-$(CONFIG_VP8_DECODER) += vp8.o vp56rac.o
 OBJS-$(CONFIG_VP8_CUVID_DECODER)   += cuviddec.o
 OBJS-$(CONFIG_VP8_MEDIACODEC_DECODER)  += mediacodecdec.o
-OBJS-$(CONFIG_VP8_QSV_DECODER) += qsvdec_other.o
+OBJS-$(CONFIG_VP8_QSV_DECODER) += qsvdec.o
 OBJS-$(CONFIG_VP8_RKMPP_DECODER)   += rkmppdec.o
 OBJS-$(CONFIG_VP8_VAAPI_ENCODER)   += vaapi_encode_vp8.o
 OBJS-$(CONFIG_VP8_V4L2M2M_DECODER) += v4l2_m2m_dec.o
@@ -942,7 +942,7 @@ OBJS-$(CONFIG_MPEG1_XVMC_HWACCEL) += 
mpegvideo_xvmc.o
 OBJS-$(CONFIG_MPEG2_D3D11VA_HWACCEL)  += dxva2_mpeg2.o
 OBJS-$(CONFIG_MPEG2_DXVA2_HWACCEL)+= dxva2_mpeg2.o
 OBJS-$(CONFIG_MPEG2_NVDEC_HWACCEL)+= nvdec_mpeg12.o
-OBJS-$(CONFIG_MPEG2_QSV_HWACCEL)  += qsvdec_other.o
+OBJS-$(CONFIG_MPEG2_QSV_HWACCEL)  += qsvdec.o
 OBJS-$(CONFIG_MPEG2_VAAPI_HWACCEL)+= vaapi_mpeg2.o
 OBJS-$(CONFIG_MPEG2_VDPAU_HWACCEL)+= vdpau_mpeg12.o
 OBJS-$(CONFIG_MPEG2_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o
@@ -954,7 +954,7 @@ OBJS-$(CONFIG_MPEG4_VIDEOTOOLBOX_HWACCEL) += videotoolbox.o
 OBJS-$(CONFIG_VC1_D3D11VA_HWACCEL)+= dxva2_vc1.o
 OBJS-$(CONFIG_VC1_DXVA2_HWACCEL)  += dxva2_vc1.o
 OBJS-$(CONFIG_VC1_NVDEC_HWACCEL)  += nvdec_vc1.o
-OBJS-$(CONFIG_VC1_QSV_HWACCEL)+= qsvdec_other.o
+OBJS-$(CONFIG_VC1_QSV_HWACCEL)+= qsvdec.o
 OBJS-$(CONFIG_VC1_VAAPI_HWACCEL)  += vaapi_vc1.o
 OBJS-$(CONFIG_VC1_VDPAU_HWACCEL)  += vdpau_vc1.o
 OBJS-$(CONFIG_VP8_NVDEC_HWACCEL)  += nvdec_vp8.o
@@ -964,7 +964,7 @@ OBJS-$(CONFIG_VP9_DXVA2_HWACCEL)  += dxva2_vp9.o
 OBJS-$(CONFIG_VP9_NVDEC_HWACCEL)  += nvdec_vp9.o
 OBJS-$(CONFIG_VP9_VAAPI_HWACCEL)  += vaapi_vp9.o
 OBJS-$(CONFIG_VP9_VDPAU_HWACCEL)  += vdpau_vp9.o
-OBJS-$(CONFIG_VP8_QSV_HWACCEL)+= qsvdec_other.o
+OBJS-$(CONFIG_VP8_QSV_HWACCEL)+= qsvdec.o
 
 # libavformat dependencies
 OBJS-$(CONFIG_ISO_MEDIA)   += mpeg4audio.o mpegaudiodata.o
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 18ae288b70..3ca16dafae 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -683,7 +683,22 @@ static av_cold int qsv_decode_init(AVCodecContext *avctx)
 QSVDecContext *s = avctx->priv_data;
 int ret;
 
-if (avctx->codec_id == AV_CODEC_ID_HEVC && s->load_plugin != 
LOAD_PLUGIN_NONE) {
+if (avctx->codec_id == AV_CODEC_ID_VP8) {
+static const char *uid_vp8dec_hw = "f622394d8d87452f878c51f2fc9b4131";
+
+av_freep(&s->qsv.load_plugins);
+s->qsv.load_plugins = av_strdup(uid_vp8dec_hw);
+if (!s->qsv.load_plugins)
+return AVERROR(ENOMEM);
+} else if (avctx->codec_id == AV_CODEC_ID_VP9) {
+static const char *uid_vp9dec_hw = "a922394d8d87452f878c51f2fc9b4131";
+
+   

[FFmpeg-devel] [PATCH v2 6/6] avcodec/qsvdec: refact, remove duplicate code for plugin loading

2021-01-04 Thread Xu Guangxin
---
 libavcodec/qsvdec.c | 29 +++--
 1 file changed, 11 insertions(+), 18 deletions(-)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 3ca16dafae..d10f90a0db 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -682,21 +682,12 @@ static av_cold int qsv_decode_init(AVCodecContext *avctx)
 {
 QSVDecContext *s = avctx->priv_data;
 int ret;
+const char *uid = NULL;
 
 if (avctx->codec_id == AV_CODEC_ID_VP8) {
-static const char *uid_vp8dec_hw = "f622394d8d87452f878c51f2fc9b4131";
-
-av_freep(&s->qsv.load_plugins);
-s->qsv.load_plugins = av_strdup(uid_vp8dec_hw);
-if (!s->qsv.load_plugins)
-return AVERROR(ENOMEM);
+uid = "f622394d8d87452f878c51f2fc9b4131";
 } else if (avctx->codec_id == AV_CODEC_ID_VP9) {
-static const char *uid_vp9dec_hw = "a922394d8d87452f878c51f2fc9b4131";
-
-av_freep(&s->qsv.load_plugins);
-s->qsv.load_plugins = av_strdup(uid_vp9dec_hw);
-if (!s->qsv.load_plugins)
-return AVERROR(ENOMEM);
+uid = "a922394d8d87452f878c51f2fc9b4131";
 }
 else if (avctx->codec_id == AV_CODEC_ID_HEVC && s->load_plugin != 
LOAD_PLUGIN_NONE) {
 static const char * const uid_hevcdec_sw = 
"15dd936825ad475ea34e35f3f54217a6";
@@ -707,16 +698,18 @@ static av_cold int qsv_decode_init(AVCodecContext *avctx)
"load_plugins is not empty, but load_plugin is not set to 
'none'."
"The load_plugin value will be ignored.\n");
 } else {
-av_freep(&s->qsv.load_plugins);
-
 if (s->load_plugin == LOAD_PLUGIN_HEVC_SW)
-s->qsv.load_plugins = av_strdup(uid_hevcdec_sw);
+uid = uid_hevcdec_sw;
 else
-s->qsv.load_plugins = av_strdup(uid_hevcdec_hw);
-if (!s->qsv.load_plugins)
-return AVERROR(ENOMEM);
+uid = uid_hevcdec_hw;
 }
 }
+if (uid) {
+av_freep(&s->qsv.load_plugins);
+s->qsv.load_plugins = av_strdup(uid);
+if (!s->qsv.load_plugins)
+return AVERROR(ENOMEM);
+}
 
 s->qsv.orig_pix_fmt = AV_PIX_FMT_NV12;
 s->packet_fifo = av_fifo_alloc(sizeof(AVPacket));
-- 
2.17.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/2] avcodec/dvenc: dv100_weight_shift never used

2021-01-04 Thread Peter Ross
---
 libavcodec/dvenc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c
index 0dc290642e..233e2b68c7 100644
--- a/libavcodec/dvenc.c
+++ b/libavcodec/dvenc.c
@@ -318,9 +318,8 @@ static const int dv100_qstep_inv[16] = {
 65536,  65536,  32768,  21845,  16384,  13107,  10923,  9362,  8192,  
4096,  3641,  3277,  2979,  2731,  2341,  1260,
 };
 
-/* DV100 weights are pre-zigzagged, inverted and multiplied by 
2^(dv100_weight_shift)
+/* DV100 weights are pre-zigzagged, inverted and multiplied by 2^16
(in DV100 the AC components are divided by the spec weights) */
-static const int dv100_weight_shift = 16;
 static const int dv_weight_1080[2][64] = {
 { 8192, 65536, 65536, 61681, 61681, 61681, 58254, 58254,
   58254, 58254, 58254, 58254, 55188, 58254, 58254, 55188,
-- 
2.29.2

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/2] avfilter/vf_waveform: flat_pix_fmts never used

2021-01-04 Thread Peter Ross
---
 libavfilter/vf_waveform.c | 7 ---
 1 file changed, 7 deletions(-)

diff --git a/libavfilter/vf_waveform.c b/libavfilter/vf_waveform.c
index 11f8c0016e..8191da2792 100644
--- a/libavfilter/vf_waveform.c
+++ b/libavfilter/vf_waveform.c
@@ -303,13 +303,6 @@ static const enum AVPixelFormat 
out_gray12_lowpass_pix_fmts[] = {
 AV_PIX_FMT_NONE
 };
 
-static const enum AVPixelFormat flat_pix_fmts[] = {
-AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUVJ444P,
-AV_PIX_FMT_YUV444P9, AV_PIX_FMT_YUV444P10,
-AV_PIX_FMT_YUV444P12,
-AV_PIX_FMT_NONE
-};
-
 static int query_formats(AVFilterContext *ctx)
 {
 WaveformContext *s = ctx->priv;
-- 
2.29.2

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v4 1/2] lavf/qsv: Add functions to print mfx iopattern, warning and error

2021-01-04 Thread Haihao Xiang
It is a copy of the relevant part in lavc/qsv but use different function
names to avoid multiple definition when linking lavc and lavf statically.

Signed-off-by: Haihao Xiang 
---
v4: rename the new functions to avoid multiple definition

 libavfilter/qsvvpp.c | 104 +++
 libavfilter/qsvvpp.h |   9 
 2 files changed, 113 insertions(+)

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index 8d5ff2eb65..b31082db03 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -76,6 +76,110 @@ static const mfxHandleType handle_types[] = {
 
 static const AVRational default_tb = { 1, 9 };
 
+static const struct {
+int mfx_iopattern;
+const char *desc;
+} qsv_iopatterns[] = {
+{MFX_IOPATTERN_IN_VIDEO_MEMORY, "input is video memory surface"
 },
+{MFX_IOPATTERN_IN_SYSTEM_MEMORY,"input is system memory surface"   
 },
+{MFX_IOPATTERN_IN_OPAQUE_MEMORY,"input is opaque memory surface"   
 },
+{MFX_IOPATTERN_OUT_VIDEO_MEMORY,"output is video memory surface"   
 },
+{MFX_IOPATTERN_OUT_SYSTEM_MEMORY,   "output is system memory surface"  
 },
+{MFX_IOPATTERN_OUT_OPAQUE_MEMORY,   "output is opaque memory surface"  
 },
+};
+
+int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern,
+  const char *extra_string)
+{
+const char *desc = NULL;
+
+for (int i = 0; i < FF_ARRAY_ELEMS(qsv_iopatterns); i++) {
+if (qsv_iopatterns[i].mfx_iopattern == mfx_iopattern) {
+desc = qsv_iopatterns[i].desc;
+}
+}
+if (!desc)
+desc = "unknown iopattern";
+
+av_log(log_ctx, AV_LOG_VERBOSE, "%s: %s\n", extra_string, desc);
+return 0;
+}
+
+static const struct {
+mfxStatus   mfxerr;
+int averr;
+const char *desc;
+} qsv_errors[] = {
+{ MFX_ERR_NONE, 0,   "success" 
 },
+{ MFX_ERR_UNKNOWN,  AVERROR_UNKNOWN, "unknown error"   
 },
+{ MFX_ERR_NULL_PTR, AVERROR(EINVAL), "NULL pointer"
 },
+{ MFX_ERR_UNSUPPORTED,  AVERROR(ENOSYS), "unsupported" 
 },
+{ MFX_ERR_MEMORY_ALLOC, AVERROR(ENOMEM), "failed to allocate 
memory"},
+{ MFX_ERR_NOT_ENOUGH_BUFFER,AVERROR(ENOMEM), "insufficient 
input/output buffer" },
+{ MFX_ERR_INVALID_HANDLE,   AVERROR(EINVAL), "invalid handle"  
 },
+{ MFX_ERR_LOCK_MEMORY,  AVERROR(EIO),"failed to lock the 
memory block"  },
+{ MFX_ERR_NOT_INITIALIZED,  AVERROR_BUG, "not initialized" 
 },
+{ MFX_ERR_NOT_FOUND,AVERROR(ENOSYS), "specified object was 
not found"   },
+/* the following 3 errors should always be handled explicitly, so those 
"mappings"
+ * are for completeness only */
+{ MFX_ERR_MORE_DATA,AVERROR_UNKNOWN, "expect more data at 
input"},
+{ MFX_ERR_MORE_SURFACE, AVERROR_UNKNOWN, "expect more surface 
at output"},
+{ MFX_ERR_MORE_BITSTREAM,   AVERROR_UNKNOWN, "expect more 
bitstream at output"  },
+{ MFX_ERR_ABORTED,  AVERROR_UNKNOWN, "operation aborted"   
 },
+{ MFX_ERR_DEVICE_LOST,  AVERROR(EIO),"device lost" 
 },
+{ MFX_ERR_INCOMPATIBLE_VIDEO_PARAM, AVERROR(EINVAL), "incompatible video 
parameters"},
+{ MFX_ERR_INVALID_VIDEO_PARAM,  AVERROR(EINVAL), "invalid video 
parameters" },
+{ MFX_ERR_UNDEFINED_BEHAVIOR,   AVERROR_BUG, "undefined behavior"  
 },
+{ MFX_ERR_DEVICE_FAILED,AVERROR(EIO),"device failed"   
 },
+{ MFX_ERR_INCOMPATIBLE_AUDIO_PARAM, AVERROR(EINVAL), "incompatible audio 
parameters"},
+{ MFX_ERR_INVALID_AUDIO_PARAM,  AVERROR(EINVAL), "invalid audio 
parameters" },
+
+{ MFX_WRN_IN_EXECUTION, 0,   "operation in 
execution"   },
+{ MFX_WRN_DEVICE_BUSY,  0,   "device busy" 
 },
+{ MFX_WRN_VIDEO_PARAM_CHANGED,  0,   "video parameters 
changed" },
+{ MFX_WRN_PARTIAL_ACCELERATION, 0,   "partial 
acceleration" },
+{ MFX_WRN_INCOMPATIBLE_VIDEO_PARAM, 0,   "incompatible video 
parameters"},
+{ MFX_WRN_VALUE_NOT_CHANGED,0,   "value is saturated"  
 },
+{ MFX_WRN_OUT_OF_RANGE, 0,   "value out of range"  
 },
+{ MFX_WRN_FILTER_SKIPPED,   0,   "filter skipped"  
 },
+{ MFX_WRN_INCOMPATIBLE_AUDIO_PARAM, 0,   "incompatible a

[FFmpeg-devel] [PATCH v4 2/2] qsv: dump more info in error, debug and verbose mode

2021-01-04 Thread Haihao Xiang
Dump iopattern mode and the SDK error/warning desciptions for qsv based
filters and iopattern mode for qsvenc

Signed-off-by: Haihao Xiang 
---
 libavcodec/qsvenc.c  |  1 +
 libavfilter/qsvvpp.c | 21 +--
 libavfilter/vf_deinterlace_qsv.c | 36 +++-
 libavfilter/vf_scale_qsv.c   | 30 +++---
 4 files changed, 64 insertions(+), 24 deletions(-)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 2bd2a56227..566a5c8552 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -1132,6 +1132,7 @@ int ff_qsv_enc_init(AVCodecContext *avctx, QSVEncContext 
*q)
 if (!iopattern)
 iopattern = MFX_IOPATTERN_IN_SYSTEM_MEMORY;
 q->param.IOPattern = iopattern;
+ff_qsv_print_iopattern(avctx, iopattern, "Encoder");
 
 ret = qsvenc_init_session(avctx, q);
 if (ret < 0)
diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index b31082db03..f216b3f248 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -609,15 +609,19 @@ static int init_vpp_session(AVFilterContext *avctx, 
QSVVPPContext *s)
 }
 }
 
-if (ret != MFX_ERR_NONE) {
-av_log(avctx, AV_LOG_ERROR, "Error getting the session handle\n");
+if (ret < 0)
+return ff_qsvvpp_print_error(avctx, ret, "Error getting the session 
handle");
+else if (ret > 0) {
+ff_qsvvpp_print_warning(avctx, ret, "Warning in getting the session 
handle");
 return AVERROR_UNKNOWN;
 }
 
 /* create a "slave" session with those same properties, to be used for vpp 
*/
 ret = MFXInit(impl, &ver, &s->session);
-if (ret != MFX_ERR_NONE) {
-av_log(avctx, AV_LOG_ERROR, "Error initializing a session for 
scaling\n");
+if (ret < 0)
+return ff_qsvvpp_print_error(avctx, ret, "Error initializing a 
session");
+else if (ret > 0) {
+ff_qsvvpp_print_warning(avctx, ret, "Warning in session 
initialization");
 return AVERROR_UNKNOWN;
 }
 
@@ -750,11 +754,16 @@ int ff_qsvvpp_create(AVFilterContext *avctx, 
QSVVPPContext **vpp, QSVVPPParam *p
 else if (IS_OPAQUE_MEMORY(s->out_mem_mode))
 s->vpp_param.IOPattern |= MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
 
+/* Print input memory mode */
+ff_qsvvpp_print_iopattern(avctx, s->vpp_param.IOPattern & 0x0F, "VPP");
+/* Print output memory mode */
+ff_qsvvpp_print_iopattern(avctx, s->vpp_param.IOPattern & 0xF0, "VPP");
 ret = MFXVideoVPP_Init(s->session, &s->vpp_param);
 if (ret < 0) {
-av_log(avctx, AV_LOG_ERROR, "Failed to create a qsvvpp, ret = %d.\n", 
ret);
+ret = ff_qsvvpp_print_error(avctx, ret, "Failed to create a qsvvpp");
 goto failed;
-}
+} else if (ret > 0)
+ff_qsvvpp_print_warning(avctx, ret, "Warning When creating qsvvpp");
 
 *vpp = s;
 return 0;
diff --git a/libavfilter/vf_deinterlace_qsv.c b/libavfilter/vf_deinterlace_qsv.c
index 80217c8419..89a282f99e 100644
--- a/libavfilter/vf_deinterlace_qsv.c
+++ b/libavfilter/vf_deinterlace_qsv.c
@@ -202,16 +202,20 @@ static int init_out_session(AVFilterContext *ctx)
 }
 }
 
-if (err != MFX_ERR_NONE) {
-av_log(ctx, AV_LOG_ERROR, "Error getting the session handle\n");
+if (err < 0)
+return ff_qsvvpp_print_error(ctx, err, "Error getting the session 
handle");
+else if (err > 0) {
+ff_qsvvpp_print_warning(ctx, err, "Warning in getting the session 
handle");
 return AVERROR_UNKNOWN;
 }
 
 /* create a "slave" session with those same properties, to be used for
  * actual deinterlacing */
 err = MFXInit(impl, &ver, &s->session);
-if (err != MFX_ERR_NONE) {
-av_log(ctx, AV_LOG_ERROR, "Error initializing a session for 
deinterlacing\n");
+if (err < 0)
+return ff_qsvvpp_print_error(ctx, err, "Error initializing a session 
for deinterlacing");
+else if (err > 0) {
+ff_qsvvpp_print_warning(ctx, err, "Warning in session initialization");
 return AVERROR_UNKNOWN;
 }
 
@@ -309,9 +313,17 @@ static int init_out_session(AVFilterContext *ctx)
 par.vpp.Out.FrameRateExtD = ctx->outputs[0]->time_base.den;
 }
 
+/* Print input memory mode */
+ff_qsvvpp_print_iopattern(ctx, par.IOPattern & 0x0F, "VPP");
+/* Print output memory mode */
+ff_qsvvpp_print_iopattern(ctx, par.IOPattern & 0xF0, "VPP");
 err = MFXVideoVPP_Init(s->session, &par);
-if (err != MFX_ERR_NONE) {
-av_log(ctx, AV_LOG_ERROR, "Error opening the VPP for deinterlacing: 
%d\n", err);
+if (err < 0)
+return ff_qsvvpp_print_error(ctx, err,
+ "Error opening the VPP for 
deinterlacing");
+else if (err > 0) {
+ff_qsvvpp_print_warning(ctx, err,
+"Warning in VPP initialization");
 return AVERROR_UNKNOWN;
 }
 
@@ -482,8 +494,13 @@ static int process_frame(AVFilterContext *ctx, const 
AVFrame *in,