[FFmpeg-cvslog] avdevice/oss_dec: account for sample size when computing timestamp

2022-06-19 Thread Matt Jacobson
ffmpeg | branch: master | Matt Jacobson  | Wed Jun  1 
05:06:16 2022 -0400| [b3e261bab381f43ab5f842725d30479d511d] | committer: 
Marton Balint

avdevice/oss_dec: account for sample size when computing timestamp

Don't assume each sample is one byte in size. Doing so results in wrong and
occasionally non-monotonically-increasing timestamps.

Fix nearby cosmetic typo.

Signed-off-by: Marton Balint 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b3e261bab381f43ab5f842725d30479d511d
---

 libavdevice/oss.c | 4 +++-
 libavdevice/oss.h | 1 +
 libavdevice/oss_dec.c | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavdevice/oss.c b/libavdevice/oss.c
index eddc2ddf1a..b042f58875 100644
--- a/libavdevice/oss.c
+++ b/libavdevice/oss.c
@@ -102,9 +102,11 @@ int ff_oss_audio_open(AVFormatContext *s1, int is_output,
 switch(tmp) {
 case AFMT_S16_LE:
 s->codec_id = AV_CODEC_ID_PCM_S16LE;
+s->sample_size = 2;
 break;
 case AFMT_S16_BE:
 s->codec_id = AV_CODEC_ID_PCM_S16BE;
+s->sample_size = 2;
 break;
 default:
 av_log(s1, AV_LOG_ERROR, "Soundcard does not support 16 bit sample 
format\n");
@@ -112,7 +114,7 @@ int ff_oss_audio_open(AVFormatContext *s1, int is_output,
 return AVERROR(EIO);
 }
 err=ioctl(audio_fd, SNDCTL_DSP_SETFMT, &tmp);
-CHECK_IOCTL_ERROR(SNDCTL_DSP_SETFMTS)
+CHECK_IOCTL_ERROR(SNDCTL_DSP_SETFMT)
 
 tmp = (s->channels == 2);
 err = ioctl(audio_fd, SNDCTL_DSP_STEREO, &tmp);
diff --git a/libavdevice/oss.h b/libavdevice/oss.h
index 66d1a34cf6..f1da2b1bec 100644
--- a/libavdevice/oss.h
+++ b/libavdevice/oss.h
@@ -30,6 +30,7 @@ typedef struct OSSAudioData {
 AVClass *class;
 int fd;
 int sample_rate;
+int sample_size; /* in bytes ! */
 int channels;
 int frame_size; /* in bytes ! */
 enum AVCodecID codec_id;
diff --git a/libavdevice/oss_dec.c b/libavdevice/oss_dec.c
index d3dbe77cf9..2cdc4324e8 100644
--- a/libavdevice/oss_dec.c
+++ b/libavdevice/oss_dec.c
@@ -91,7 +91,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket 
*pkt)
 bdelay += abufi.bytes;
 }
 /* subtract time represented by the number of bytes in the audio fifo */
-cur_time -= (bdelay * 100LL) / (s->sample_rate * s->channels);
+cur_time -= (bdelay * 100LL) / (s->sample_rate * s->sample_size * 
s->channels);
 
 /* convert to wanted units */
 pkt->pts = cur_time;

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

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


[FFmpeg-cvslog] lavfi/colorspace: add ff_matrix_mul_3x3_vec

2022-06-19 Thread rcombs
ffmpeg | branch: master | rcombs  | Thu Jun  2 02:59:19 2022 
-0500| [a5b3b65dc067b900be55d7edcea3cecd65a133f0] | committer: rcombs

lavfi/colorspace: add ff_matrix_mul_3x3_vec

Signed-off-by: rcombs 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a5b3b65dc067b900be55d7edcea3cecd65a133f0
---

 libavfilter/colorspace.c | 11 +++
 libavfilter/colorspace.h |  1 +
 2 files changed, 12 insertions(+)

diff --git a/libavfilter/colorspace.c b/libavfilter/colorspace.c
index 7f74fe5113..f0bd14be18 100644
--- a/libavfilter/colorspace.c
+++ b/libavfilter/colorspace.c
@@ -62,6 +62,17 @@ void ff_matrix_mul_3x3(double dst[3][3],
 src2[m][1] * src1[1][n] +
 src2[m][2] * src1[2][n];
 }
+
+void ff_matrix_mul_3x3_vec(double dst[3], const double vec[3], const double 
mat[3][3])
+{
+int m;
+
+for (m = 0; m < 3; m++)
+dst[m] = vec[0] * mat[m][0] +
+ vec[1] * mat[m][1] +
+ vec[2] * mat[m][2];
+}
+
 /*
  * see e.g. http://www.brucelindbloom.com/index.html?Eqn_RGB_XYZ_Matrix.html
  */
diff --git a/libavfilter/colorspace.h b/libavfilter/colorspace.h
index 879518d242..4d98b1da2e 100644
--- a/libavfilter/colorspace.h
+++ b/libavfilter/colorspace.h
@@ -29,6 +29,7 @@
 void ff_matrix_invert_3x3(const double in[3][3], double out[3][3]);
 void ff_matrix_mul_3x3(double dst[3][3],
const double src1[3][3], const double src2[3][3]);
+void ff_matrix_mul_3x3_vec(double dst[3], const double vec[3], const double 
mat[3][3]);
 void ff_fill_rgb2xyz_table(const AVPrimaryCoefficients *coeffs,
const AVWhitepointCoefficients *wp,
double rgb2xyz[3][3]);

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

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


[FFmpeg-cvslog] lavfi/drawutils: improve colorspace support

2022-06-19 Thread rcombs
ffmpeg | branch: master | rcombs  | Thu Jun  2 03:48:25 2022 
-0500| [6c3a82f0433de8ff9c35def971a736056cc8ff38] | committer: rcombs

lavfi/drawutils: improve colorspace support

- Introduce ff_draw_init2, which takes explicit colorspace and range
  args
- Use lavu/csp and lavfi/colorspace for conversion, rather than the
  lavu/colorspace.h macros
- Use the passed-in colorspace when performing RGB->YUV conversions

The upshot of this is:
- Support for YUV spaces other than BT601
- Better rounding for all conversions
- Particular rounding improvements in >8-bit formats, which previously
  used simple left-shifts
- Support for limited-range RGB
- Support for full-range YUV in non-J pixfmts

Due to the rounding improvements, this results in a large number of
minor changes to FATE tests.

Signed-off-by: rcombs 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=6c3a82f0433de8ff9c35def971a736056cc8ff38
---

 libavfilter/drawutils.c|  84 ++--
 libavfilter/drawutils.h|  26 +-
 tests/ref/fate/filter-chromashift-smear|  10 +-
 tests/ref/fate/filter-chromashift-wrap |  10 +-
 tests/ref/fate/filter-decimate | 480 ++---
 tests/ref/fate/filter-fps-down |  22 +-
 tests/ref/fate/filter-fps-down-eof-pass|  22 +-
 tests/ref/fate/filter-fps-down-round-down  |  20 +-
 tests/ref/fate/filter-fps-down-round-up|  22 +-
 tests/ref/fate/filter-fps-start-drop   |  12 +-
 tests/ref/fate/filter-fps-start-fill   |  12 +-
 tests/ref/fate/filter-fps-up   |  28 +-
 tests/ref/fate/filter-fps-up-round-down|  28 +-
 tests/ref/fate/filter-fps-up-round-up  |  28 +-
 tests/ref/fate/filter-framerate-12bit-down | 100 ++---
 tests/ref/fate/filter-framerate-12bit-up   | 120 +++---
 tests/ref/fate/filter-framerate-down   |   2 +-
 tests/ref/fate/filter-framerate-up |  20 +-
 .../ref/fate/filter-metadata-signalstats-yuv420p10 |   2 +-
 tests/ref/fate/filter-minterpolate-down|   2 +-
 tests/ref/fate/filter-minterpolate-up  |  20 +-
 tests/ref/fate/filter-mpdecimate   |  40 +-
 tests/ref/fate/filter-overlay_yuv420p10|   6 +-
 tests/ref/fate/filter-overlay_yuv422p10|   6 +-
 tests/ref/fate/filter-pixfmts-pad  |  84 ++--
 tests/ref/fate/filter-pixfmts-tinterlace_pad   |  22 +-
 tests/ref/fate/filter-testsrc2-yuv420p | 140 +++---
 tests/ref/fate/filter-testsrc2-yuv444p | 140 +++---
 tests/ref/fate/filter-tpad-add |   4 +-
 tests/ref/fate/filter-tpad-clone   |   8 +-
 tests/ref/fate/filter-unsharp-yuv420p10|  40 +-
 tests/ref/fate/filter-untile   |  16 +-
 32 files changed, 807 insertions(+), 769 deletions(-)

diff --git a/libavfilter/drawutils.c b/libavfilter/drawutils.c
index 65ed61aa92..b4083b9a95 100644
--- a/libavfilter/drawutils.c
+++ b/libavfilter/drawutils.c
@@ -23,9 +23,10 @@
 
 #include "libavutil/avassert.h"
 #include "libavutil/avutil.h"
-#include "libavutil/colorspace.h"
+#include "libavutil/csp.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/pixdesc.h"
+#include "colorspace.h"
 #include "drawutils.h"
 #include "formats.h"
 
@@ -76,13 +77,14 @@ int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat 
pix_fmt)
 return 0;
 }
 
-int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned 
flags)
+int ff_draw_init2(FFDrawContext *draw, enum AVPixelFormat format, enum 
AVColorSpace csp,
+  enum AVColorRange range, unsigned flags)
 {
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format);
+const AVLumaCoefficients *luma = NULL;
 const AVComponentDescriptor *c;
 unsigned i, nb_planes = 0;
 int pixelstep[MAX_PLANES] = { 0 };
-int full_range = 0;
 int depthb = 0;
 
 if (!desc || !desc->name)
@@ -91,9 +93,17 @@ int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat 
format, unsigned flags)
 return AVERROR(ENOSYS);
 if (desc->flags & ~(AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_RGB | 
AV_PIX_FMT_FLAG_ALPHA))
 return AVERROR(ENOSYS);
-if (format == AV_PIX_FMT_YUVJ420P || format == AV_PIX_FMT_YUVJ422P || 
format == AV_PIX_FMT_YUVJ444P ||
-format == AV_PIX_FMT_YUVJ411P || format == AV_PIX_FMT_YUVJ440P)
-full_range = 1;
+if (csp == AVCOL_SPC_UNSPECIFIED)
+csp = (desc->flags & AV_PIX_FMT_FLAG_RGB) ? AVCOL_SPC_RGB : 
AVCOL_SPC_SMPTE170M;
+if (!(desc->flags & AV_PIX_FMT_FLAG_RGB) && !(luma = 
av_csp_luma_coeffs_from_avcsp(csp)))
+return AVERROR(EINVAL);
+if (range == AVCOL_RANGE_UNSPECIFIED)
+range = (format == AV_PIX_FMT_YUVJ420P || format == 
AV_PIX_FMT_YUVJ422P ||
+ format == AV_PIX_FMT_YUVJ444P || format == 
AV_PIX_FMT_YUV