[FFmpeg-devel] [PATCH] libavfilter/vf_dnn_detect: bbox index may bigger than bbox number

2023-07-16 Thread wenbin . chen-at-intel . com
From: Wenbin Chen 

Fix a bug that queried bbox index may bigger than bbox's total number.

Signed-off-by: Wenbin Chen 
---
 libavfilter/vf_dnn_detect.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c
index 06efce02a6..6ef04e0958 100644
--- a/libavfilter/vf_dnn_detect.c
+++ b/libavfilter/vf_dnn_detect.c
@@ -106,12 +106,11 @@ static int dnn_detect_post_proc_ov(AVFrame *frame, 
DNNData *output, AVFilterCont
 float x1 =  detections[i * detect_size + 5];
 float y1 =  detections[i * detect_size + 6];
 
-bbox = av_get_detection_bbox(header, i);
-
 if (conf < conf_threshold) {
 continue;
 }
 
+bbox = av_get_detection_bbox(header, header->nb_bboxes - nb_bboxes);
 bbox->x = (int)(x0 * frame->width);
 bbox->w = (int)(x1 * frame->width) - bbox->x;
 bbox->y = (int)(y0 * frame->height);
-- 
2.34.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/7] checkasm: use pointers for start/stop functions

2023-07-16 Thread Rémi Denis-Courmont
Le sunnuntaina 16. heinäkuuta 2023, 23.32.21 EEST Lynne a écrit :
> Introducing additional overhead in the form of a dereference is a point
> where instability can creep in. Can you guarantee that a context will
> always remain in L1D cache,

L1D is not involved here. In version 2, the pointers are cached locally.

> as opposed to just reading the raw CPU timing
> directly where that's supported.

Of course not. Raw CPU timing is subject to noise from interrupts (and 
whatever those interrupts trigger). And that's not just theoretical. I've 
experienced it and it sucks. Raw CPU timing is much noisier than Linux perf.

And because it has also been proven vastly insecure, it's been disabled on Arm 
for a long time, and is being disabled on RISC-V too now.

> > But I still argue that that is, either way, completely negligible compared
> > to the *existing* overhead. Each loop is making 4 system calls, and each
> > of those system call requires a direct call (to PLT) and an indirect
> > branch (from GOT). If you have a problem with the two additional function
> > calls, then you can't be using Linux perf in the first place.
> 
> You don't want to ever use linux perf in the first place, it's second class.

No it isn't. The interface is more involved than just reading a CSR; and sure 
I'd prefer the simple interface that RDCYCLE is all other things being equal. 
But other things are not equal. Linux perf is in fact *more* accurate by 
virtue of not *wrongly* counting other things. And it does not threaten the 
security of the entire system, so it will work inside a rented VM or an 
unprivileged process.

> I don't think it's worth changing the direct inlining we had before. You're
> not interested in whether or not the same exact code is ran between
> platforms,

Err, I am definitely interested in doing exactly that. I don't want to have to 
reconfigure and recompile the entire FFmpeg just to switch between Linux perf 
and raw cycle counter. A contrario, I *do* want to compare performance between 
vendors once the hardware is available.

> just that the code that's measuring timing is as efficient and
> low overhead as possible.

Of course not. Low overhead is irrelevant here. The measurement overhead is 
know and is subtracted. What we need is stable/reproducible overhead, and 
accurate measurements.

And that's assuming the stuff works at all. You can argue that we should use 
Arm PMU and RISC-V RDCYCLE, and that Linux perf sucks, all you want. PMU 
access will just throw a SIGILL and end the checkasm process with zero 
measurements. The rest of the industry wants to use system calls for informed 
reasons. I don't think you, or even the whole FFmpeg project, can win that 
argument against OS and CPU vendors.

-- 
Rémi Denis-Courmont
http://www.remlab.net/



___
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 7/7] avradio/sdr: workaround inverted gain parameter on sdrplay

2023-07-16 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/sdr.h| 1 +
 libavradio/sdrdemux.c   | 1 +
 libavradio/sdrinradio.c | 7 +++
 3 files changed, 9 insertions(+)

diff --git a/libavradio/sdr.h b/libavradio/sdr.h
index 395b056531..27ec1db4f3 100644
--- a/libavradio/sdr.h
+++ b/libavradio/sdr.h
@@ -257,6 +257,7 @@ typedef struct SDRContext {
 int missing_streams;
 
 int rtlsdr_fixes;
+int sdrplay_fixes;
 } SDRContext;
 
 typedef struct ModulationDescriptor {
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 5214aea7be..1b3061a406 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -2180,6 +2180,7 @@ const AVOption ff_sdr_options[] = {
 
 { "driver"  , "sdr driver name"  , OFFSET(driver_name), 
AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC},
 { "rtlsdr_fixes" , "workaround rtlsdr issues", OFFSET(rtlsdr_fixes), 
AV_OPT_TYPE_INT , {.i64 = -1}, -1, 1, DEC},
+{ "sdrplay_fixes" , "workaround sdrplay issues", OFFSET(sdrplay_fixes), 
AV_OPT_TYPE_INT , {.i64 = -1}, -1, 1, DEC},
 { "sdr_sr"  , "sdr sample rate"  , OFFSET(sdr_sample_rate ), 
AV_OPT_TYPE_INT , {.i64 = 0}, 0, INT_MAX, DEC},
 { "sdr_freq", "sdr frequency", OFFSET(wanted_freq), AV_OPT_TYPE_INT64 
, {.i64 = 900}, 0, INT64_MAX, DEC},
 { "gain" , "sdr overall gain",  OFFSET(sdr_gain),  AV_OPT_TYPE_INT , {.i64 
=  GAIN_SDR_AGC}, -3, INT_MAX, DEC, "gain"},
diff --git a/libavradio/sdrinradio.c b/libavradio/sdrinradio.c
index 63a9cade78..f824a1d190 100644
--- a/libavradio/sdrinradio.c
+++ b/libavradio/sdrinradio.c
@@ -76,6 +76,11 @@ static int sdrindev_set_gain_callback(SDRContext *sdr, float 
gain)
 if (sdr->sdr_gain == GAIN_DEFAULT)
 return 0;
 
+//sdrplay has a inverted gain range, not using max_gain as this is a user 
parameter
+if (sdr->sdrplay_fixes > 0) {
+gain = FFMIN(48 - gain, 45);
+}
+
 if (soapy) {
 int ret = SoapySDRDevice_setGainMode(soapy, SOAPY_SDR_RX, 0, 
sdr->sdr_gain == GAIN_SDR_AGC);
 if (ret) {
@@ -192,6 +197,8 @@ static int sdrindev_initial_hw_setup(AVFormatContext *s)
 
 if (sdr->rtlsdr_fixes < 0)
 sdr->rtlsdr_fixes = !strcmp(sdr->driver_name, "rtlsdr");
+if (sdr->sdrplay_fixes < 0)
+sdr->sdrplay_fixes = !strcmp(sdr->driver_name, "sdrplay");
 
 SoapySDRKwargs_set(, "driver", sdr->driver_name);
 sdr->soapy = soapy = SoapySDRDevice_make();
-- 
2.31.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 6/7] avradio/sdr: Support setting gain value manually and automatic

2023-07-16 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/sdr.h| 23 +-
 libavradio/sdrdemux.c   | 53 -
 libavradio/sdrinradio.c | 41 +--
 3 files changed, 113 insertions(+), 4 deletions(-)

diff --git a/libavradio/sdr.h b/libavradio/sdr.h
index dc20415457..395b056531 100644
--- a/libavradio/sdr.h
+++ b/libavradio/sdr.h
@@ -68,6 +68,12 @@ typedef enum Modulation {
 //QAM, PSK, ...
 } Modulation;
 
+typedef enum SDR_GAIN {
+GAIN_DEFAULT = -3,
+GAIN_SW_AGC = -2,
+GAIN_SDR_AGC = -1,
+} SDR_GAIN;
+
 #define HISTOGRAMM_SIZE 9
 
 typedef struct Station {
@@ -105,6 +111,7 @@ typedef struct Station {
 
 typedef struct FIFOElement {
 int64_t center_frequency;
+float gain;
 void *halfblock;
 } FIFOElement;
 
@@ -146,7 +153,15 @@ typedef struct SDRContext {
 int64_t min_center_freq;
 int64_t max_center_freq;
 int sdr_sample_rate;
-int sdr_agc;
+float min_gain;
+float max_gain;
+int sdr_gain;
+float agc_min_headroom;
+float agc_max_headroom;
+float agc_max_headroom_time;
+int agc_low_time;
+float agc_gain; ///< current gain, should be 
accessed only by buffer thread after init
+atomic_int wanted_gain;
 int sdr_adcc;
 int64_t bandwidth;
 int64_t last_pts;
@@ -212,6 +227,12 @@ typedef struct SDRContext {
  */
 int64_t (*set_frequency_callback)(struct SDRContext *sdr, int64_t 
frequency);
 
+/**
+ * Setup the hardware for the requested gain
+ * This must only be called from the buffer thread after setup (or more 
mutex calls are needed)
+ */
+int (*set_gain_callback)(struct SDRContext *sdr, float gain);
+
 /**
  * Read from the hardware, block if nothing available with a reasonable 
timeout
  *
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index a0b80785ef..5214aea7be 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1409,6 +1409,7 @@ static void *soapy_needs_bigger_buffers_worker(SDRContext 
*sdr)
 FIFOElement fifo_element;
 int remaining, ret;
 int empty_blocks, full_blocks;
+float wanted_gain = atomic_load(>wanted_gain) / 65536.0;
 
 //i wish av_fifo was thread safe
 pthread_mutex_lock(>mutex);
@@ -1444,9 +1445,17 @@ static void 
*soapy_needs_bigger_buffers_worker(SDRContext *sdr)
 //And theres not much else we can do, an error message was already 
printed by ff_sdr_set_freq() in that case
 block_counter = 0; // we just changed the frequency, do not trust 
the next blocks content
 }
+if (sdr->sdr_gain == GAIN_SW_AGC &&
+fabs(wanted_gain - sdr->agc_gain) > 0.001 &&
+sdr->set_gain_callback
+) {
+sdr->set_gain_callback(sdr, wanted_gain);
+sdr->agc_gain = wanted_gain;
+}
 pthread_mutex_unlock(>mutex);
 
 fifo_element.center_frequency = block_counter > 0 ? sdr->freq : 0;
+fifo_element.gain = sdr->agc_gain; //we make only small 
changes so slightly mixing should be ok
 
 remaining = sdr->block_size;
 while (remaining && !atomic_load(>close_requested)) {
@@ -1624,6 +1633,7 @@ int ff_sdr_common_init(AVFormatContext *s)
 av_fifo_auto_grow_limit(sdr-> full_block_fifo, sdr->sdr_sample_rate / 
sdr->block_size);
 
 atomic_init(>close_requested, 0);
+atomic_init(>wanted_gain, lrint((sdr->min_gain + sdr->max_gain) * 
65536 / 2));
 ret = pthread_mutex_init(>mutex, NULL);
 if (ret) {
 av_log(s, AV_LOG_ERROR, "pthread_mutex_init failed: %s\n", 
strerror(ret));
@@ -1886,6 +1896,37 @@ process_next_block:
 }
 }
 
+float smaller_block_gain = FFMIN(fifo_element[0].gain, 
fifo_element[1].gain);
+float  bigger_block_gain = FFMAX(fifo_element[0].gain, 
fifo_element[1].gain);
+
+if (sdr->sdr_gain == GAIN_SW_AGC) {
+float inmax = 0;
+float wanted_gain = atomic_load(>wanted_gain) / 65536.0;
+// We only check 25% of the data to safe computations
+int start = 3*sdr->block_size / 4;
+int end   = 5*sdr->block_size / 4;
+for (i = start; i < end; i++) {
+float v = fmaxf(fabsf(sdr->windowed_block[i].re), 
fabsf(sdr->windowed_block[i].im));
+inmax = fmaxf(inmax, v);
+}
+
+if (inmax > 1.0 - sdr->agc_min_headroom && wanted_gain > 
sdr->min_gain) {
+//according to docs this is a dB scale, in reality it beheaves 
differnt to that
+//Because of this we will try to just make small changes and not 
assume too much
+wanted_gain = FFMIN(wanted_gain, FFMAX(smaller_block_gain - 1.0, 
smaller_block_gain * 0.9));
+
+sdr->agc_low_time = 0;
+} else if (inmax < 1.0 - sdr->agc_max_headroom && wanted_gain < 
sdr->max_gain) {
+sdr->agc_low_time += sdr->block_size;
+if (sdr->agc_low_time > 

[FFmpeg-devel] [PATCH 5/7] avradio/sdrdemux: adjust bandwidth to 200khz for FM probing

2023-07-16 Thread Michael Niedermayer
This improves the local noise floor value

Signed-off-by: Michael Niedermayer 
---
 libavradio/sdrdemux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index a4c590acf2..a0b80785ef 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -860,7 +860,7 @@ static int probe_fm(SDRContext *sdr)
 {
 int i;
 int bandwidth_f  = sdr->fm_bandwidth;
-int half_bw_i = bandwidth_f * (int64_t)sdr->block_size / 
sdr->sdr_sample_rate;
+int half_bw_i = 200*1000 * (int64_t)sdr->block_size / sdr->sdr_sample_rate;
 int floor_bw_i = 10*1000 * (int64_t)sdr->block_size / sdr->sdr_sample_rate;
 float last_score[3] = {FLT_MAX, FLT_MAX, FLT_MAX};
 int border_i = (sdr->sdr_sample_rate - FFMIN(sdr->bandwidth, 
sdr->sdr_sample_rate*7/8)) * sdr->block_size / sdr->sdr_sample_rate;
-- 
2.31.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 4/7] avradio/sdrdemux: Use a local noise floor in FM Probing

2023-07-16 Thread Michael Niedermayer
The global one caused problems when the spectrum is not flat

Signed-off-by: Michael Niedermayer 
---
 libavradio/sdrdemux.c | 33 +
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 5a3af23a74..a4c590acf2 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -861,17 +861,20 @@ static int probe_fm(SDRContext *sdr)
 int i;
 int bandwidth_f  = sdr->fm_bandwidth;
 int half_bw_i = bandwidth_f * (int64_t)sdr->block_size / 
sdr->sdr_sample_rate;
+int floor_bw_i = 10*1000 * (int64_t)sdr->block_size / sdr->sdr_sample_rate;
 float last_score[3] = {FLT_MAX, FLT_MAX, FLT_MAX};
 int border_i = (sdr->sdr_sample_rate - FFMIN(sdr->bandwidth, 
sdr->sdr_sample_rate*7/8)) * sdr->block_size / sdr->sdr_sample_rate;
-double noise_floor = FLT_MAX;
 
 if (2*half_bw_i > 2*sdr->block_size)
 return 0;
 
-for (int pass = 0; pass < 2; pass ++) {
+{
 double avg[2] = {0}, tri = 0;
+double floor[2] = {0};
 double mean = 0;
 double center = 0;
+float floor_compensation = half_bw_i * half_bw_i / (float)floor_bw_i;
+
 for (i = 0; ilen2block[i];
 tri+= i*sdr->len2block[i];
@@ -883,12 +886,19 @@ static int probe_fm(SDRContext *sdr)
 mean   += i*sdr->len2block[i];
 }
 
+for (i=0; ilen2block[i];
+for (i=2*half_bw_i - floor_bw_i; i<2*half_bw_i; i++)
+floor[1] += sdr->len2block[i];
+
 for(i = half_bw_i; i<2*sdr->block_size - half_bw_i; i++) {
 double b = avg[0] + sdr->len2block[i];
 avg[0] += sdr->len2block[i] - sdr->len2block[i - half_bw_i];
 avg[1] -= sdr->len2block[i] - sdr->len2block[i + half_bw_i];
 b += avg[1];
 tri += avg[1] - avg[0];
+floor[0] += sdr->len2block[i - half_bw_i + floor_bw_i] - 
sdr->len2block[i - half_bw_i];
+floor[1] -= sdr->len2block[i + half_bw_i - floor_bw_i] - 
sdr->len2block[i + half_bw_i];
 
 mean += (i+half_bw_i)*sdr->len2block[i+half_bw_i];
 center = mean / b;
@@ -897,17 +907,24 @@ static int probe_fm(SDRContext *sdr)
 if (i < border_i || i > 2*sdr->block_size - border_i)
 continue;
 
-if (pass == 0) {
-noise_floor = FFMIN(noise_floor, tri);
-} else {
+{
+float noise_floor;
+if (i - half_bw_i < border_i) {
+noise_floor = floor[1];
+} else if (i + half_bw_i >= 2*sdr->block_size - border_i) {
+noise_floor = floor[0];
+} else
+noise_floor = (floor[0] + floor[1])/2;
+noise_floor *= floor_compensation;
+
 last_score[2] = last_score[1];
 last_score[1] = last_score[0];
-last_score[0] = tri / (noise_floor);
+last_score[0] = tri;
 
 if (last_score[1] >= last_score[0] &&
 last_score[1] > last_score[2] &&
-last_score[1] > sdr->fm_threshold) {
-double score = last_score[1];
+last_score[1] / noise_floor > sdr->fm_threshold) {
+double score = last_score[1] / noise_floor;
 
 float rmax   = max_in_range(sdr, i-half_bw_i/4, 
i+half_bw_i/4);
 int lowcount = countbelow(sdr, i-half_bw_i/4, 
i+half_bw_i/4, rmax / 100);
-- 
2.31.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 3/7] avradio/sdrinradio: Print all tunable elements

2023-07-16 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/sdrinradio.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavradio/sdrinradio.c b/libavradio/sdrinradio.c
index f078d27e7b..3956c18375 100644
--- a/libavradio/sdrinradio.c
+++ b/libavradio/sdrinradio.c
@@ -184,6 +184,10 @@ static int sdrindev_initial_hw_setup(AVFormatContext *s)
 names = SoapySDRDevice_listAntennas(soapy, SOAPY_SDR_RX, 0, );
 print_and_free_list(s, names, length, "Antennas");
 
+//Go over all tunable elements
+names = SoapySDRDevice_listFrequencies(soapy, SOAPY_SDR_RX, 0, );
+print_and_free_list(s, names, length, "Tunables");
+
 //Go over all Gain Elements and print them
 names = SoapySDRDevice_listGains(soapy, SOAPY_SDR_RX, 0, );
 print_and_free_list(s, names, length, "Rx Gain Elements");
-- 
2.31.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 2/7] avradio/sdr: compensate for RTLSDR frequency limitations

2023-07-16 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/sdr.h|  2 +-
 libavradio/sdrdemux.c   |  9 -
 libavradio/sdrinradio.c | 10 --
 3 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/libavradio/sdr.h b/libavradio/sdr.h
index ac6b7dffe0..dc20415457 100644
--- a/libavradio/sdr.h
+++ b/libavradio/sdr.h
@@ -210,7 +210,7 @@ typedef struct SDRContext {
 /**
  * Setup the hardware for the requested frequency
  */
-int (*set_frequency_callback)(struct SDRContext *sdr, int64_t frequency);
+int64_t (*set_frequency_callback)(struct SDRContext *sdr, int64_t 
frequency);
 
 /**
  * Read from the hardware, block if nothing available with a reasonable 
timeout
diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index a545e7cb4c..5a3af23a74 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1129,11 +1129,10 @@ ModulationDescriptor ff_sdr_modulation_descs[] = {
 int ff_sdr_set_freq(SDRContext *sdr, int64_t freq)
 {
 freq = av_clip64(freq, sdr->min_center_freq, sdr->max_center_freq);
-
 if (sdr->set_frequency_callback) {
-int ret = sdr->set_frequency_callback(sdr, freq);
-if (ret < 0)
-return ret;
+freq = sdr->set_frequency_callback(sdr, freq);
+if (freq < 0)
+return freq;
 }
 
 sdr->freq = freq;
@@ -1421,7 +1420,7 @@ static void *soapy_needs_bigger_buffers_worker(SDRContext 
*sdr)
 if (sdr->seek_direction && block_counter > 5) {
 sdr->wanted_freq = snap2band(sdr, sdr->wanted_freq, 
sdr->seek_direction*sdr->bandwidth*0.5);
 }
-if (sdr->wanted_freq != sdr->freq) {
+if (fabs(sdr->wanted_freq - sdr->freq) > 1500) {
 //We could use a seperate MUTEX for the FIFO and for soapy
 ff_sdr_set_freq(sdr, sdr->wanted_freq);
 //This shouldnt really cause any problem if we just continue on 
error except that we continue returning data with the previous target frequency 
range
diff --git a/libavradio/sdrinradio.c b/libavradio/sdrinradio.c
index 0e7442fddf..f078d27e7b 100644
--- a/libavradio/sdrinradio.c
+++ b/libavradio/sdrinradio.c
@@ -68,7 +68,7 @@ static int sdrindev_read_callback(SDRContext *sdr, 
FIFOElement *fifo_element, in
 return ret;
 }
 
-static int sdrindev_set_frequency_callback(SDRContext *sdr, int64_t freq)
+static int64_t sdrindev_set_frequency_callback(SDRContext *sdr, int64_t freq)
 {
 AVFormatContext *avfmt = sdr->avfmt;
 SoapySDRDevice *soapy = sdr->soapy;
@@ -83,6 +83,12 @@ static int sdrindev_set_frequency_callback(SDRContext *sdr, 
int64_t freq)
 } else
 sdr->current_direct_samp = value;
 }
+//The R820T has a 16 bit fractional PLL which can do only 
multiplies of 439.45
+//Its more complex but this approximation works
+//It has to be noted that SOAPY does not tell us about this, 
instead saopy
+//pretends whatever we ask for we get exactly, but we dont
+//For more details see: 
michelebavaro.blogspot.com/2014/05/gnss-carrier-phase-rtlsdr-and.html
+freq = lrint(freq / 439.45) * 439.45;
 }
 
 if (SoapySDRDevice_setFrequency(soapy, SOAPY_SDR_RX, 0, freq, NULL) != 
0) {
@@ -90,7 +96,7 @@ static int sdrindev_set_frequency_callback(SDRContext *sdr, 
int64_t freq)
 return AVERROR_EXTERNAL;
 }
 }
-return 0;
+return freq;
 }
 
 static void print_and_free_list(AVFormatContext *s, char** names, size_t 
length, const char *title)
-- 
2.31.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/7] avradio/sdrdemux: icarrier just needs phase 2 block size

2023-07-16 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavradio/sdrdemux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavradio/sdrdemux.c b/libavradio/sdrdemux.c
index 5a6a9b8894..a545e7cb4c 100644
--- a/libavradio/sdrdemux.c
+++ b/libavradio/sdrdemux.c
@@ -1543,7 +1543,7 @@ int ff_sdr_common_init(AVFormatContext *s)
 sdr->fm_iside = av_malloc(sizeof(*sdr->fm_iside)* 2 * 
sdr->fm_block_size_p2);
 sdr->fm_block = av_malloc(sizeof(*sdr->fm_block)* 2 * 
sdr->fm_block_size);
 sdr->fm_iblock= av_malloc(sizeof(*sdr->fm_iblock)   * 2 * 
sdr->fm_block_size);
-sdr->fm_icarrier  = av_malloc(sizeof(*sdr->fm_icarrier) * 2 * 
sdr->fm_block_size);
+sdr->fm_icarrier  = av_malloc(sizeof(*sdr->fm_icarrier) * 2 * 
sdr->fm_block_size_p2);
 sdr->fm_window= av_malloc(sizeof(*sdr->fm_window)   * 2 * 
sdr->fm_block_size);
 
 if (!sdr->windowed_block || !sdr->len2block || !sdr->block || !sdr->window 
|| !sdr->fm_window_p2 || !sdr->fm_iside ||
-- 
2.31.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] avcodec/cbs_h2645: Replace parameter sets generically

2023-07-16 Thread Andreas Rheinhardt
James Almer:
> On 7/16/2023 6:18 PM, Andreas Rheinhardt wrote:
>> This avoids having a function for each type of parameter set
>> for each of the modules.
>>
>> Signed-off-by: Andreas Rheinhardt 
>> ---
>>   libavcodec/cbs_h2645.c | 134 ++---
>>   1 file changed, 72 insertions(+), 62 deletions(-)
>>
>> diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
>> index 34c5d1d372..5bbd74b977 100644
>> --- a/libavcodec/cbs_h2645.c
>> +++ b/libavcodec/cbs_h2645.c
>> @@ -736,55 +736,65 @@ static int
>> cbs_h2645_split_fragment(CodedBitstreamContext *ctx,
>>   return 0;
>>   }
>>   -#define cbs_h2645_replace_ps(h26n, ps_name, ps_var, id_element) \
>> -static int cbs_h26 ## h26n ## _replace_ ##
>> ps_var(CodedBitstreamContext *ctx, \
>> -  CodedBitstreamUnit
>> *unit)  \
>> -{ \
>> -    CodedBitstreamH26 ## h26n ## Context *priv = ctx->priv_data; \
>> -    H26 ## h26n ## Raw ## ps_name *ps_var = unit->content; \
>> -    unsigned int id = ps_var->id_element; \
>> -    int err = ff_cbs_make_unit_refcounted(ctx, unit); \
>> -    if (err < 0) \
>> -    return err; \
>> -    if (priv->ps_var[id] == priv->active_ ## ps_var) \
>> -    priv->active_ ## ps_var = NULL ; \
>> -    av_buffer_unref(>ps_var ## _ref[id]); \
>> -    av_assert0(unit->content_ref); \
>> -    priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \
>> -    if (!priv->ps_var ## _ref[id]) \
>> -    return AVERROR(ENOMEM); \
>> -    priv->ps_var[id] = (H26 ## h26n ## Raw ## ps_name *)priv->ps_var
>> ## _ref[id]->data; \
>> -    return 0; \
>> +typedef struct PSOffsets {
>> +    unsigned id_element_offset;    //< relative to the raw parameter
>> set struct; must refer to uint8_t
>> +    unsigned ps_array_offset;  //< relative to
>> CodedBitstreamH26*Context
>> +    unsigned ps_ref_array_offset;  //< relative to
>> CodedBitstreamH26*Context
>> +    unsigned active_ps_offset; //< Zero means that active PS is
>> unused
>> +} PSOffsets;
>> +
>> +#define CBS_H26456_OFFSET_TABLE(MODULE, module, PS_NAME, ps_var,
>> id_element, _active_ps_offset)   \
>> +static const PSOffsets module ## _ ## ps_var ## _offsets =
>> {  \
>> +    .id_element_offset   = offsetof(MODULE ## Raw ## PS_NAME,
>> id_element),    \
>> +    .ps_array_offset = offsetof(CodedBitstream ## MODULE ##
>> Context, ps_var), \
>> +    .ps_ref_array_offset = offsetof(CodedBitstream ## MODULE ##
>> Context, ps_var ## _ref), \
>> +    .active_ps_offset    =
>> _active_ps_offset, \
>>   }
>>   -cbs_h2645_replace_ps(4, SPS, sps, seq_parameter_set_id)
>> -cbs_h2645_replace_ps(4, PPS, pps, pic_parameter_set_id)
>> -cbs_h2645_replace_ps(5, VPS, vps, vps_video_parameter_set_id)
>> -cbs_h2645_replace_ps(5, SPS, sps, sps_seq_parameter_set_id)
>> -cbs_h2645_replace_ps(5, PPS, pps, pps_pic_parameter_set_id)
>> -
>> -#define cbs_h266_replace_ps(h26n, ps_name, ps_var, id_element) \
>> -static int cbs_h26 ## h26n ## _replace_ ##
>> ps_var(CodedBitstreamContext *ctx, \
>> -  CodedBitstreamUnit
>> *unit)  \
>> -{ \
>> -    CodedBitstreamH26 ## h26n ## Context *priv = ctx->priv_data; \
>> -    H26 ## h26n ## Raw ## ps_name *ps_var = unit->content; \
>> -    unsigned int id = ps_var->id_element; \
>> -    int err = ff_cbs_make_unit_refcounted(ctx, unit); \
>> -    if (err < 0) \
>> -    return err; \
>> -    av_buffer_unref(>ps_var ## _ref[id]); \
>> -    av_assert0(unit->content_ref); \
>> -    priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \
>> -    if (!priv->ps_var ## _ref[id]) \
>> -    return AVERROR(ENOMEM); \
>> -    priv->ps_var[id] = (H26 ## h26n ## Raw ## ps_name *)priv->ps_var
>> ## _ref[id]->data; \
>> -    return 0; \
>> -}
>> +#define CBS_H2645_OFFSET_TABLE(h26n, PS_NAME, ps_var, id_element)    \
>> +    CBS_H26456_OFFSET_TABLE(H26 ## h26n, h26 ## h26n, PS_NAME,
>> ps_var, id_element,   \
>> +    offsetof(CodedBitstreamH26 ## h26n ##
>> Context, active_ ## ps_var))
>> +
>> +CBS_H2645_OFFSET_TABLE(4, SPS, sps, seq_parameter_set_id);
>> +CBS_H2645_OFFSET_TABLE(4, PPS, pps, pic_parameter_set_id);
>> +CBS_H2645_OFFSET_TABLE(5, VPS, vps, vps_video_parameter_set_id);
>> +CBS_H2645_OFFSET_TABLE(5, SPS, sps, sps_seq_parameter_set_id);
>> +CBS_H2645_OFFSET_TABLE(5, PPS, pps, pps_pic_parameter_set_id);
>> +
>> +#define CBS_H266_OFFSET_TABLE(PS_NAME, ps_var, id_element) \
>> +    CBS_H26456_OFFSET_TABLE(H266, h266, PS_NAME, ps_var,
>> id_element, 0)
>> +
>> +CBS_H266_OFFSET_TABLE(VPS, vps, vps_video_parameter_set_id);
>> +CBS_H266_OFFSET_TABLE(SPS, sps, sps_seq_parameter_set_id);
>> +CBS_H266_OFFSET_TABLE(PPS, pps, pps_pic_parameter_set_id);
>> +
>> +static int cbs_h26456_replace_ps(CodedBitstreamContext *ctx,
>> CodedBitstreamUnit *unit,
> 
> nit: it might be a good idea to rename the module 

Re: [FFmpeg-devel] [PATCH] avcodec/cbs_h2645: Replace parameter sets generically

2023-07-16 Thread James Almer

On 7/16/2023 6:18 PM, Andreas Rheinhardt wrote:

This avoids having a function for each type of parameter set
for each of the modules.

Signed-off-by: Andreas Rheinhardt 
---
  libavcodec/cbs_h2645.c | 134 ++---
  1 file changed, 72 insertions(+), 62 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 34c5d1d372..5bbd74b977 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -736,55 +736,65 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext 
*ctx,
  return 0;
  }
  
-#define cbs_h2645_replace_ps(h26n, ps_name, ps_var, id_element) \

-static int cbs_h26 ## h26n ## _replace_ ## ps_var(CodedBitstreamContext *ctx, \
-  CodedBitstreamUnit *unit)  \
-{ \
-CodedBitstreamH26 ## h26n ## Context *priv = ctx->priv_data; \
-H26 ## h26n ## Raw ## ps_name *ps_var = unit->content; \
-unsigned int id = ps_var->id_element; \
-int err = ff_cbs_make_unit_refcounted(ctx, unit); \
-if (err < 0) \
-return err; \
-if (priv->ps_var[id] == priv->active_ ## ps_var) \
-priv->active_ ## ps_var = NULL ; \
-av_buffer_unref(>ps_var ## _ref[id]); \
-av_assert0(unit->content_ref); \
-priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \
-if (!priv->ps_var ## _ref[id]) \
-return AVERROR(ENOMEM); \
-priv->ps_var[id] = (H26 ## h26n ## Raw ## ps_name *)priv->ps_var ## 
_ref[id]->data; \
-return 0; \
+typedef struct PSOffsets {
+unsigned id_element_offset;//< relative to the raw parameter set 
struct; must refer to uint8_t
+unsigned ps_array_offset;  //< relative to CodedBitstreamH26*Context
+unsigned ps_ref_array_offset;  //< relative to CodedBitstreamH26*Context
+unsigned active_ps_offset; //< Zero means that active PS is unused
+} PSOffsets;
+
+#define CBS_H26456_OFFSET_TABLE(MODULE, module, PS_NAME, ps_var, id_element, 
_active_ps_offset)   \
+static const PSOffsets module ## _ ## ps_var ## _offsets = {   
   \
+.id_element_offset   = offsetof(MODULE ## Raw ## PS_NAME, id_element), 
   \
+.ps_array_offset = offsetof(CodedBitstream ## MODULE ## Context, 
ps_var), \
+.ps_ref_array_offset = offsetof(CodedBitstream ## MODULE ## Context, 
ps_var ## _ref), \
+.active_ps_offset= _active_ps_offset,  
   \
  }
  
-cbs_h2645_replace_ps(4, SPS, sps, seq_parameter_set_id)

-cbs_h2645_replace_ps(4, PPS, pps, pic_parameter_set_id)
-cbs_h2645_replace_ps(5, VPS, vps, vps_video_parameter_set_id)
-cbs_h2645_replace_ps(5, SPS, sps, sps_seq_parameter_set_id)
-cbs_h2645_replace_ps(5, PPS, pps, pps_pic_parameter_set_id)
-
-#define cbs_h266_replace_ps(h26n, ps_name, ps_var, id_element) \
-static int cbs_h26 ## h26n ## _replace_ ## ps_var(CodedBitstreamContext *ctx, \
-  CodedBitstreamUnit *unit)  \
-{ \
-CodedBitstreamH26 ## h26n ## Context *priv = ctx->priv_data; \
-H26 ## h26n ## Raw ## ps_name *ps_var = unit->content; \
-unsigned int id = ps_var->id_element; \
-int err = ff_cbs_make_unit_refcounted(ctx, unit); \
-if (err < 0) \
-return err; \
-av_buffer_unref(>ps_var ## _ref[id]); \
-av_assert0(unit->content_ref); \
-priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \
-if (!priv->ps_var ## _ref[id]) \
-return AVERROR(ENOMEM); \
-priv->ps_var[id] = (H26 ## h26n ## Raw ## ps_name *)priv->ps_var ## 
_ref[id]->data; \
-return 0; \
-}
+#define CBS_H2645_OFFSET_TABLE(h26n, PS_NAME, ps_var, id_element)\
+CBS_H26456_OFFSET_TABLE(H26 ## h26n, h26 ## h26n, PS_NAME, ps_var, 
id_element,   \
+offsetof(CodedBitstreamH26 ## h26n ## Context, 
active_ ## ps_var))
+
+CBS_H2645_OFFSET_TABLE(4, SPS, sps, seq_parameter_set_id);
+CBS_H2645_OFFSET_TABLE(4, PPS, pps, pic_parameter_set_id);
+CBS_H2645_OFFSET_TABLE(5, VPS, vps, vps_video_parameter_set_id);
+CBS_H2645_OFFSET_TABLE(5, SPS, sps, sps_seq_parameter_set_id);
+CBS_H2645_OFFSET_TABLE(5, PPS, pps, pps_pic_parameter_set_id);
+
+#define CBS_H266_OFFSET_TABLE(PS_NAME, ps_var, id_element) \
+CBS_H26456_OFFSET_TABLE(H266, h266, PS_NAME, ps_var, id_element, 0)
+
+CBS_H266_OFFSET_TABLE(VPS, vps, vps_video_parameter_set_id);
+CBS_H266_OFFSET_TABLE(SPS, sps, sps_seq_parameter_set_id);
+CBS_H266_OFFSET_TABLE(PPS, pps, pps_pic_parameter_set_id);
+
+static int cbs_h26456_replace_ps(CodedBitstreamContext *ctx, 
CodedBitstreamUnit *unit,


nit: it might be a good idea to rename the module (and h2645_parse) to 
h26x. Or alternatively, nal.

___
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] avcodec/cbs_h2645: Replace parameter sets generically

2023-07-16 Thread Andreas Rheinhardt
This avoids having a function for each type of parameter set
for each of the modules.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/cbs_h2645.c | 134 ++---
 1 file changed, 72 insertions(+), 62 deletions(-)

diff --git a/libavcodec/cbs_h2645.c b/libavcodec/cbs_h2645.c
index 34c5d1d372..5bbd74b977 100644
--- a/libavcodec/cbs_h2645.c
+++ b/libavcodec/cbs_h2645.c
@@ -736,55 +736,65 @@ static int cbs_h2645_split_fragment(CodedBitstreamContext 
*ctx,
 return 0;
 }
 
-#define cbs_h2645_replace_ps(h26n, ps_name, ps_var, id_element) \
-static int cbs_h26 ## h26n ## _replace_ ## ps_var(CodedBitstreamContext *ctx, \
-  CodedBitstreamUnit *unit)  \
-{ \
-CodedBitstreamH26 ## h26n ## Context *priv = ctx->priv_data; \
-H26 ## h26n ## Raw ## ps_name *ps_var = unit->content; \
-unsigned int id = ps_var->id_element; \
-int err = ff_cbs_make_unit_refcounted(ctx, unit); \
-if (err < 0) \
-return err; \
-if (priv->ps_var[id] == priv->active_ ## ps_var) \
-priv->active_ ## ps_var = NULL ; \
-av_buffer_unref(>ps_var ## _ref[id]); \
-av_assert0(unit->content_ref); \
-priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \
-if (!priv->ps_var ## _ref[id]) \
-return AVERROR(ENOMEM); \
-priv->ps_var[id] = (H26 ## h26n ## Raw ## ps_name *)priv->ps_var ## 
_ref[id]->data; \
-return 0; \
+typedef struct PSOffsets {
+unsigned id_element_offset;//< relative to the raw parameter set 
struct; must refer to uint8_t
+unsigned ps_array_offset;  //< relative to CodedBitstreamH26*Context
+unsigned ps_ref_array_offset;  //< relative to CodedBitstreamH26*Context
+unsigned active_ps_offset; //< Zero means that active PS is unused
+} PSOffsets;
+
+#define CBS_H26456_OFFSET_TABLE(MODULE, module, PS_NAME, ps_var, id_element, 
_active_ps_offset)   \
+static const PSOffsets module ## _ ## ps_var ## _offsets = {   
   \
+.id_element_offset   = offsetof(MODULE ## Raw ## PS_NAME, id_element), 
   \
+.ps_array_offset = offsetof(CodedBitstream ## MODULE ## Context, 
ps_var), \
+.ps_ref_array_offset = offsetof(CodedBitstream ## MODULE ## Context, 
ps_var ## _ref), \
+.active_ps_offset= _active_ps_offset,  
   \
 }
 
-cbs_h2645_replace_ps(4, SPS, sps, seq_parameter_set_id)
-cbs_h2645_replace_ps(4, PPS, pps, pic_parameter_set_id)
-cbs_h2645_replace_ps(5, VPS, vps, vps_video_parameter_set_id)
-cbs_h2645_replace_ps(5, SPS, sps, sps_seq_parameter_set_id)
-cbs_h2645_replace_ps(5, PPS, pps, pps_pic_parameter_set_id)
-
-#define cbs_h266_replace_ps(h26n, ps_name, ps_var, id_element) \
-static int cbs_h26 ## h26n ## _replace_ ## ps_var(CodedBitstreamContext *ctx, \
-  CodedBitstreamUnit *unit)  \
-{ \
-CodedBitstreamH26 ## h26n ## Context *priv = ctx->priv_data; \
-H26 ## h26n ## Raw ## ps_name *ps_var = unit->content; \
-unsigned int id = ps_var->id_element; \
-int err = ff_cbs_make_unit_refcounted(ctx, unit); \
-if (err < 0) \
-return err; \
-av_buffer_unref(>ps_var ## _ref[id]); \
-av_assert0(unit->content_ref); \
-priv->ps_var ## _ref[id] = av_buffer_ref(unit->content_ref); \
-if (!priv->ps_var ## _ref[id]) \
-return AVERROR(ENOMEM); \
-priv->ps_var[id] = (H26 ## h26n ## Raw ## ps_name *)priv->ps_var ## 
_ref[id]->data; \
-return 0; \
-}
+#define CBS_H2645_OFFSET_TABLE(h26n, PS_NAME, ps_var, id_element)\
+CBS_H26456_OFFSET_TABLE(H26 ## h26n, h26 ## h26n, PS_NAME, ps_var, 
id_element,   \
+offsetof(CodedBitstreamH26 ## h26n ## Context, 
active_ ## ps_var))
+
+CBS_H2645_OFFSET_TABLE(4, SPS, sps, seq_parameter_set_id);
+CBS_H2645_OFFSET_TABLE(4, PPS, pps, pic_parameter_set_id);
+CBS_H2645_OFFSET_TABLE(5, VPS, vps, vps_video_parameter_set_id);
+CBS_H2645_OFFSET_TABLE(5, SPS, sps, sps_seq_parameter_set_id);
+CBS_H2645_OFFSET_TABLE(5, PPS, pps, pps_pic_parameter_set_id);
+
+#define CBS_H266_OFFSET_TABLE(PS_NAME, ps_var, id_element) \
+CBS_H26456_OFFSET_TABLE(H266, h266, PS_NAME, ps_var, id_element, 0)
+
+CBS_H266_OFFSET_TABLE(VPS, vps, vps_video_parameter_set_id);
+CBS_H266_OFFSET_TABLE(SPS, sps, sps_seq_parameter_set_id);
+CBS_H266_OFFSET_TABLE(PPS, pps, pps_pic_parameter_set_id);
+
+static int cbs_h26456_replace_ps(CodedBitstreamContext *ctx, 
CodedBitstreamUnit *unit,
+ const PSOffsets *offsets)
+{
+int err = ff_cbs_make_unit_refcounted(ctx, unit);
+unsigned char *priv = ctx->priv_data;
+struct ps **ps_array = (struct ps **)(priv + offsets->ps_array_offset);
+AVBufferRef **ps_ref_array = (AVBufferRef**)(priv + 
offsets->ps_ref_array_offset);
+unsigned id;
+
+if (err < 0)
+return err;
 
-cbs_h266_replace_ps(6, VPS, vps, 

Re: [FFmpeg-devel] [PATCH 4/7] checkasm: use pointers for start/stop functions

2023-07-16 Thread Lynne
Jul 15, 2023, 22:13 by r...@remlab.net:

> Le lauantaina 15. heinäkuuta 2023, 20.43.26 EEST Lynne a écrit :
>
>> Jul 15, 2023, 10:26 by r...@remlab.net:
>> > Le lauantaina 15. heinäkuuta 2023, 11.05.51 EEST Lynne a écrit :
>> >> Jul 14, 2023, 20:29 by r...@remlab.net:
>> >> > This makes all calls to the bench start and stop functions via
>> >> > function pointers. While the primary goal is to support run-time
>> >> > selection of the performance measurement back-end in later commits,
>> >> > this has the side benefit of containing platform dependencies in to
>> >> > checkasm.c and out of checkasm.h.
>> >> > ---
>> >> > 
>> >> >  tests/checkasm/checkasm.c | 33 -
>> >> >  tests/checkasm/checkasm.h | 31 ---
>> >> >  2 files changed, 32 insertions(+), 32 deletions(-)
>> >> 
>> >> Not sure I agree with this commit, the overhead can be detectable,
>> >> and we have a lot of small functions with runtime a few times that
>> >> of a null function call.
>> > 
>> > I don't think the function call is ever null. The pointers are left NULL
>> > only if none of the backend initialise. But then, checkasm will bail out
>> > and exit before we try to benchmark anything anyway.
>> > 
>> > As for the real functions, they always do *something*. None of them "just
>> > return 0".
>>
>> I meant a no-op function call to measure the overhead of function
>> calls themselves, complete with all the ABI stuff.
>>
>
> I
>
>>
>> >> Can you store the function pointers out of the loop to reduce
>> >> the derefs needed?
>> > 
>> > Taking just the two loads is out of the loop should be feasible but it
>> > seems a rather vain. You will still have the overhead of the indirect
>> > function call, the function, and most importantly in the case of Linux
>> > perf and MacOS kperf, the system calls.
>> > 
>> > The only way to avoid the indirect function calls are to use IFUNC (tricky
>> > and not portable), or to make horrible macros to spawn one bench loop for
>> > each backend.
>> > 
>> > In the end, I think we should rather aim for as constant time as possible,
>> > rather than as fast as possible, so that the nop loop can estimate the
>> > benchmarking overhead as well as possible. In this respect, I think it is
>> > actually marginally better *not* to cache the function pointers in local
>> > variables, which could end up spilled on the stack, or not, depending on
>> > local compiler optimisations for any given test case.
>>
>> I disagree, uninlining the timer fetches adds another source of
>> inconsistency.
>>
>
> Err, outlining the timer makes sure that it's always the exact same code 
> that's run, and not differently optimised inlinings, at least if LTO is 
> absent. 
> (And even with LTO, it vastly reduces the compiler's ability to optimise and 
> vary the compilation.) Again, given how the calculations are made at the 
> moment, the stability of the overhead is important, so that we can *compare* 
> measurements. The absolute value of the overhead, not so much.
>

Introducing additional overhead in the form of a dereference is a point
where instability can creep in. Can you guarantee that a context will
always remain in L1D cache, as opposed to just reading the raw CPU timing
directly where that's supported.


> But I still argue that that is, either way, completely negligible compared to 
> the *existing* overhead. Each loop is making 4 system calls, and each of 
> those 
> system call requires a direct call (to PLT) and an indirect branch (from 
> GOT). 
> If you have a problem with the two additional function calls, then you can't 
> be using Linux perf in the first place.
>

You don't want to ever use linux perf in the first place, it's second class.
I don't think it's worth changing the direct inlining we had before. You're not
interested in whether or not the same exact code is ran between platforms,
just that the code that's measuring timing is as efficient and low overhead
as possible.
___
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/x86/mathops: clip constants used with shift instructions within inline assembly

2023-07-16 Thread Rémi Denis-Courmont
Le sunnuntaina 16. heinäkuuta 2023, 19.00.35 EEST Andreas Rheinhardt a écrit :
> > @@ -113,19 +121,31 @@ __asm__ volatile(\
> > 
> >  // avoid +32 for shift optimization (gcc should do that ...)
> >  #define NEG_SSR32 NEG_SSR32
> >  static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
> > 
> > +if (__builtin_constant_p(s))
> > 
> >  __asm__ ("sarl %1, %0\n\t"
> >  
> >   : "+r" (a)
> > 
> > - : "ic" ((uint8_t)(-s))
> > + : "i" (-s & 0x1F)
> > 
> >  );
> > 
> > +else
> > +__asm__ ("sarl %1, %0\n\t"
> > +   : "+r" (a)
> > +   : "c" ((uint8_t)(-s))
> > +);
> > 
> >  return a;
> >  
> >  }
> >  
> >  #define NEG_USR32 NEG_USR32
> >  static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
> > 
> > +if (__builtin_constant_p(s))
> > 
> >  __asm__ ("shrl %1, %0\n\t"
> >  
> >   : "+r" (a)
> > 
> > - : "ic" ((uint8_t)(-s))
> > + : "i" (-s & 0x1F)
> > 
> >  );
> > 
> > +else
> > +__asm__ ("shrl %1, %0\n\t"
> > +   : "+r" (a)
> > +   : "c" ((uint8_t)(-s))
> > +);
> > 
> >  return a;
> >  
> >  }
> 
> Does this have a performance or codesize impact?

It performs the masking at compilation time rather than run-time, thus saving 
one masking instruction and sparing an implicit clobber on ECX.

However, since we are dealing with constants, we the shift amount could 
*presumably* just as well be fixed in the calling code. Not that I'd know.

> And is the inline ASM actually any good?

To be honest, even if it's good, it inhibits instruction scheduling by the 
compiler. So IMO the threshold should be for assembler to be strictly *better* 
than the C code.

(And I don't know the answer to that question.)

-- 
Rémi Denis-Courmont
http://www.remlab.net/



___
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/x86/mathops: clip constants used with shift instructions within inline assembly

2023-07-16 Thread James Almer

On 7/16/2023 1:00 PM, Andreas Rheinhardt wrote:

James Almer:

From: Rémi Denis-Courmont 

Fixes assembling with binutil as >= 2.41

Signed-off-by: James Almer 
---
  libavcodec/x86/mathops.h | 26 +++---
  1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
index 6298f5ed19..ca7e2dffc1 100644
--- a/libavcodec/x86/mathops.h
+++ b/libavcodec/x86/mathops.h
@@ -35,12 +35,20 @@
  static av_always_inline av_const int MULL(int a, int b, unsigned shift)
  {
  int rt, dummy;
+if (__builtin_constant_p(shift))


We actually have av_builtin_constant_p. Is it guaranteed that all
compilers supporting inline ASM also support __builtin_constant_p?


I can use av_builtin_constant_p() if you want, but it will be expanded 
to __builtin_constant_p() in all supported compilers, judging by how 
it's defined.





  __asm__ (
  "imull %3   \n\t"
  "shrdl %4, %%edx, %%eax \n\t"
  :"=a"(rt), "=d"(dummy)
-:"a"(a), "rm"(b), "ci"((uint8_t)shift)
+:"a"(a), "rm"(b), "i"(shift & 0x1F)
  );
+else
+__asm__ (
+"imull %3   \n\t"
+"shrdl %4, %%edx, %%eax \n\t"
+:"=a"(rt), "=d"(dummy)
+:"a"(a), "rm"(b), "c"((uint8_t)shift)
+);
  return rt;
  }
  
@@ -113,19 +121,31 @@ __asm__ volatile(\

  // avoid +32 for shift optimization (gcc should do that ...)
  #define NEG_SSR32 NEG_SSR32
  static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
+if (__builtin_constant_p(s))
  __asm__ ("sarl %1, %0\n\t"
   : "+r" (a)
- : "ic" ((uint8_t)(-s))
+ : "i" (-s & 0x1F)
  );
+else
+__asm__ ("sarl %1, %0\n\t"
+   : "+r" (a)
+   : "c" ((uint8_t)(-s))
+);
  return a;
  }
  
  #define NEG_USR32 NEG_USR32

  static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
+if (__builtin_constant_p(s))
  __asm__ ("shrl %1, %0\n\t"
   : "+r" (a)
- : "ic" ((uint8_t)(-s))
+ : "i" (-s & 0x1F)
  );
+else
+__asm__ ("shrl %1, %0\n\t"
+   : "+r" (a)
+   : "c" ((uint8_t)(-s))
+);
  return a;
  }
  


Does this have a performance or codesize impact?


It should behave the same it has until now.


And is the inline ASM actually any good? (When I comment the inline ASM
of NEG_USR32 out, code size actually increases with GCC 11, suggesting
that the inline ASM may be counterproductive as it impairs the compilers
ability to optimize.)


I did not test nor check if removing this ricing is better or not. It 
can be looked at later. Right now, i want lavc to compile with binutils 2.41




- 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".

___
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/x86/mathops: clip constants used with shift instructions within inline assembly

2023-07-16 Thread Andreas Rheinhardt
James Almer:
> From: Rémi Denis-Courmont 
> 
> Fixes assembling with binutil as >= 2.41
> 
> Signed-off-by: James Almer 
> ---
>  libavcodec/x86/mathops.h | 26 +++---
>  1 file changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
> index 6298f5ed19..ca7e2dffc1 100644
> --- a/libavcodec/x86/mathops.h
> +++ b/libavcodec/x86/mathops.h
> @@ -35,12 +35,20 @@
>  static av_always_inline av_const int MULL(int a, int b, unsigned shift)
>  {
>  int rt, dummy;
> +if (__builtin_constant_p(shift))

We actually have av_builtin_constant_p. Is it guaranteed that all
compilers supporting inline ASM also support __builtin_constant_p?

>  __asm__ (
>  "imull %3   \n\t"
>  "shrdl %4, %%edx, %%eax \n\t"
>  :"=a"(rt), "=d"(dummy)
> -:"a"(a), "rm"(b), "ci"((uint8_t)shift)
> +:"a"(a), "rm"(b), "i"(shift & 0x1F)
>  );
> +else
> +__asm__ (
> +"imull %3   \n\t"
> +"shrdl %4, %%edx, %%eax \n\t"
> +:"=a"(rt), "=d"(dummy)
> +:"a"(a), "rm"(b), "c"((uint8_t)shift)
> +);
>  return rt;
>  }
>  
> @@ -113,19 +121,31 @@ __asm__ volatile(\
>  // avoid +32 for shift optimization (gcc should do that ...)
>  #define NEG_SSR32 NEG_SSR32
>  static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
> +if (__builtin_constant_p(s))
>  __asm__ ("sarl %1, %0\n\t"
>   : "+r" (a)
> - : "ic" ((uint8_t)(-s))
> + : "i" (-s & 0x1F)
>  );
> +else
> +__asm__ ("sarl %1, %0\n\t"
> +   : "+r" (a)
> +   : "c" ((uint8_t)(-s))
> +);
>  return a;
>  }
>  
>  #define NEG_USR32 NEG_USR32
>  static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
> +if (__builtin_constant_p(s))
>  __asm__ ("shrl %1, %0\n\t"
>   : "+r" (a)
> - : "ic" ((uint8_t)(-s))
> + : "i" (-s & 0x1F)
>  );
> +else
> +__asm__ ("shrl %1, %0\n\t"
> +   : "+r" (a)
> +   : "c" ((uint8_t)(-s))
> +);
>  return a;
>  }
>  

Does this have a performance or codesize impact?
And is the inline ASM actually any good? (When I comment the inline ASM
of NEG_USR32 out, code size actually increases with GCC 11, suggesting
that the inline ASM may be counterproductive as it impairs the compilers
ability to optimize.)

- 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".


[FFmpeg-devel] [PATCH] avcodec/x86/mathops: clip constants used with shift instructions within inline assembly

2023-07-16 Thread James Almer
From: Rémi Denis-Courmont 

Fixes assembling with binutil as >= 2.41

Signed-off-by: James Almer 
---
 libavcodec/x86/mathops.h | 26 +++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/libavcodec/x86/mathops.h b/libavcodec/x86/mathops.h
index 6298f5ed19..ca7e2dffc1 100644
--- a/libavcodec/x86/mathops.h
+++ b/libavcodec/x86/mathops.h
@@ -35,12 +35,20 @@
 static av_always_inline av_const int MULL(int a, int b, unsigned shift)
 {
 int rt, dummy;
+if (__builtin_constant_p(shift))
 __asm__ (
 "imull %3   \n\t"
 "shrdl %4, %%edx, %%eax \n\t"
 :"=a"(rt), "=d"(dummy)
-:"a"(a), "rm"(b), "ci"((uint8_t)shift)
+:"a"(a), "rm"(b), "i"(shift & 0x1F)
 );
+else
+__asm__ (
+"imull %3   \n\t"
+"shrdl %4, %%edx, %%eax \n\t"
+:"=a"(rt), "=d"(dummy)
+:"a"(a), "rm"(b), "c"((uint8_t)shift)
+);
 return rt;
 }
 
@@ -113,19 +121,31 @@ __asm__ volatile(\
 // avoid +32 for shift optimization (gcc should do that ...)
 #define NEG_SSR32 NEG_SSR32
 static inline  int32_t NEG_SSR32( int32_t a, int8_t s){
+if (__builtin_constant_p(s))
 __asm__ ("sarl %1, %0\n\t"
  : "+r" (a)
- : "ic" ((uint8_t)(-s))
+ : "i" (-s & 0x1F)
 );
+else
+__asm__ ("sarl %1, %0\n\t"
+   : "+r" (a)
+   : "c" ((uint8_t)(-s))
+);
 return a;
 }
 
 #define NEG_USR32 NEG_USR32
 static inline uint32_t NEG_USR32(uint32_t a, int8_t s){
+if (__builtin_constant_p(s))
 __asm__ ("shrl %1, %0\n\t"
  : "+r" (a)
- : "ic" ((uint8_t)(-s))
+ : "i" (-s & 0x1F)
 );
+else
+__asm__ ("shrl %1, %0\n\t"
+   : "+r" (a)
+   : "c" ((uint8_t)(-s))
+);
 return a;
 }
 
-- 
2.41.0

___
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] lavc/bswapdsp: purge RISC-V V bswap32

2023-07-16 Thread Rémi Denis-Courmont
This cannot beat the Zbb implementation, and it is unlikely that a real
meaningful CPU design would support V and not Zbb. The best loop rewrite
that I could come up with (4 shifts, 2 ands, 3 ors) is still ~40% slower
than Zbb.

A proper faster vector implementation should be feasible with the
cryptographic vector extensions, but that is a story for another time.
---
 libavcodec/riscv/bswapdsp_init.c |  5 +
 libavcodec/riscv/bswapdsp_rvv.S  | 23 ---
 2 files changed, 1 insertion(+), 27 deletions(-)

diff --git a/libavcodec/riscv/bswapdsp_init.c b/libavcodec/riscv/bswapdsp_init.c
index 6ad63e3805..ed666c9b3a 100644
--- a/libavcodec/riscv/bswapdsp_init.c
+++ b/libavcodec/riscv/bswapdsp_init.c
@@ -26,7 +26,6 @@
 #include "libavcodec/bswapdsp.h"
 
 void ff_bswap32_buf_rvb(uint32_t *dst, const uint32_t *src, int len);
-void ff_bswap32_buf_rvv(uint32_t *dst, const uint32_t *src, int len);
 void ff_bswap16_buf_rvv(uint16_t *dst, const uint16_t *src, int len);
 
 av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c)
@@ -39,10 +38,8 @@ av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c)
 c->bswap_buf = ff_bswap32_buf_rvb;
 #endif
 #if HAVE_RVV
-if (flags & AV_CPU_FLAG_RVV_I32) {
-c->bswap_buf = ff_bswap32_buf_rvv;
+if (flags & AV_CPU_FLAG_RVV_I32)
 c->bswap16_buf = ff_bswap16_buf_rvv;
-}
 #endif
 }
 }
diff --git a/libavcodec/riscv/bswapdsp_rvv.S b/libavcodec/riscv/bswapdsp_rvv.S
index 8b585ec5c9..b37fe26255 100644
--- a/libavcodec/riscv/bswapdsp_rvv.S
+++ b/libavcodec/riscv/bswapdsp_rvv.S
@@ -21,29 +21,6 @@
 #include "config.h"
 #include "libavutil/riscv/asm.S"
 
-func ff_bswap32_buf_rvv, zve32x
-li  t4, 4
-addit1, a0, 1
-addit2, a0, 2
-addit3, a0, 3
-1:
-vsetvlit0, a2, e8, m1, ta, ma
-vlseg4e8.v v8, (a1)
-suba2, a2, t0
-sh2add a1, t0, a1
-vsse8.vv8, (t3), t4
-sh2add t3, t0, t3
-vsse8.vv9, (t2), t4
-sh2add t2, t0, t2
-vsse8.vv10, (t1), t4
-sh2add t1, t0, t1
-vsse8.vv11, (a0), t4
-sh2add a0, t0, a0
-bnez   a2, 1b
-
-ret
-endfunc
-
 func ff_bswap16_buf_rvv, zve32x
 1:
 vsetvli t0, a2, e16, m8, ta, ma
-- 
2.40.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] lavc/bswapdsp: rewrite RISC-V V bswap16

2023-07-16 Thread Rémi Denis-Courmont
This favours bit-wise logic over slow strided stores.
---
 libavcodec/riscv/bswapdsp_rvv.S | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/libavcodec/riscv/bswapdsp_rvv.S b/libavcodec/riscv/bswapdsp_rvv.S
index ef2999c1be..8b585ec5c9 100644
--- a/libavcodec/riscv/bswapdsp_rvv.S
+++ b/libavcodec/riscv/bswapdsp_rvv.S
@@ -45,18 +45,17 @@ func ff_bswap32_buf_rvv, zve32x
 endfunc
 
 func ff_bswap16_buf_rvv, zve32x
-li  t2, 2
-addit1, a0, 1
 1:
-vsetvlit0, a2, e8, m1, ta, ma
-vlseg2e8.v v8, (a1)
-suba2, a2, t0
-sh1add a1, t0, a1
-vsse8.vv8, (t1), t2
-sh1add t1, t0, t1
-vsse8.vv9, (a0), t2
-sh1add a0, t0, a0
-bnez   a2, 1b
+vsetvli t0, a2, e16, m8, ta, ma
+vle16.v v8, (a1)
+sub a2, a2, t0
+vsll.vi v16, v8, 8
+sh1add  a1, t0, a1
+vsrl.vi v24, v8, 8
+vor.vv  v8, v16, v24
+vse16.v v8, (a0)
+sh1add  a0, t0, a0
+bneza2, 1b
 
 ret
 endfunc
-- 
2.40.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 5/5] avcodec/msrleenc: Constify pointers for frame->data

2023-07-16 Thread Andreas Rheinhardt
Encoders (usually) have no business modifying frame->data
(which need not be writable), so they should use the appropriate
pointers.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/msrleenc.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavcodec/msrleenc.c b/libavcodec/msrleenc.c
index 11f7d2a319..931e7af053 100644
--- a/libavcodec/msrleenc.c
+++ b/libavcodec/msrleenc.c
@@ -64,7 +64,8 @@ static void write_run(AVCodecContext *avctx, uint8_t **data, 
int len, int value)
 }
 }
 
-static void write_absolute(AVCodecContext *avctx, uint8_t **data, uint8_t 
*line, int len)
+static void write_absolute(AVCodecContext *avctx, uint8_t **data,
+   const uint8_t *line, int len)
 {
 // writing 255 would be wasteful here due to the padding requirement
 while (len >= 254) {
@@ -136,7 +137,8 @@ static void write_yskip(AVCodecContext *avctx, uint8_t 
**data, int yskip)
 }
 
 // used both to encode lines in keyframes and to encode lines between deltas
-static void encode_line(AVCodecContext *avctx, uint8_t **data, uint8_t *line, 
int length)
+static void encode_line(AVCodecContext *avctx, uint8_t **data,
+const uint8_t *line, int length)
 {
 int run = 0, last = -1, absstart = 0;
 if (length == 0)
@@ -192,8 +194,8 @@ static int encode(AVCodecContext *avctx, AVPacket *pkt,
 // compare to previous frame
 int yskip = 0; // we can encode large skips using deltas
 for (int y = avctx->height-1; y >= 0; y--) {
-uint8_t *line = >data[0][y*pict->linesize[0]];
-uint8_t *prev = 
>last_frame->data[0][y*s->last_frame->linesize[0]];
+const uint8_t *line = >data[0][y*pict->linesize[0]];
+const uint8_t *prev = 
>last_frame->data[0][y*s->last_frame->linesize[0]];
 // we need at least 5 pixels in a row for a delta to be worthwhile
 int delta = 0, linestart = 0, encoded = 0;
 for (int x = 0; x < avctx->width; x++) {
-- 
2.34.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 4/4] avcodec/msrleenc: Check frame allocations/references

2023-07-16 Thread Andreas Rheinhardt
Also allocate the AVFrame during init and use av_frame_replace()
to replace it later.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/msrleenc.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libavcodec/msrleenc.c b/libavcodec/msrleenc.c
index d5931f42fe..11f7d2a319 100644
--- a/libavcodec/msrleenc.c
+++ b/libavcodec/msrleenc.c
@@ -37,7 +37,13 @@ typedef struct MSRLEContext {
 
 static av_cold int msrle_encode_init(AVCodecContext *avctx)
 {
+MSRLEContext *s = avctx->priv_data;
+
 avctx->bits_per_coded_sample = 8;
+s->last_frame = av_frame_alloc();
+if (!s->last_frame)
+return AVERROR(ENOMEM);
+
 return 0;
 }
 
@@ -265,13 +271,7 @@ static int msrle_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 s->curframe = 0;
 *got_packet = 1;
 
-if (!s->last_frame)
-s->last_frame = av_frame_alloc();
-else
-av_frame_unref(s->last_frame);
-
-av_frame_ref(s->last_frame, pict);
-return 0;
+return av_frame_replace(s->last_frame, pict);
 }
 
 static int msrle_encode_close(AVCodecContext *avctx)
-- 
2.34.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 3/4] avcodec/msrleenc: Remove useless private class

2023-07-16 Thread Andreas Rheinhardt
A private class for an encoder without options is useless.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/msrleenc.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/libavcodec/msrleenc.c b/libavcodec/msrleenc.c
index 264d57e178..d5931f42fe 100644
--- a/libavcodec/msrleenc.c
+++ b/libavcodec/msrleenc.c
@@ -31,7 +31,6 @@
 #include "encode.h"
 
 typedef struct MSRLEContext {
-const AVClass *class;
 int curframe;
 AVFrame *last_frame;
 } MSRLEContext;
@@ -282,12 +281,6 @@ static int msrle_encode_close(AVCodecContext *avctx)
 return 0;
 }
 
-static const AVClass msrle_class = {
-.class_name = "Microsoft RLE encoder",
-.item_name  = av_default_item_name,
-.version= LIBAVUTIL_VERSION_INT,
-};
-
 const FFCodec ff_msrle_encoder = {
 .p.name = "msrle",
 CODEC_LONG_NAME("Microsoft RLE"),
@@ -301,6 +294,5 @@ const FFCodec ff_msrle_encoder = {
 .p.pix_fmts = (const enum AVPixelFormat[]){
 AV_PIX_FMT_PAL8, AV_PIX_FMT_NONE
 },
-.p.priv_class   = _class,
 .caps_internal  = FF_CODEC_CAP_INIT_CLEANUP,
 };
-- 
2.34.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 2/4] avcodec/msrleenc: Check allocation

2023-07-16 Thread Andreas Rheinhardt
Fixes Coverity issue #1538297.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/msrleenc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/msrleenc.c b/libavcodec/msrleenc.c
index e48d11a0f7..264d57e178 100644
--- a/libavcodec/msrleenc.c
+++ b/libavcodec/msrleenc.c
@@ -250,6 +250,8 @@ static int msrle_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 
 if (pict->data[1]) {
 uint8_t *side_data = av_packet_new_side_data(pkt, AV_PKT_DATA_PALETTE, 
AVPALETTE_SIZE);
+if (!side_data)
+return AVERROR(ENOMEM);
 memcpy(side_data, pict->data[1], AVPALETTE_SIZE);
 }
 
-- 
2.34.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/4] avcodec/msrleenc: Replace stray \r by \n

2023-07-16 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/msrleenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/msrleenc.c b/libavcodec/msrleenc.c
index b73aa5e384..e48d11a0f7 100644
--- a/libavcodec/msrleenc.c
+++ b/libavcodec/msrleenc.c
@@ -234,7 +234,8 @@ static int encode(AVCodecContext *avctx, AVPacket *pkt,
 }
 bytestream_put_be16(, 0x0001); // end of bitmap
 pkt->size = data - pkt->data;
-return 0;
}
+return 0;
+}
 
 static int msrle_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
   const AVFrame *pict, int *got_packet)
-- 
2.34.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 1/3] avcodec/evc_ps: Fix size of tile_(row|column) arrays

2023-07-16 Thread James Almer

On 7/16/2023 11:22 AM, Andreas Rheinhardt wrote:

Prevents out-of-bound writes when parsing tile row heights.
Fixes Coverity issue #1538300.

Signed-off-by: Andreas Rheinhardt 
---
  libavcodec/evc_ps.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/evc_ps.h b/libavcodec/evc_ps.h
index 0bbec1f138..336953b176 100644
--- a/libavcodec/evc_ps.h
+++ b/libavcodec/evc_ps.h
@@ -192,8 +192,8 @@ typedef struct EVCParserPPS {
  uint32_t num_tile_columns_minus1;  // ue(v)
  uint32_t num_tile_rows_minus1; // ue(v)
  uint8_t uniform_tile_spacing_flag; // u(1)
-uint32_t tile_column_width_minus1[EVC_MAX_TILE_ROWS];  // ue(v)
-uint32_t tile_row_height_minus1[EVC_MAX_TILE_COLUMNS]; // ue(v)
+uint32_t tile_column_width_minus1[EVC_MAX_TILE_COLUMNS];   // ue(v)
+uint32_t tile_row_height_minus1[EVC_MAX_TILE_ROWS];// ue(v)
  uint8_t loop_filter_across_tiles_enabled_flag; // u(1)
  uint32_t tile_offset_len_minus1;   // ue(v)
  uint8_t tile_id_len_minus1;// ue(v)


LGTM.
___
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/3] avcodec/evc_ps: Fix size of tile_(row|column) arrays

2023-07-16 Thread Andreas Rheinhardt
Prevents out-of-bound writes when parsing tile row heights.
Fixes Coverity issue #1538300.

Signed-off-by: Andreas Rheinhardt 
---
 libavcodec/evc_ps.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/evc_ps.h b/libavcodec/evc_ps.h
index 0bbec1f138..336953b176 100644
--- a/libavcodec/evc_ps.h
+++ b/libavcodec/evc_ps.h
@@ -192,8 +192,8 @@ typedef struct EVCParserPPS {
 uint32_t num_tile_columns_minus1;  // ue(v)
 uint32_t num_tile_rows_minus1; // ue(v)
 uint8_t uniform_tile_spacing_flag; // u(1)
-uint32_t tile_column_width_minus1[EVC_MAX_TILE_ROWS];  // ue(v)
-uint32_t tile_row_height_minus1[EVC_MAX_TILE_COLUMNS]; // ue(v)
+uint32_t tile_column_width_minus1[EVC_MAX_TILE_COLUMNS];   // ue(v)
+uint32_t tile_row_height_minus1[EVC_MAX_TILE_ROWS];// ue(v)
 uint8_t loop_filter_across_tiles_enabled_flag; // u(1)
 uint32_t tile_offset_len_minus1;   // ue(v)
 uint8_t tile_id_len_minus1;// ue(v)
-- 
2.34.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 1/2] lavc/aacpsdsp: rework RISC-V add_squares

2023-07-16 Thread Rémi Denis-Courmont
Le lauantaina 15. heinäkuuta 2023, 23.57.04 EEST Rémi Denis-Courmont a écrit :
> Segmented loads are kinda slow, so this advantageously uses a
> unit-strided load and narrowing shifts instead.
> 
> Before:
> ps_add_squares_rvv_f32: 30352.2
> 
> After:
> ps_add_squares_rvv_f32: 11973.7
> ---
>  libavcodec/riscv/aacpsdsp_rvv.S | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/riscv/aacpsdsp_rvv.S
> b/libavcodec/riscv/aacpsdsp_rvv.S index 80bd19f6ad..b7ea314fc3 100644
> --- a/libavcodec/riscv/aacpsdsp_rvv.S
> +++ b/libavcodec/riscv/aacpsdsp_rvv.S
> @@ -1,5 +1,5 @@
>  /*
> - * Copyright © 2022 Rémi Denis-Courmont.
> + * Copyright © 2022-2023 Rémi Denis-Courmont.
>   *
>   * This file is part of FFmpeg.
>   *
> @@ -21,13 +21,16 @@
>  #include "libavutil/riscv/asm.S"
> 
>  func ff_ps_add_squares_rvv, zve32f
> +li  t1, 32
>  1:
>  vsetvli t0, a2, e32, m1, ta, ma
> -vlseg2e32.v v24, (a1)
> -sub a2, a2, t0
> +vle64.v v8, (a1)

Requires zve64x

> +vnsrl.wxv24, v8, zero
>  vle32.v v16, (a0)
> -sh3add  a1, t0, a1
> +sub a2, a2, t0
> +vnsrl.wxv25, v8, t1
>  vfmacc.vv   v16, v24, v24
> +sh3add  a1, t0, a1
>  vfmacc.vv   v16, v25, v25
>  vse32.v v16, (a0)
>  sh2add  a0, t0, a0

-- 
レミ・デニ-クールモン
http://www.remlab.net/



___
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 3/3] fftools/ffmpeg_enc: Reindentate after the last commit

2023-07-16 Thread Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt 
---
 fftools/ffmpeg_enc.c | 38 +++---
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 2c7e29af24..8b750de4e5 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -304,31 +304,31 @@ int enc_open(OutputStream *ost, AVFrame *frame)
 enc_ctx->bits_per_raw_sample = FFMIN(fd->bits_per_raw_sample,
  
av_pix_fmt_desc_get(enc_ctx->pix_fmt)->comp[0].depth);
 
-enc_ctx->color_range= frame->color_range;
-enc_ctx->color_primaries= frame->color_primaries;
-enc_ctx->color_trc  = frame->color_trc;
-enc_ctx->colorspace = frame->colorspace;
-enc_ctx->chroma_sample_location = frame->chroma_location;
+enc_ctx->color_range= frame->color_range;
+enc_ctx->color_primaries= frame->color_primaries;
+enc_ctx->color_trc  = frame->color_trc;
+enc_ctx->colorspace = frame->colorspace;
+enc_ctx->chroma_sample_location = frame->chroma_location;
 
 enc_ctx->framerate = fr;
 
 ost->st->avg_frame_rate = fr;
 
 // Field order: autodetection
-if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | 
AV_CODEC_FLAG_INTERLACED_ME) &&
-ost->top_field_first >= 0)
-if (ost->top_field_first)
-frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
-else
-frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
-
-if (frame->flags & AV_FRAME_FLAG_INTERLACED) {
-if (enc->id == AV_CODEC_ID_MJPEG)
-enc_ctx->field_order = (frame->flags & 
AV_FRAME_FLAG_TOP_FIELD_FIRST) ? AV_FIELD_TT:AV_FIELD_BB;
-else
-enc_ctx->field_order = (frame->flags & 
AV_FRAME_FLAG_TOP_FIELD_FIRST) ? AV_FIELD_TB:AV_FIELD_BT;
-} else
-enc_ctx->field_order = AV_FIELD_PROGRESSIVE;
+if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | 
AV_CODEC_FLAG_INTERLACED_ME) &&
+ost->top_field_first >= 0)
+if (ost->top_field_first)
+frame->flags |= AV_FRAME_FLAG_TOP_FIELD_FIRST;
+else
+frame->flags &= ~AV_FRAME_FLAG_TOP_FIELD_FIRST;
+
+if (frame->flags & AV_FRAME_FLAG_INTERLACED) {
+if (enc->id == AV_CODEC_ID_MJPEG)
+enc_ctx->field_order = (frame->flags & 
AV_FRAME_FLAG_TOP_FIELD_FIRST) ? AV_FIELD_TT:AV_FIELD_BB;
+else
+enc_ctx->field_order = (frame->flags & 
AV_FRAME_FLAG_TOP_FIELD_FIRST) ? AV_FIELD_TB:AV_FIELD_BT;
+} else
+enc_ctx->field_order = AV_FIELD_PROGRESSIVE;
 
 // Field order: override
 if (ost->top_field_first == 0) {
-- 
2.34.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 2/3] fftools/ffmpeg_enc: Remove always-true checks

2023-07-16 Thread Andreas Rheinhardt
frame is always != NULL for audio and video here
(this is checked by an assert and the frame is already dereferenced
before it reaches this code here).
Fixes Coverity issue #1538858.

Signed-off-by: Andreas Rheinhardt 
---
 fftools/ffmpeg_enc.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index 1489b2f179..2c7e29af24 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -304,20 +304,17 @@ int enc_open(OutputStream *ost, AVFrame *frame)
 enc_ctx->bits_per_raw_sample = FFMIN(fd->bits_per_raw_sample,
  
av_pix_fmt_desc_get(enc_ctx->pix_fmt)->comp[0].depth);
 
-if (frame) {
 enc_ctx->color_range= frame->color_range;
 enc_ctx->color_primaries= frame->color_primaries;
 enc_ctx->color_trc  = frame->color_trc;
 enc_ctx->colorspace = frame->colorspace;
 enc_ctx->chroma_sample_location = frame->chroma_location;
-}
 
 enc_ctx->framerate = fr;
 
 ost->st->avg_frame_rate = fr;
 
 // Field order: autodetection
-if (frame) {
 if (enc_ctx->flags & (AV_CODEC_FLAG_INTERLACED_DCT | 
AV_CODEC_FLAG_INTERLACED_ME) &&
 ost->top_field_first >= 0)
 if (ost->top_field_first)
@@ -332,7 +329,6 @@ int enc_open(OutputStream *ost, AVFrame *frame)
 enc_ctx->field_order = (frame->flags & 
AV_FRAME_FLAG_TOP_FIELD_FIRST) ? AV_FIELD_TB:AV_FIELD_BT;
 } else
 enc_ctx->field_order = AV_FIELD_PROGRESSIVE;
-}
 
 // Field order: override
 if (ost->top_field_first == 0) {
-- 
2.34.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] swscale/x86/rgb2rgb: fix a Wlto-type-mismatch warning

2023-07-16 Thread psykose
From: psykose 

fixes a warning when building with --enable-lto:
libswscale/x86/swscale.c:323:1: warning: type of 'ff_nv12ToUV_avx' does not 
match original declaration [-Wlto-type-mismatch]
  323 | INPUT_FUNCS(avx);
  | ^
libswscale/x86/rgb2rgb_template.c:1821:6: note: type mismatch in parameter 8
 1821 | void RENAME(ff_nv12ToUV)(uint8_t *dstU, uint8_t *dstV,
  |  ^
libswscale/x86/rgb2rgb_template.c:1821:6: note: 'ff_nv12ToUV_avx' was 
previously declared here

this is because INPUT_UV_FUNC in swscale.c has an 8th void * parameter,
so match the declaration and pass NULL for it
---
 libswscale/x86/rgb2rgb_template.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libswscale/x86/rgb2rgb_template.c 
b/libswscale/x86/rgb2rgb_template.c
index 4aba25dd51..f6c843e4f2 100644
--- a/libswscale/x86/rgb2rgb_template.c
+++ b/libswscale/x86/rgb2rgb_template.c
@@ -1823,7 +1823,7 @@ void RENAME(ff_nv12ToUV)(uint8_t *dstU, uint8_t *dstV,
  const uint8_t *src1,
  const uint8_t *src2,
  int w,
- uint32_t *unused2);
+ uint32_t *unused2, void *opq);
 static void RENAME(deinterleaveBytes)(const uint8_t *src, uint8_t *dst1, 
uint8_t *dst2,
   int width, int height, int srcStride,
   int dst1Stride, int dst2Stride)
@@ -1831,7 +1831,7 @@ static void RENAME(deinterleaveBytes)(const uint8_t *src, 
uint8_t *dst1, uint8_t
 int h;
 
 for (h = 0; h < height; h++) {
-RENAME(ff_nv12ToUV)(dst1, dst2, NULL, src, NULL, width, NULL);
+RENAME(ff_nv12ToUV)(dst1, dst2, NULL, src, NULL, width, NULL, NULL);
 src  += srcStride;
 dst1 += dst1Stride;
 dst2 += dst2Stride;
-- 
2.41.0

___
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] lavu: add/use flag for RISC-V Zba extension

2023-07-16 Thread Rémi Denis-Courmont
The code was blindly assuming that Zbb or V implied Zba. While the
earlier is practically always true, the later broke some QEMU setups,
as V was introduced earlier than Zba.
---
 libavcodec/riscv/aacpsdsp_init.c  | 11 ++---
 libavcodec/riscv/alacdsp_init.c   |  2 +-
 libavcodec/riscv/audiodsp_init.c  | 12 +
 libavcodec/riscv/bswapdsp_init.c  | 16 ++--
 libavcodec/riscv/fmtconvert_init.c|  2 +-
 libavcodec/riscv/h264_chroma_init_riscv.c |  3 ++-
 libavcodec/riscv/vorbisdsp_init.c |  2 +-
 libavutil/cpu.c   |  1 +
 libavutil/cpu.h   |  1 +
 libavutil/riscv/cpu.c |  5 +++-
 libavutil/riscv/fixed_dsp_init.c  |  2 +-
 libavutil/riscv/float_dsp_init.c  | 30 ---
 libswscale/riscv/rgb2rgb.c|  2 +-
 tests/checkasm/checkasm.c |  1 +
 14 files changed, 53 insertions(+), 37 deletions(-)

diff --git a/libavcodec/riscv/aacpsdsp_init.c b/libavcodec/riscv/aacpsdsp_init.c
index f42baf4251..c5ec796232 100644
--- a/libavcodec/riscv/aacpsdsp_init.c
+++ b/libavcodec/riscv/aacpsdsp_init.c
@@ -43,13 +43,16 @@ av_cold void ff_psdsp_init_riscv(PSDSPContext *c)
 int flags = av_get_cpu_flags();
 
 if (flags & AV_CPU_FLAG_RVV_F32) {
-c->add_squares = ff_ps_add_squares_rvv;
-c->mul_pair_single = ff_ps_mul_pair_single_rvv;
 c->hybrid_analysis = ff_ps_hybrid_analysis_rvv;
-c->stereo_interpolate[0] = ff_ps_stereo_interpolate_rvv;
+
+if (flags & AV_CPU_FLAG_RVB_ADDR) {
+c->add_squares = ff_ps_add_squares_rvv;
+c->mul_pair_single = ff_ps_mul_pair_single_rvv;
+c->stereo_interpolate[0] = ff_ps_stereo_interpolate_rvv;
+}
 }
 
-if (flags & AV_CPU_FLAG_RVV_I32) {
+if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB_ADDR)) {
 c->hybrid_analysis_ileave = ff_ps_hybrid_analysis_ileave_rvv;
 c->hybrid_synthesis_deint = ff_ps_hybrid_synthesis_deint_rvv;
 }
diff --git a/libavcodec/riscv/alacdsp_init.c b/libavcodec/riscv/alacdsp_init.c
index fa8a7c8129..cd6dc4f8ae 100644
--- a/libavcodec/riscv/alacdsp_init.c
+++ b/libavcodec/riscv/alacdsp_init.c
@@ -41,7 +41,7 @@ av_cold void ff_alacdsp_init_riscv(ALACDSPContext *c)
 #if HAVE_RVV && (__riscv_xlen == 64)
 int flags = av_get_cpu_flags();
 
-if (flags & AV_CPU_FLAG_RVV_I32) {
+if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB_ADDR)) {
 c->decorrelate_stereo = ff_alac_decorrelate_stereo_rvv;
 c->append_extra_bits[0] = ff_alac_append_extra_bits_mono_rvv;
 c->append_extra_bits[1] = ff_alac_append_extra_bits_stereo_rvv;
diff --git a/libavcodec/riscv/audiodsp_init.c b/libavcodec/riscv/audiodsp_init.c
index 32c3c6794d..9ab59c011e 100644
--- a/libavcodec/riscv/audiodsp_init.c
+++ b/libavcodec/riscv/audiodsp_init.c
@@ -38,11 +38,13 @@ av_cold void ff_audiodsp_init_riscv(AudioDSPContext *c)
 if (flags & AV_CPU_FLAG_RVF)
 c->vector_clipf = ff_vector_clipf_rvf;
 #if HAVE_RVV
-if (flags & AV_CPU_FLAG_RVV_I32) {
-c->scalarproduct_int16 = ff_scalarproduct_int16_rvv;
-c->vector_clip_int32 = ff_vector_clip_int32_rvv;
+if (flags & AV_CPU_FLAG_RVB_ADDR) {
+if (flags & AV_CPU_FLAG_RVV_I32) {
+c->scalarproduct_int16 = ff_scalarproduct_int16_rvv;
+c->vector_clip_int32 = ff_vector_clip_int32_rvv;
+}
+if (flags & AV_CPU_FLAG_RVV_F32)
+c->vector_clipf = ff_vector_clipf_rvv;
 }
-if (flags & AV_CPU_FLAG_RVV_F32)
-c->vector_clipf = ff_vector_clipf_rvv;
 #endif
 }
diff --git a/libavcodec/riscv/bswapdsp_init.c b/libavcodec/riscv/bswapdsp_init.c
index abe84ec1f7..6ad63e3805 100644
--- a/libavcodec/riscv/bswapdsp_init.c
+++ b/libavcodec/riscv/bswapdsp_init.c
@@ -31,16 +31,18 @@ void ff_bswap16_buf_rvv(uint16_t *dst, const uint16_t *src, 
int len);
 
 av_cold void ff_bswapdsp_init_riscv(BswapDSPContext *c)
 {
-int cpu_flags = av_get_cpu_flags();
+int flags = av_get_cpu_flags();
 
+if (flags & AV_CPU_FLAG_RVB_ADDR) {
 #if (__riscv_xlen >= 64)
-if (cpu_flags & AV_CPU_FLAG_RVB_BASIC)
-c->bswap_buf = ff_bswap32_buf_rvb;
+if (flags & AV_CPU_FLAG_RVB_BASIC)
+c->bswap_buf = ff_bswap32_buf_rvb;
 #endif
 #if HAVE_RVV
-if (cpu_flags & AV_CPU_FLAG_RVV_I32) {
-c->bswap_buf = ff_bswap32_buf_rvv;
-c->bswap16_buf = ff_bswap16_buf_rvv;
-}
+if (flags & AV_CPU_FLAG_RVV_I32) {
+c->bswap_buf = ff_bswap32_buf_rvv;
+c->bswap16_buf = ff_bswap16_buf_rvv;
+}
 #endif
+}
 }
diff --git a/libavcodec/riscv/fmtconvert_init.c 
b/libavcodec/riscv/fmtconvert_init.c
index 2ded9d3615..f5eeafba45 100644
--- a/libavcodec/riscv/fmtconvert_init.c
+++ b/libavcodec/riscv/fmtconvert_init.c
@@ -36,7 +36,7 @@ av_cold void ff_fmt_convert_init_riscv(FmtConvertContext *c)
 #if 

Re: [FFmpeg-devel] [PATCH] avcodec/x86/mathops: use constrained immediate operands

2023-07-16 Thread Rémi Denis-Courmont
Le sunnuntaina 16. heinäkuuta 2023, 14.55.43 EEST James Almer a écrit :
> On 7/16/2023 6:23 AM, Rémi Denis-Courmont wrote:
> > Le sunnuntaina 16. heinäkuuta 2023, 2.58.32 EEST James Almer a écrit :
> >> Should fix assembling with binutil as >= 2.41
> >> 
> >> Signed-off-by: James Almer 
> >> ---
> >> This is IMO a big breakage. binutil's as has until now clipped these
> >> values
> >> on its own, and never required the compiler to do it.
> > 
> > TBH, silently clipping immediate constants sounds like a nasty bug that
> > could cause really nasty suprises if somebody every passes an
> > out-of-range constant.
> We're passing it out or range constants alright. I tried adding an
> av_assert0((uint8_t)(-s) <= 31) and most fate tests started failing.

Well, yes. That's why recent binutils is complaining. It wouldn't if the 
constant values were always in range.

I'm not versed in the x86 subdomain of black magic, so I'm not sure if you 
imply that it was intentional that FFmpeg fed out of range values that would 
be cropped, or if it was unintentional. In the later case, I think that the 
existing assembler constraint should actually be kept as it is precisely to 
detect errors, and the calling code path ought to be fixed instead.

Either way, changing "i" for "I" will generate suboptimal-looking code as I 
pointed out up-thread. If we don't even care about that, then we migth as well 
shift in C code, AFAICT.

> > This has happened to me many times, typically with incidentally
> > out-of-range immediate offsets in loads/stores.
> > 
> > (...)
> > 
> >>   __asm__ ("shrl %1, %0\n\t"
> >>   
> >>: "+r" (a)
> >> 
> >> - : "ic" ((uint8_t)(-s))
> >> + : "Ic" ((uint8_t)(-s))
> > 
> > Note that this is not equivalent. Now, if `s` is constant but out of
> > range,
> > the compiler will be required to fit it. And it does that by moving it
> > into
> > ECX. This is probably not what you want.
> > 
> > AFAICT, you should keep the constraint as it is, and fix the operand value
> > 
> > instead by masking it, e.g.:
> >  if (__builtin_constant_p(s))
> >  
> >  __asm__ ("shrl %1, %0\n\t"
> >  
> >  : "+r" (a)
> >  : "i" ((-s) & 0x1f)
> >  
> >  );
> >  
> >  else
> >  
> >  __asm__ ("shrl %1, %0\n\t"
> >  
> >  : "+r" (a)
> >  : "c" (-s)
> >  
> >  );
> > 
> > (Not sure if the the 0x1f mask is correct, but you get the idea.)
> 
> It is, just tested.
> ___
> 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".


-- 
雷米‧德尼-库尔蒙
http://www.remlab.net/



___
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/x86/mathops: use constrained immediate operands

2023-07-16 Thread James Almer

On 7/16/2023 6:23 AM, Rémi Denis-Courmont wrote:

Le sunnuntaina 16. heinäkuuta 2023, 2.58.32 EEST James Almer a écrit :

Should fix assembling with binutil as >= 2.41

Signed-off-by: James Almer 
---
This is IMO a big breakage. binutil's as has until now clipped these values
on its own, and never required the compiler to do it.


TBH, silently clipping immediate constants sounds like a nasty bug that could
cause really nasty suprises if somebody every passes an out-of-range constant.


We're passing it out or range constants alright. I tried adding an 
av_assert0((uint8_t)(-s) <= 31) and most fate tests started failing.



This has happened to me many times, typically with incidentally out-of-range
immediate offsets in loads/stores.

(...)


  __asm__ ("shrl %1, %0\n\t"
   : "+r" (a)
- : "ic" ((uint8_t)(-s))
+ : "Ic" ((uint8_t)(-s))


Note that this is not equivalent. Now, if `s` is constant but out of range,
the compiler will be required to fit it. And it does that by moving it into
ECX. This is probably not what you want.

AFAICT, you should keep the constraint as it is, and fix the operand value
instead by masking it, e.g.:

 if (__builtin_constant_p(s))
 __asm__ ("shrl %1, %0\n\t"
 : "+r" (a)
 : "i" ((-s) & 0x1f)
 );
 else
 __asm__ ("shrl %1, %0\n\t"
 : "+r" (a)
 : "c" (-s)
 );

(Not sure if the the 0x1f mask is correct, but you get the idea.)


It is, just tested.
___
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] checkasm: test Zbb before V

2023-07-16 Thread Rémi Denis-Courmont
Without this, Zbb functions get shadowed by V functions on devices
supporting both extensions, and never tested.
---
 tests/checkasm/checkasm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 53cf6c48bb..c6dec0de7a 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -258,11 +258,11 @@ static const struct {
 { "RVI",  "rvi",  AV_CPU_FLAG_RVI },
 { "RVF",  "rvf",  AV_CPU_FLAG_RVF },
 { "RVD",  "rvd",  AV_CPU_FLAG_RVD },
+{ "RVBbasic", "rvb_b",AV_CPU_FLAG_RVB_BASIC },
 { "RVVi32",   "rvv_i32",  AV_CPU_FLAG_RVV_I32 },
 { "RVVf32",   "rvv_f32",  AV_CPU_FLAG_RVV_F32 },
 { "RVVi64",   "rvv_i64",  AV_CPU_FLAG_RVV_I64 },
 { "RVVf64",   "rvv_f64",  AV_CPU_FLAG_RVV_F64 },
-{ "RVBbasic", "rvb_b",AV_CPU_FLAG_RVB_BASIC },
 #elif ARCH_MIPS
 { "MMI",  "mmi",  AV_CPU_FLAG_MMI },
 { "MSA",  "msa",  AV_CPU_FLAG_MSA },
-- 
2.40.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] git email hook

2023-07-16 Thread Nicolas George
Michael Niedermayer (12023-07-15):
> COMBINED_REFCHANGE_REVISION_SUBJECT_TEMPLATE = (
> '%(emailprefix)s%(refname_type)s %(short_refname)s updated: %(oneline)s'
> )

Setting this to:

'%(emailprefix)s %(oneline)s (%(refname_type)s %(short_refname))'

would yield:

[ffmpeg-radio] avradio/sdrdemux: Some corrections to the FM stereo side channel 
(branch master)

instead of:

[ffmpeg-radio] branch master updated: avradio/sdrdemux: Some corrections to the 
FM stereo side channel

and is much closer to what we have now.

Maybe also get rid of %(emailprefix)s, since the mailing-list will add
its own.

Thanks.

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] avcodec/x86/mathops: use constrained immediate operands

2023-07-16 Thread Nicolas George
James Almer (12023-07-15):
> Should fix assembling with binutil as >= 2.41
> 
> Signed-off-by: James Almer 
> ---
> This is IMO a big breakage. binutil's as has until now clipped these values on
> its own, and never required the compiler to do it.

I confirm it fixes the build failures on up-to-date Debian testing.

OTOH, I ran a benchmark (decoding some x264):

474134 mod
488751 orig
494359 mod
498554 orig
508958 orig
514246 orig
518160 mod
528427 orig
530223 mod
534762 mod
536415 orig
548434 orig
550789 orig
551716 mod
553951 orig
561754 orig
572688 mod
580254 mod
581205 orig
583856 mod
583939 orig
584748 orig
594143 orig
600681 mod
607596 mod
612757 mod
621033 orig
624567 orig
626346 mod
627309 mod
628242 mod
638344 mod

The numbers are the sum of the “user” column of the -benchmark_all
output, on an AMD Ryzen 3 3200U and Debaian stable. The mod lines are
when I disabled the two faulty functions.

They are all over the place, it is hard to be sure, but it seems to
indicate that, as you suspected, the benefit is not that big.

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] avcodec/x86/mathops: use constrained immediate operands

2023-07-16 Thread Rémi Denis-Courmont
Le sunnuntaina 16. heinäkuuta 2023, 2.58.32 EEST James Almer a écrit :
> Should fix assembling with binutil as >= 2.41
> 
> Signed-off-by: James Almer 
> ---
> This is IMO a big breakage. binutil's as has until now clipped these values
> on its own, and never required the compiler to do it.

TBH, silently clipping immediate constants sounds like a nasty bug that could 
cause really nasty suprises if somebody every passes an out-of-range constant. 
This has happened to me many times, typically with incidentally out-of-range 
immediate offsets in loads/stores.

(...)

>  __asm__ ("shrl %1, %0\n\t"
>   : "+r" (a)
> - : "ic" ((uint8_t)(-s))
> + : "Ic" ((uint8_t)(-s))

Note that this is not equivalent. Now, if `s` is constant but out of range, 
the compiler will be required to fit it. And it does that by moving it into 
ECX. This is probably not what you want.

AFAICT, you should keep the constraint as it is, and fix the operand value 
instead by masking it, e.g.:

if (__builtin_constant_p(s))
__asm__ ("shrl %1, %0\n\t"
: "+r" (a)
: "i" ((-s) & 0x1f)
);
else
__asm__ ("shrl %1, %0\n\t"
: "+r" (a)
: "c" (-s)
);

(Not sure if the the 0x1f mask is correct, but you get the idea.)

-- 
Rémi Denis-Courmont
http://www.remlab.net/



___
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/3] avfilter: add scale_vt for videotoolbox pix_fmt

2023-07-16 Thread Zhao Zhili
From: Zhao Zhili 

For example,

./ffmpeg -hwaccel videotoolbox \
-hwaccel_output_format videotoolbox_vld \
-i ios-265.mov \
-c:v hevc_videotoolbox \
-profile:v main \
-b:v 3M \
-vf 
scale_vt=w=iw/2:h=ih/2:color_matrix=bt709:color_primaries=bt709:color_transfer=bt709
 \
-c:a copy \
-tag:v hvc1 \
/tmp/test.mp4

Input: hevc (Main 10) (hvc1 / 0x31637668), yuv420p10le(tv, 
bt2020nc/bt2020/arib-std-b67), 3840x2160
Output: hevc (Main) (hvc1 / 0x31637668), yuv420p(tv, bt709, progressive), 
1920x1080
---
 Changelog |   1 +
 configure |   1 +
 doc/filters.texi  |  21 
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/version.h |   4 +-
 libavfilter/vf_scale_vt.c | 244 ++
 7 files changed, 271 insertions(+), 2 deletions(-)
 create mode 100644 libavfilter/vf_scale_vt.c

diff --git a/Changelog b/Changelog
index 3876082844..dadaf15de6 100644
--- a/Changelog
+++ b/Changelog
@@ -25,6 +25,7 @@ version :
 - Raw VVC bitstream parser, muxer and demuxer
 - Bitstream filter for editing metadata in VVC streams
 - Bitstream filter for converting VVC from MP4 to Annex B
+- scale_vt filter for videotoolbox
 
 version 6.0:
 - Radiance HDR image support
diff --git a/configure b/configure
index dab3fb9036..bef6a6cb21 100755
--- a/configure
+++ b/configure
@@ -3835,6 +3835,7 @@ zmq_filter_deps="libzmq"
 zoompan_filter_deps="swscale"
 zscale_filter_deps="libzimg const_nan"
 scale_vaapi_filter_deps="vaapi"
+scale_vt_filter_deps="videotoolbox"
 scale_vulkan_filter_deps="vulkan spirv_compiler"
 vpp_qsv_filter_deps="libmfx"
 vpp_qsv_filter_select="qsvvpp"
diff --git a/doc/filters.texi b/doc/filters.texi
index e5325c7410..500f3ac3cf 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -21175,6 +21175,27 @@ Scale a logo to 1/10th the height of a video, while 
preserving its display aspec
 @end example
 @end itemize
 
+@section scale_vt
+
+Scale and convert the color parameters using VTPixelTransferSession.
+
+The filter accepts the following options:
+@table @option
+@item w
+@item h
+Set the output video dimension expression. Default value is the input 
dimension.
+
+@item color_matrix
+Set the output colorspace matrix.
+
+@item color_primaries
+Set the output color primaries.
+
+@item color_transfer
+Set the output transfer characteristics.
+
+@end table
+
 @section scharr
 Apply scharr operator to input video stream.
 
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 9b7813575a..ef2c87104f 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -457,6 +457,7 @@ OBJS-$(CONFIG_SCALE_CUDA_FILTER) += 
vf_scale_cuda.o scale_eval.o \
 OBJS-$(CONFIG_SCALE_NPP_FILTER)  += vf_scale_npp.o scale_eval.o
 OBJS-$(CONFIG_SCALE_QSV_FILTER)  += vf_vpp_qsv.o
 OBJS-$(CONFIG_SCALE_VAAPI_FILTER)+= vf_scale_vaapi.o scale_eval.o 
vaapi_vpp.o
+OBJS-$(CONFIG_SCALE_VT_FILTER)   += vf_scale_vt.o scale_eval.o
 OBJS-$(CONFIG_SCALE_VULKAN_FILTER)   += vf_scale_vulkan.o vulkan.o 
vulkan_filter.o
 OBJS-$(CONFIG_SCALE2REF_FILTER)  += vf_scale.o scale_eval.o
 OBJS-$(CONFIG_SCALE2REF_NPP_FILTER)  += vf_scale_npp.o scale_eval.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 9a7fadc58d..fefaa94d2b 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -427,6 +427,7 @@ extern const AVFilter ff_vf_scale_cuda;
 extern const AVFilter ff_vf_scale_npp;
 extern const AVFilter ff_vf_scale_qsv;
 extern const AVFilter ff_vf_scale_vaapi;
+extern const AVFilter ff_vf_scale_vt;
 extern const AVFilter ff_vf_scale_vulkan;
 extern const AVFilter ff_vf_scale2ref;
 extern const AVFilter ff_vf_scale2ref_npp;
diff --git a/libavfilter/version.h b/libavfilter/version.h
index c001693e3c..77f38cb9b4 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,8 +31,8 @@
 
 #include "version_major.h"
 
-#define LIBAVFILTER_VERSION_MINOR   8
-#define LIBAVFILTER_VERSION_MICRO 102
+#define LIBAVFILTER_VERSION_MINOR   9
+#define LIBAVFILTER_VERSION_MICRO 100
 
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
diff --git a/libavfilter/vf_scale_vt.c b/libavfilter/vf_scale_vt.c
new file mode 100644
index 00..a7f72c8de9
--- /dev/null
+++ b/libavfilter/vf_scale_vt.c
@@ -0,0 +1,244 @@
+/*
+ * Copyright (c) 2023 Zhao Zhili 
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * 

[FFmpeg-devel] [PATCH 1/3] avcodec/videotoolboxenc: use color parameters conversion from avutil

2023-07-16 Thread Zhao Zhili
From: Zhao Zhili 

---
 libavcodec/videotoolboxenc.c | 137 ---
 1 file changed, 13 insertions(+), 124 deletions(-)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 6114351392..8e493c4f7a 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -1001,132 +1001,20 @@ pbinfo_nomem:
 return AVERROR(ENOMEM);
 }
 
-static int get_cv_color_primaries(AVCodecContext *avctx,
-  CFStringRef *primaries)
-{
-enum AVColorPrimaries pri = avctx->color_primaries;
-switch (pri) {
-case AVCOL_PRI_UNSPECIFIED:
-*primaries = NULL;
-break;
-
-case AVCOL_PRI_BT470BG:
-*primaries = kCVImageBufferColorPrimaries_EBU_3213;
-break;
-
-case AVCOL_PRI_SMPTE170M:
-*primaries = kCVImageBufferColorPrimaries_SMPTE_C;
-break;
-
-case AVCOL_PRI_BT709:
-*primaries = kCVImageBufferColorPrimaries_ITU_R_709_2;
-break;
-
-case AVCOL_PRI_BT2020:
-*primaries = compat_keys.kCVImageBufferColorPrimaries_ITU_R_2020;
-break;
-
-default:
-av_log(avctx, AV_LOG_ERROR, "Color primaries %s is not 
supported.\n", av_color_primaries_name(pri));
-*primaries = NULL;
-return -1;
-}
-
-return 0;
-}
-
-static int get_cv_transfer_function(AVCodecContext *avctx,
-CFStringRef *transfer_fnc,
-CFNumberRef *gamma_level)
+static int get_cv_gamma(AVCodecContext *avctx,
+CFNumberRef *gamma_level)
 {
 enum AVColorTransferCharacteristic trc = avctx->color_trc;
-Float32 gamma;
+Float32 gamma = 0;
 *gamma_level = NULL;
 
-switch (trc) {
-case AVCOL_TRC_UNSPECIFIED:
-*transfer_fnc = NULL;
-break;
-
-case AVCOL_TRC_BT709:
-*transfer_fnc = kCVImageBufferTransferFunction_ITU_R_709_2;
-break;
-
-case AVCOL_TRC_SMPTE240M:
-*transfer_fnc = kCVImageBufferTransferFunction_SMPTE_240M_1995;
-break;
-
-#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_SMPTE_ST_2084_PQ
-case AVCOL_TRC_SMPTE2084:
-*transfer_fnc = kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
-break;
-#endif
-#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_LINEAR
-case AVCOL_TRC_LINEAR:
-*transfer_fnc = kCVImageBufferTransferFunction_Linear;
-break;
-#endif
-#if HAVE_KCVIMAGEBUFFERTRANSFERFUNCTION_ITU_R_2100_HLG
-case AVCOL_TRC_ARIB_STD_B67:
-*transfer_fnc = kCVImageBufferTransferFunction_ITU_R_2100_HLG;
-break;
-#endif
-
-case AVCOL_TRC_GAMMA22:
-gamma = 2.2;
-*transfer_fnc = kCVImageBufferTransferFunction_UseGamma;
-*gamma_level = CFNumberCreate(NULL, kCFNumberFloat32Type, );
-break;
-
-case AVCOL_TRC_GAMMA28:
-gamma = 2.8;
-*transfer_fnc = kCVImageBufferTransferFunction_UseGamma;
-*gamma_level = CFNumberCreate(NULL, kCFNumberFloat32Type, );
-break;
-
-case AVCOL_TRC_BT2020_10:
-case AVCOL_TRC_BT2020_12:
-*transfer_fnc = 
compat_keys.kCVImageBufferTransferFunction_ITU_R_2020;
-break;
-
-default:
-*transfer_fnc = NULL;
-av_log(avctx, AV_LOG_ERROR, "Transfer function %s is not 
supported.\n", av_color_transfer_name(trc));
-return -1;
-}
-
-return 0;
-}
-
-static int get_cv_ycbcr_matrix(AVCodecContext *avctx, CFStringRef *matrix) {
-switch(avctx->colorspace) {
-case AVCOL_SPC_BT709:
-*matrix = kCVImageBufferYCbCrMatrix_ITU_R_709_2;
-break;
-
-case AVCOL_SPC_UNSPECIFIED:
-case AVCOL_SPC_RGB:
-*matrix = NULL;
-break;
-
-case AVCOL_SPC_BT470BG:
-case AVCOL_SPC_SMPTE170M:
-*matrix = kCVImageBufferYCbCrMatrix_ITU_R_601_4;
-break;
-
-case AVCOL_SPC_SMPTE240M:
-*matrix = kCVImageBufferYCbCrMatrix_SMPTE_240M_1995;
-break;
-
-case AVCOL_SPC_BT2020_NCL:
-*matrix = compat_keys.kCVImageBufferYCbCrMatrix_ITU_R_2020;
-break;
-
-default:
-av_log(avctx, AV_LOG_ERROR, "Color space %s is not supported.\n", 
av_color_space_name(avctx->colorspace));
-return -1;
-}
+if (trc == AVCOL_TRC_GAMMA22)
+gamma = 2.2;
+else if (trc == AVCOL_TRC_GAMMA28)
+gamma = 2.8;
 
+if (gamma != 0)
+*gamma_level = CFNumberCreate(NULL, kCFNumberFloat32Type, );
 return 0;
 }
 
@@ -1694,9 +1582,10 @@ static int vtenc_configure_encoder(AVCodecContext *avctx)
 
 vtctx->dts_delta = vtctx->has_b_frames ? -1 : 0;
 
-get_cv_transfer_function(avctx, >transfer_function, _level);
-

[FFmpeg-devel] [PATCH 3/3] avfilter: add transpose_vt for videotoolbox pix_fmt

2023-07-16 Thread Zhao Zhili
From: Zhao Zhili 

---
 Changelog |   1 +
 configure |   2 +
 doc/filters.texi  |  48 +++
 libavfilter/Makefile  |   1 +
 libavfilter/allfilters.c  |   1 +
 libavfilter/version.h |   2 +-
 libavfilter/vf_transpose_vt.c | 246 ++
 7 files changed, 300 insertions(+), 1 deletion(-)
 create mode 100644 libavfilter/vf_transpose_vt.c

diff --git a/Changelog b/Changelog
index dadaf15de6..bbda4f4fd4 100644
--- a/Changelog
+++ b/Changelog
@@ -26,6 +26,7 @@ version :
 - Bitstream filter for editing metadata in VVC streams
 - Bitstream filter for converting VVC from MP4 to Annex B
 - scale_vt filter for videotoolbox
+- transpose_vt filter for videotoolbox
 
 version 6.0:
 - Radiance HDR image support
diff --git a/configure b/configure
index bef6a6cb21..e446a912c9 100755
--- a/configure
+++ b/configure
@@ -3823,6 +3823,7 @@ tonemap_vaapi_filter_deps="vaapi 
VAProcFilterParameterBufferHDRToneMapping"
 tonemap_opencl_filter_deps="opencl const_nan"
 transpose_opencl_filter_deps="opencl"
 transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags"
+transpose_vt_filter_deps="videotoolbox VTPixelRotationSessionCreate"
 transpose_vulkan_filter_deps="vulkan spirv_compiler"
 unsharp_opencl_filter_deps="opencl"
 uspp_filter_deps="gpl avcodec"
@@ -6467,6 +6468,7 @@ check_headers termios.h
 check_headers unistd.h
 check_headers valgrind/valgrind.h
 check_func_headers VideoToolbox/VTCompressionSession.h 
VTCompressionSessionPrepareToEncodeFrames -framework VideoToolbox
+check_func_headers VideoToolbox/VideoToolbox.h VTPixelRotationSessionCreate 
-framework VideoToolbox
 check_headers windows.h
 check_headers asm/types.h
 
diff --git a/doc/filters.texi b/doc/filters.texi
index 500f3ac3cf..1c9bd38cb2 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -27661,6 +27661,54 @@ Default value is @code{0}.
 
 @end table
 
+@section transpose_vt
+
+Transpose rows with columns in the input video and optionally flip it.
+For more in depth examples see the @ref{transpose} video filter, which shares 
mostly the same options.
+
+It accepts the following parameters:
+
+@table @option
+
+@item dir
+Specify the transposition direction.
+
+Can assume the following values:
+@table @samp
+@item cclock_flip
+Rotate by 90 degrees counterclockwise and vertically flip. (default)
+
+@item clock
+Rotate by 90 degrees clockwise.
+
+@item cclock
+Rotate by 90 degrees counterclockwise.
+
+@item clock_flip
+Rotate by 90 degrees clockwise and vertically flip.
+
+@item hflip
+Flip the input video horizontally.
+
+@item vflip
+Flip the input video vertically.
+
+@end table
+
+@item passthrough
+Do not apply the transposition if the input geometry matches the one
+specified by the specified value. It accepts the following values:
+@table @samp
+@item none
+Always apply transposition. (default)
+@item portrait
+Preserve portrait geometry (when @var{height} >= @var{width}).
+@item landscape
+Preserve landscape geometry (when @var{width} >= @var{height}).
+@end table
+
+@end table
+
 @section transpose_vulkan
 
 Transpose rows with columns in the input video and optionally flip it.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index ef2c87104f..30a0e22ef8 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -525,6 +525,7 @@ OBJS-$(CONFIG_TRANSPOSE_FILTER)  += 
vf_transpose.o
 OBJS-$(CONFIG_TRANSPOSE_NPP_FILTER)  += vf_transpose_npp.o
 OBJS-$(CONFIG_TRANSPOSE_OPENCL_FILTER)   += vf_transpose_opencl.o opencl.o 
opencl/transpose.o
 OBJS-$(CONFIG_TRANSPOSE_VAAPI_FILTER)+= vf_transpose_vaapi.o 
vaapi_vpp.o
+OBJS-$(CONFIG_TRANSPOSE_VT_FILTER)   += vf_transpose_vt.o
 OBJS-$(CONFIG_TRANSPOSE_VULKAN_FILTER)   += vf_transpose_vulkan.o vulkan.o 
vulkan_filter.o
 OBJS-$(CONFIG_TRIM_FILTER)   += trim.o
 OBJS-$(CONFIG_UNPREMULTIPLY_FILTER)  += vf_premultiply.o framesync.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index fefaa94d2b..089ad3a0ed 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -492,6 +492,7 @@ extern const AVFilter ff_vf_transpose;
 extern const AVFilter ff_vf_transpose_npp;
 extern const AVFilter ff_vf_transpose_opencl;
 extern const AVFilter ff_vf_transpose_vaapi;
+extern const AVFilter ff_vf_transpose_vt;
 extern const AVFilter ff_vf_transpose_vulkan;
 extern const AVFilter ff_vf_trim;
 extern const AVFilter ff_vf_unpremultiply;
diff --git a/libavfilter/version.h b/libavfilter/version.h
index 77f38cb9b4..4a69d6be98 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -31,7 +31,7 @@
 
 #include "version_major.h"
 
-#define LIBAVFILTER_VERSION_MINOR   9
+#define LIBAVFILTER_VERSION_MINOR  10
 #define LIBAVFILTER_VERSION_MICRO 100
 
 
diff --git a/libavfilter/vf_transpose_vt.c b/libavfilter/vf_transpose_vt.c
new file mode 100644
index 00..197ea5707c
--- /dev/null
+++ 

Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg_mux_init: fix an array declaration

2023-07-16 Thread Rémi Denis-Courmont
Le sunnuntaina 16. heinäkuuta 2023, 11.29.34 EEST Anton Khirnov a écrit :
> map_func is supposed to be an array of const pointer to function
> returning int, not an array of pointer to function returning const int.
> 
> Reported-By: Martin Storsjö
> ---
>  fftools/ffmpeg_mux_init.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
> index 6458414b5f..c2630dd893 100644
> --- a/fftools/ffmpeg_mux_init.c
> +++ b/fftools/ffmpeg_mux_init.c
> @@ -1648,7 +1648,7 @@ read_fail:
> 
>  static int create_streams(Muxer *mux, const OptionsContext *o)
>  {
> -static const int (*map_func[])(Muxer *mux, const OptionsContext *o) = {
> +static int (* const map_func[])(Muxer *mux, const OptionsContext *o) =
> { [AVMEDIA_TYPE_VIDEO]= map_auto_video,
>  [AVMEDIA_TYPE_AUDIO]= map_auto_audio,
>  [AVMEDIA_TYPE_SUBTITLE] = map_auto_subtitle,

LGTM

-- 
Rémi Denis-Courmont
http://www.remlab.net/



___
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] fftools/ffmpeg_mux_init: fix an array declaration

2023-07-16 Thread Anton Khirnov
map_func is supposed to be an array of const pointer to function
returning int, not an array of pointer to function returning const int.

Reported-By: Martin Storsjö
---
 fftools/ffmpeg_mux_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 6458414b5f..c2630dd893 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1648,7 +1648,7 @@ read_fail:
 
 static int create_streams(Muxer *mux, const OptionsContext *o)
 {
-static const int (*map_func[])(Muxer *mux, const OptionsContext *o) = {
+static int (* const map_func[])(Muxer *mux, const OptionsContext *o) = {
 [AVMEDIA_TYPE_VIDEO]= map_auto_video,
 [AVMEDIA_TYPE_AUDIO]= map_auto_audio,
 [AVMEDIA_TYPE_SUBTITLE] = map_auto_subtitle,
-- 
2.40.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 v2 01/14] vvcdec: add thread executor

2023-07-16 Thread Nuo Mi
On Sat, Jul 15, 2023 at 6:38 AM Michael Niedermayer 
wrote:

> On Fri, Jul 07, 2023 at 10:05:27PM +0800, Nuo Mi wrote:
> > The executor design pattern was inroduced by java
> > <
> https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/util/concurrent/Executor.html
> >
> > it also adapted by python
> > 
> > Compared to handcrafted thread pool management, it greatly simplifies
> the thread code.
> > ---
> >  libavcodec/Makefile |   1 +
> >  libavcodec/executor.c   | 182 
> >  libavcodec/executor.h   |  67 +++
> >  libavcodec/vvc/Makefile |   4 +
> >  4 files changed, 254 insertions(+)
> >  create mode 100644 libavcodec/executor.c
> >  create mode 100644 libavcodec/executor.h
> >  create mode 100644 libavcodec/vvc/Makefile
>
> [...]
>
> > +++ b/libavcodec/executor.h
> > @@ -0,0 +1,67 @@
> > +/*
> > + * Copyright (C) 2022 Nuo Mi
> > + *
> > + * This file is part of FFmpeg.
> > + *
> > + * FFmpeg is free software; you can redistribute it and/or
> > + * modify it under the terms of the GNU Lesser General Public
> > + * License as published by the Free Software Foundation; either
> > + * version 2.1 of the License, or (at your option) any later version.
> > + *
> > + * FFmpeg is distributed in the hope that it will be useful,
> > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> > + * Lesser General Public License for more details.
> > + *
> > + * You should have received a copy of the GNU Lesser General Public
> > + * License along with FFmpeg; if not, write to the Free Software
> > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> > + */
> > +
> > +#ifndef AVCODEC_EXECUTOR_H
> > +#define AVCODEC_EXECUTOR_H
> > +
> > +typedef struct Executor Executor;
> > +typedef struct Tasklet Tasklet;
> > +
> > +struct Tasklet {
> > +Tasklet *next;
> > +};
> > +
> > +typedef struct TaskletCallbacks {
> > +void *user_data;
> > +
> > +int local_context_size;
> > +
> > +// return 1 if a's priority > b's priority
> > +int (*priority_higher)(const Tasklet *a, const Tasklet *b);
> > +
> > +// task is ready for run
> > +int (*ready)(const Tasklet *t, void *user_data);
> > +
> > +// run the task
> > +int (*run)(Tasklet *t, void *local_context, void *user_data);
> > +} TaskletCallbacks;
> > +
> > +/**
> > + * Alloc executor
> > + * @param callbacks callback strucutre for executor
> > + * @param thread_count worker thread number
> > + * @return return the executor
> > + */
> > +Executor* ff_executor_alloc(const TaskletCallbacks *callbacks, int
> thread_count);
> > +
> > +/**
> > + * Free executor
> > + * @param e  pointer to executor
> > + */
> > +void ff_executor_free(Executor **e);
> > +
> > +/**
> > + * Add task to executor
> > + * @param e pointer to executor
> > + * @param t pointer to task. If NULL, it will wakeup one work thread
> > + */
> > +void ff_executor_execute(Executor *e, Tasklet *t);
> > +
> > +#endif //AVCODEC_EXECUTOR_H
>
> This would be quite useful outside libavcodec
> In fact id like to use it in libavradio to do the first stage of FFTs
> (which
> are the overwhelming bulk of computations ATM) and maybe eventually later
> stages too
>
Thank you. Glad to hear it.

>
> Maybe this could be made available to the outside of libavcodec
> as avpriv_ or av_ ?
> maybe from libavutil ?
>
avpriv_  is better since it is not a public API for ffmpeg's users(yet)
I will move it to libavutil and send separate patches for the executor
only.

>
> thx
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Take away the freedom of one citizen and you will be jailed, take away
> the freedom of all citizens and you will be congratulated by your peers
> in Parliament.
> ___
> 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 01/14] vvcdec: add thread executor

2023-07-16 Thread Nuo Mi
On Mon, Jul 10, 2023 at 3:41 PM Nuo Mi  wrote:

>
>
> On Sun, Jul 9, 2023 at 5:52 AM Michael Niedermayer 
> wrote:
>
>> On Fri, Jul 07, 2023 at 10:05:27PM +0800, Nuo Mi wrote:
>> > The executor design pattern was inroduced by java
>> > <
>> https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/util/concurrent/Executor.html
>> >
>> > it also adapted by python
>> > 
>> > Compared to handcrafted thread pool management, it greatly simplifies
>> the thread code.
>> > ---
>> >  libavcodec/Makefile |   1 +
>> >  libavcodec/executor.c   | 182 
>> >  libavcodec/executor.h   |  67 +++
>> >  libavcodec/vvc/Makefile |   4 +
>> >  4 files changed, 254 insertions(+)
>> >  create mode 100644 libavcodec/executor.c
>> >  create mode 100644 libavcodec/executor.h
>> >  create mode 100644 libavcodec/vvc/Makefile
>>
>> This seems to need some fallback if pthreads are unavailable
>>
>> src/libavcodec/executor.c: In function ‘executor_worker_task’:
>> src/libavcodec/executor.c:64:5: error: implicit declaration of function
>> ‘pthread_mutex_lock’; did you mean ‘ff_mutex_lock’?
>> [-Werror=implicit-function-declaration]
>>  pthread_mutex_lock(>lock);
>>  ^~
>>  ff_mutex_lock
>> ...
>> cc1: some warnings being treated as errors
>> ffmpeg/ffbuild/common.mak:81: recipe for target 'libavcodec/executor.o'
>> failed
>> make: *** [libavcodec/executor.o] Error 1
>> make: *** Waiting for unfinished jobs
>>
>> thx
>>
>> [...]
>> --
>> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>>
>> Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
>> ___
>> 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".
>>
> Hi Michael,
> Thank you for the information. I will fixed it
>

Hi Michael,
FFmpeg application has a dependency on threads
Once I --disable-pthreads, I can't build ffmpeg for the decoder md5 test.
Could you share with me how to test the decoder when we disabled threads?
Thank you
___
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/2] avformat/mov: add support for 'amve' ambient viewing environment box. As defined in ISOBMFF (ISO/IEC 14496-12) document.

2023-07-16 Thread Damiano Galassi
---
 libavformat/dump.c   | 15 +++
 libavformat/isom.h   |  3 +++
 libavformat/mov.c| 36 
 libavformat/movenc.c | 22 ++
 4 files changed, 76 insertions(+)

diff --git a/libavformat/dump.c b/libavformat/dump.c
index d31e4c2ec6..88dc9dd89c 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -27,6 +27,7 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/log.h"
 #include "libavutil/mastering_display_metadata.h"
+#include "libavutil/ambient_viewing_environment.h"
 #include "libavutil/dovi_meta.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
@@ -366,6 +367,17 @@ static void dump_content_light_metadata(void *ctx, const 
AVPacketSideData *sd)
metadata->MaxCLL, metadata->MaxFALL);
 }
 
+static void dump_ambient_viewing_environment_metadata(void *ctx, const 
AVPacketSideData *sd)
+{
+const AVAmbientViewingEnvironment *ambient =
+(const AVAmbientViewingEnvironment *)sd->data;
+av_log(ctx, AV_LOG_INFO, "Ambient Viewing Environment, "
+   "ambient_illuminance=%f, ambient_light_x=%f, ambient_light_y=%f",
+   av_q2d(ambient->ambient_illuminance),
+   av_q2d(ambient->ambient_light_x),
+   av_q2d(ambient->ambient_light_y));
+}
+
 static void dump_spherical(void *ctx, const AVCodecParameters *par,
const AVPacketSideData *sd)
 {
@@ -497,6 +509,9 @@ static void dump_sidedata(void *ctx, const AVStream *st, 
const char *indent)
 av_log(ctx, AV_LOG_INFO, "SMPTE ST 12-1:2014: ");
 dump_s12m_timecode(ctx, st, sd);
 break;
+case AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT:
+dump_ambient_viewing_environment_metadata(ctx, sd);
+break;
 default:
 av_log(ctx, AV_LOG_INFO, "unknown side data type %d "
"(%"SIZE_SPECIFIER" bytes)", sd->type, sd->size);
diff --git a/libavformat/isom.h b/libavformat/isom.h
index 4b1cd42f0f..e24dfb3dd0 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -29,6 +29,7 @@
 
 #include "libavutil/encryption_info.h"
 #include "libavutil/mastering_display_metadata.h"
+#include "libavutil/ambient_viewing_environment.h"
 #include "libavutil/spherical.h"
 #include "libavutil/stereo3d.h"
 
@@ -249,6 +250,8 @@ typedef struct MOVStreamContext {
 AVMasteringDisplayMetadata *mastering;
 AVContentLightMetadata *coll;
 size_t coll_size;
+AVAmbientViewingEnvironment *ambient;
+size_t ambient_size;
 
 uint32_t format;
 
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 444aca5235..726341736e 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -6010,6 +6010,31 @@ static int mov_read_clli(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 return 0;
 }
 
+static int mov_read_amve(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+{
+MOVStreamContext *sc;
+const int illuminance_den = 1;
+const int ambient_den = 5;
+if (c->fc->nb_streams < 1)
+return AVERROR_INVALIDDATA;
+sc = c->fc->streams[c->fc->nb_streams - 1]->priv_data;
+if (atom.size < 6) {
+av_log(c->fc, AV_LOG_ERROR, "Empty Ambient Viewing Environment Info 
box\n");
+return AVERROR_INVALIDDATA;
+}
+if (sc->ambient){
+av_log(c->fc, AV_LOG_WARNING, "Ignoring duplicate AMVE\n");
+return 0;
+}
+sc->ambient = av_ambient_viewing_environment_alloc(>ambient_size);
+if (!sc->ambient)
+return AVERROR(ENOMEM);
+sc->ambient->ambient_illuminance  = av_make_q(avio_rb32(pb), 
illuminance_den);
+sc->ambient->ambient_light_x = av_make_q(avio_rb16(pb), ambient_den);
+sc->ambient->ambient_light_y = av_make_q(avio_rb16(pb), ambient_den);
+return 0;
+}
+
 static int mov_read_st3d(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
 AVStream *st;
@@ -7921,6 +7946,7 @@ static const MOVParseTableEntry mov_default_parse_table[] 
= {
 { MKTAG('p','c','m','C'), mov_read_pcmc }, /* PCM configuration box */
 { MKTAG('p','i','t','m'), mov_read_pitm },
 { MKTAG('e','v','c','C'), mov_read_glbl },
+{ MKTAG('a','m','v','e'), mov_read_amve }, /* ambient viewing environment box 
*/
 { 0, NULL }
 };
 
@@ -8391,6 +8417,7 @@ static int mov_read_close(AVFormatContext *s)
 av_freep(>spherical);
 av_freep(>mastering);
 av_freep(>coll);
+av_freep(>ambient);
 }
 
 av_freep(>dv_demux);
@@ -8756,6 +8783,15 @@ static int mov_read_header(AVFormatContext *s)
 
 sc->coll = NULL;
 }
+if (sc->ambient) {
+err = av_stream_add_side_data(st, 
AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT,
+  (uint8_t *)sc->ambient,
+  sc->ambient_size);
+if (err < 0)
+return err;
+
+sc->ambient = NULL;
+}
 break;
 }
 }
diff --git 

[FFmpeg-devel] [PATCH v2 1/2] avcodec: add ambient viewing environment packet side data.

2023-07-16 Thread Damiano Galassi
---
 fftools/ffprobe.c | 3 +++
 libavcodec/avpacket.c | 1 +
 libavcodec/decode.c   | 1 +
 libavcodec/packet.h   | 7 +++
 4 files changed, 12 insertions(+)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 1ff76ce809..9f17567897 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2360,6 +2360,9 @@ static void print_pkt_side_data(WriterContext *w,
 AVContentLightMetadata *metadata = (AVContentLightMetadata 
*)sd->data;
 print_int("max_content", metadata->MaxCLL);
 print_int("max_average", metadata->MaxFALL);
+} else if (sd->type == AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT) {
+print_ambient_viewing_environment(
+w, (const AVAmbientViewingEnvironment *)sd->data);
 } else if (sd->type == AV_PKT_DATA_DYNAMIC_HDR10_PLUS) {
 AVDynamicHDRPlus *metadata = (AVDynamicHDRPlus *)sd->data;
 print_dynamic_hdr10_plus(w, metadata);
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 5fef65e97a..db9c0c95e8 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -300,6 +300,7 @@ const char *av_packet_side_data_name(enum 
AVPacketSideDataType type)
 case AV_PKT_DATA_DOVI_CONF:  return "DOVI configuration 
record";
 case AV_PKT_DATA_S12M_TIMECODE:  return "SMPTE ST 12-1:2014 
timecode";
 case AV_PKT_DATA_DYNAMIC_HDR10_PLUS: return "HDR10+ Dynamic 
Metadata (SMPTE 2094-40)";
+case AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT:return "Ambient viewing 
environment";
 }
 return NULL;
 }
diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index a19cca1a7c..68f82e8980 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1408,6 +1408,7 @@ int ff_decode_frame_props_from_pkt(const AVCodecContext 
*avctx,
 { AV_PKT_DATA_S12M_TIMECODE,  AV_FRAME_DATA_S12M_TIMECODE 
},
 { AV_PKT_DATA_DYNAMIC_HDR10_PLUS, 
AV_FRAME_DATA_DYNAMIC_HDR_PLUS },
 { AV_PKT_DATA_SKIP_SAMPLES,   AV_FRAME_DATA_SKIP_SAMPLES },
+{ 
AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT,AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT
 },
 };
 
 frame->pts  = pkt->pts;
diff --git a/libavcodec/packet.h b/libavcodec/packet.h
index f28e7e7011..199baad763 100644
--- a/libavcodec/packet.h
+++ b/libavcodec/packet.h
@@ -299,6 +299,13 @@ enum AVPacketSideDataType {
  */
 AV_PKT_DATA_DYNAMIC_HDR10_PLUS,
 
+/**
+ * Ambient viewing environment metadata, as defined by H.274.. This 
metadata
+ * should be associated with a video stream and contains data in the form
+ * of the AVAmbientViewingEnvironment struct.
+ */
+AV_PKT_DATA_AMBIENT_VIEWING_ENVIRONMENT,
+
 /**
  * The number of side data types.
  * This is not part of the public API/ABI in the sense that it may
-- 
2.39.2 (Apple Git-143)

___
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".