[FFmpeg-cvslog] avformat/internal: Don't auto-include os_support.h

2023-09-02 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Aug 31 19:28:10 2023 +0200| [ee485b4051c24e2cebe46b426294b346f0f5fff4] | 
committer: Andreas Rheinhardt

avformat/internal: Don't auto-include os_support.h

It includes various Windows-specific headers when compiling
for Windows and these sometimes cause issues: E.g. winbase.h
defines IGNORE, which clashes with a macro used in the Matroska
muxer (since 884653ee5be03ed38db957c14fad51b300611c8c) and demuxer.

This header provides fallback defines for various stuff that is
mostly not used directly by (de)muxers at all:
mkdir, rename, rmdir, unlink, access, poll, pollfd, nfds_t,
closesocket, socklen_t, fstat, stat, lseek, SHUT_(RD|WR|RDWR)
and various POLL* constants.

Ergo fix this issue by not auto-including this header in lots
of places via an inclusion in internal.h and instead include
it everywhere where the above stuff is used (most of these
translation units already included os_support.h).

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/img2dec.c  | 1 +
 libavformat/internal.h | 1 -
 libavformat/rtsp.h | 1 +
 libavformat/utils.c| 1 +
 4 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 15fd67927f..2761cb37a4 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -36,6 +36,7 @@
 #include "avio_internal.h"
 #include "internal.h"
 #include "img2.h"
+#include "os_support.h"
 #include "libavcodec/jpegxl_parse.h"
 #include "libavcodec/mjpeg.h"
 #include "libavcodec/vbn.h"
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 594afd731d..53e70ccb53 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -26,7 +26,6 @@
 #include "libavcodec/packet_internal.h"
 
 #include "avformat.h"
-#include "os_support.h"
 
 #define MAX_URL_SIZE 4096
 
diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
index 6e500fd56a..83b2e3f4fb 100644
--- a/libavformat/rtsp.h
+++ b/libavformat/rtsp.h
@@ -28,6 +28,7 @@
 #include "network.h"
 #include "httpauth.h"
 #include "internal.h"
+#include "os_support.h"
 
 #include "libavutil/log.h"
 #include "libavutil/opt.h"
diff --git a/libavformat/utils.c b/libavformat/utils.c
index cf4d68bff9..c722743744 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -37,6 +37,7 @@
 #if CONFIG_NETWORK
 #include "network.h"
 #endif
+#include "os_support.h"
 
 static AVMutex avformat_mutex = AV_MUTEX_INITIALIZER;
 

___
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] avformat/matroska(dec|enc): Rename macro to avoid clash with winbase.h

2023-09-02 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Thu Aug 31 19:55:05 2023 +0200| [fc993e7a53c2e7a18f8d49b3a52cadf47580b82c] | 
committer: Andreas Rheinhardt

avformat/matroska(dec|enc): Rename macro to avoid clash with winbase.h

winbase.h defines IGNORE and is included via bzlib.h when compiling
for Windows. So rename this macro to NOTHING.
Also rename the muxer macro for consistency.

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/matroskadec.c | 4 ++--
 libavformat/matroskaenc.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 21f52ccab2..fda77b0b89 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -2171,8 +2171,8 @@ static int mkv_stereo3d_conv(AVStream *st, 
MatroskaVideoStereoModeType stereo_mo
 } stereo_mode_conv [] = {
 #define STEREO_MODE_CONV(STEREOMODETYPE, STEREO3DTYPE, FLAGS, WDIV, HDIV, 
WEBM) \
 [(STEREOMODETYPE)] = { .type = (STEREO3DTYPE), .flags = (FLAGS) },
-#define IGNORE(STEREOMODETYPE, WDIV, HDIV, WEBM)
-STEREOMODE_STEREO3D_MAPPING(STEREO_MODE_CONV, IGNORE)
+#define NOTHING(STEREOMODETYPE, WDIV, HDIV, WEBM)
+STEREOMODE_STEREO3D_MAPPING(STEREO_MODE_CONV, NOTHING)
 };
 AVStereo3D *stereo;
 int ret;
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index d26c0fa059..bf2ca7106b 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -1633,9 +1633,9 @@ static int mkv_write_stereo_mode(AVFormatContext *s, 
EbmlWriter *writer,
  * values to be in the range 0..254. */
 #define STEREOMODE(STEREOMODETYPE, STEREO3DTYPE, FLAGS, WDIV, HDIV, WEBM) \
 [(STEREO3DTYPE)][!!((FLAGS) & AV_STEREO3D_FLAG_INVERT)] = (STEREOMODETYPE) 
+ 1,
-#define IGNORE(STEREOMODETYPE, WDIV, HDIV, WEBM)
+#define NOTHING(STEREOMODETYPE, WDIV, HDIV, WEBM)
 static const unsigned char conversion_table[][2] = {
-STEREOMODE_STEREO3D_MAPPING(STEREOMODE, IGNORE)
+STEREOMODE_STEREO3D_MAPPING(STEREOMODE, NOTHING)
 };
 int fmt;
 

___
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] avformat/wavarc: fix data end calculation

2023-09-02 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat Sep  2 16:17:00 
2023 +0200| [fb06a443609817ce9883cf37d0af78de4d27c992] | committer: Paul B Mahol

avformat/wavarc: fix data end calculation

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

 libavformat/wavarc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/wavarc.c b/libavformat/wavarc.c
index 2b5d1b99eb..542a2abbc1 100644
--- a/libavformat/wavarc.c
+++ b/libavformat/wavarc.c
@@ -70,8 +70,10 @@ static int wavarc_read_header(AVFormatContext *s)
 if (avio_r8(pb))
 return AVERROR_INVALIDDATA;
 id = avio_rl32(pb);
+w->data_end = avio_tell(pb);
 if (avio_read(pb, data, sizeof(data)) != sizeof(data))
 return AVERROR(EIO);
+w->data_end += 16LL + AV_RL32(data + 4);
 fmt_len = AV_RL32(data + 32);
 if (fmt_len < 12)
 return AVERROR_INVALIDDATA;
@@ -98,8 +100,7 @@ static int wavarc_read_header(AVFormatContext *s)
 if (id != MKTAG('d','a','t','a'))
 avio_skip(pb, avio_rl32(pb));
 } while (id != MKTAG('d','a','t','a') && !avio_feof(pb));
-w->data_end = avio_rl32(pb);
-w->data_end += avio_tell(pb);
+avio_skip(pb, 4);
 
 if (AV_RL32(par->extradata + 16) != MKTAG('R','I','F','F'))
 return AVERROR_INVALIDDATA;

___
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] avcodec/wavarc: fix bugs in arithmetic coding mode

2023-09-02 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat Sep  2 15:46:24 
2023 +0200| [9c2206a13bb19591ff2fd80bbbe0c35700bf89b2] | committer: Paul B Mahol

avcodec/wavarc: fix bugs in arithmetic coding mode

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

 libavcodec/wavarc.c | 74 ++---
 1 file changed, 48 insertions(+), 26 deletions(-)

diff --git a/libavcodec/wavarc.c b/libavcodec/wavarc.c
index 4bdd548d5f..b954e8800c 100644
--- a/libavcodec/wavarc.c
+++ b/libavcodec/wavarc.c
@@ -412,13 +412,13 @@ static int ac_init(AVCodecContext *avctx,
 return 0;
 }
 
-static unsigned ac_get_prob(WavArcContext *s)
+static uint16_t ac_get_prob(WavArcContext *s)
 {
-return ((s->freq_range - 1) + ((unsigned)s->ac_value - 
(unsigned)s->ac_low) *
-(unsigned)s->freq_range) / (((unsigned)s->ac_high - 
(unsigned)s->ac_low) + 1) & 0xu;
+return ((s->freq_range - 1) + (s->ac_value - s->ac_low) * s->freq_range) /
+   ((s->ac_high - s->ac_low) + 1U);
 }
 
-static unsigned ac_map_symbol(WavArcContext *s, unsigned prob)
+static uint8_t ac_map_symbol(WavArcContext *s, uint16_t prob)
 {
 int idx = 255;
 
@@ -435,33 +435,43 @@ static int ac_normalize(AVCodecContext *avctx, 
WavArcContext *s, GetBitContext *
 {
 int range;
 
-range = (unsigned)s->ac_high - (unsigned)s->ac_low + 1;
-s->ac_high = (int16_t)((range * (unsigned)s->range_high) / 
(unsigned)s->freq_range) + -1 + s->ac_low;
-s->ac_low += (int16_t)((range * (unsigned)s->range_low)  / 
(unsigned)s->freq_range);
+if (s->ac_high < s->ac_low)
+goto fail;
+
+range = (s->ac_high - s->ac_low) + 1;
+s->ac_high = (range * s->range_high) / s->freq_range + s->ac_low - 1;
+s->ac_low += (range * s->range_low)  / s->freq_range;
+
+if (s->ac_high < s->ac_low)
+goto fail;
 
 for (;;) {
 if ((s->ac_high & 0x8000) != (s->ac_low & 0x8000)) {
-if ((s->ac_low & 0x4000) == 0 || (s->ac_high & 0x4000) != 0)
+if (((s->ac_low & 0x4000) == 0) || ((s->ac_high & 0x4000) != 0))
 return 0;
 s->ac_value ^= 0x4000;
 s->ac_low   &= 0x3fff;
 s->ac_high  |= 0x4000;
 }
 
-s->ac_low = s->ac_low << 1;
-s->ac_high = s->ac_high * 2 + 1;
-if (s->ac_high < s->ac_low) {
-av_log(avctx, AV_LOG_ERROR, "invalid state\n");
-return AVERROR_INVALIDDATA;
-}
+s->ac_low = s->ac_low * 2;
+s->ac_high = s->ac_high * 2 | 1;
+if (s->ac_high < s->ac_low)
+goto fail;
 
 if (get_bits_left(gb) <= 0) {
 av_log(avctx, AV_LOG_ERROR, "overread in arithmetic coder\n");
-return AVERROR_INVALIDDATA;
+goto fail;
 }
 
 s->ac_value = s->ac_value * 2 + get_bits1(gb);
+if (s->ac_low > s->ac_value || s->ac_high < s->ac_value)
+goto fail;
 }
+
+fail:
+av_log(avctx, AV_LOG_ERROR, "invalid state\n");
+return AVERROR_INVALIDDATA;
 }
 
 static void ac_init_model(WavArcContext *s)
@@ -484,11 +494,11 @@ static int ac_read_model(AVCodecContext *avctx,
 end = get_bits(gb, 8);
 
 for (;;) {
-while (start <= end)
+while (start <= end) {
+if (get_bits_left(gb) < 8)
+return AVERROR_INVALIDDATA;
 s->model[start++] = get_bits(gb, 8);
-
-if (get_bits_left(gb) < 8)
-return AVERROR_INVALIDDATA;
+}
 
 if (get_bits_left(gb) < 8)
 return AVERROR_INVALIDDATA;
@@ -568,9 +578,9 @@ static int decode_5elp(AVCodecContext *avctx,
 }
 
 for (int n = 0; n < s->nb_samples; n++) {
-unsigned prob = ac_get_prob(s);
-prob = ac_map_symbol(s, prob);
-ac_out[n] = prob - 0x80;
+uint16_t prob = ac_get_prob(s);
+int ac = ac_map_symbol(s, prob);
+ac_out[n] = ac - 0x80;
 if ((ret = ac_normalize(avctx, s, &ac_gb)) < 0)
 return ret;
 }
@@ -620,11 +630,16 @@ static int decode_5elp(AVCodecContext *avctx,
 case 20:
 case 7:
 for (int n = 0; n < s->nb_samples; n++)
-samples[n + 70] = ac_out[n] + samples[n + 69] * 3 - samples[n 
+ 68] * 3 + samples[n + 67];
+samples[n + 70] += ac_out[n] + samples[n + 69] * 3 - samples[n 
+ 68] * 3 + samples[n + 67];
 finished = 1;
 break;
 case 19:
 case 6:
+for (int n = 0; n < 70; n++) {
+ac_pred[n] = samples[n];
+samples[n] = 0;
+}
+
 for (int n = 0; n < s->nb_samples; n++) {
 int sum = 15;
 
@@ -633,24 +648,31 @@ static int decode_5elp(AVCodecContext *avctx,
 
 samples[n + 70] += ac_out[n] + (sum >> 4);
 }
+
+for 

[FFmpeg-cvslog] doc: mention OSQ support

2023-09-02 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Sat Sep  2 21:32:37 
2023 +0200| [966088cc6a12ef5a553b1f857c233674894c3f75] | committer: Paul B Mahol

doc: mention OSQ support

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

 doc/general_contents.texi | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/doc/general_contents.texi b/doc/general_contents.texi
index 8ac121dee1..c48c812a31 100644
--- a/doc/general_contents.texi
+++ b/doc/general_contents.texi
@@ -615,6 +615,7 @@ library:
 @item raw video @tab X @tab X
 @item raw id RoQ@tab X @tab
 @item raw OBU   @tab X @tab X
+@item raw OSQ   @tab   @tab X
 @item raw SBC   @tab X @tab X
 @item raw Shorten   @tab   @tab X
 @item raw TAK   @tab   @tab X
@@ -1298,6 +1299,7 @@ following image formats are supported:
 @item On2 AVC (Audio for Video Codec) @tab @tab  X
 @item Opus   @tab  E  @tab  X
 @tab encoding supported through external library libopus
+@item OSQ (Original Sound Quality)  @tab @tab  X
 @item PCM A-law  @tab  X  @tab  X
 @item PCM mu-law @tab  X  @tab  X
 @item PCM Archimedes VIDC@tab  X  @tab  X

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