[FFmpeg-cvslog] avformat/hls: Fixes overwriting existing #EXT-X-PROGRAM-DATE-TIME value in HLS playlist

2020-12-08 Thread Vignesh Ravichandran
ffmpeg | branch: master | Vignesh Ravichandran 
 | Tue Dec  1 15:58:40 2020 +0530| 
[45a673ebee2e603a87c0ecb259c0027c14321018] | committer: liuqi05

avformat/hls: Fixes overwriting existing #EXT-X-PROGRAM-DATE-TIME value in HLS 
playlist

fix ticket: 8989

This is is due to the following behavior in the current code:
1. The initial_prog_date_time gets set to the current local time
2. The existing playlist (.m3u8) file gets parsed and the segments
   present are added to the variant stream
3. The new segment is created and added
4. The existing segments and the new segment are written to the
   playlist file. The initial_prog_date_time from point 1 is used
   for calculating "#EXT-X-PROGRAM-DATE-TIME" for the segments,
   which results in incorrect "#EXT-X-PROGRAM-DATE-TIME" values
   for existing segments
The following approach fixes this bug:
1. Add a new variable "discont_program_date_time" of type double
   to HLSSegment struct
2. Store the "EXT-X-PROGRAM-DATE-TIME" value from the existing
   segments in this variable
3. When writing to playlist file if "discont_program_date_time"
   is set, then use that value for "EXT-X-PROGRAM-DATE-TIME" else
   use the value present in vs->initial_prog_date_time

Signed-off-by: Vignesh Ravichandran 
Signed-off-by: liuqi05 

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

 libavformat/hlsenc.c | 33 ++---
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index cbfd8f7c0d..9bce374605 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -88,6 +88,7 @@ typedef struct HLSSegment {
 char iv_string[KEYSIZE*2 + 1];
 
 struct HLSSegment *next;
+double discont_program_date_time;
 } HLSSegment;
 
 typedef enum HLSFlags {
@@ -1124,6 +1125,7 @@ static int hls_append_segment(struct AVFormatContext *s, 
HLSContext *hls,
 en->keyframe_size = vs->video_keyframe_size;
 en->next = NULL;
 en->discont  = 0;
+en->discont_program_date_time = 0;
 
 if (vs->discontinuity) {
 en->discont = 1;
@@ -1148,7 +1150,8 @@ static int hls_append_segment(struct AVFormatContext *s, 
HLSContext *hls,
 
 if (hls->max_nb_segments && vs->nb_entries >= hls->max_nb_segments) {
 en = vs->segments;
-vs->initial_prog_date_time += en->duration;
+if (!en->next->discont_program_date_time && 
!en->discont_program_date_time)
+vs->initial_prog_date_time += en->duration;
 vs->segments = en->next;
 if (en && hls->flags & HLS_DELETE_SEGMENTS &&
 #if FF_API_HLS_WRAP
@@ -1182,6 +1185,7 @@ static int parse_playlist(AVFormatContext *s, const char 
*url, VariantStream *vs
 char line[MAX_URL_SIZE];
 const char *ptr;
 const char *end;
+double discont_program_date_time = 0;
 
 if ((ret = ffio_open_whitelist(&in, url, AVIO_FLAG_READ,
&s->interrupt_callback, NULL,
@@ -1236,7 +1240,25 @@ static int parse_playlist(AVFormatContext *s, const char 
*url, VariantStream *vs
 av_strlcpy(vs->iv_string, ptr, sizeof(vs->iv_string));
 }
 }
+} else if (av_strstart(line, "#EXT-X-PROGRAM-DATE-TIME:", &ptr)) {
+struct tm program_date_time;
+int y,M,d,h,m,s;
+double ms;
+if (sscanf(ptr, "%d-%d-%dT%d:%d:%d.%lf", &y, &M, &d, &h, &m, &s, 
&ms) != 7) {
+ret = AVERROR_INVALIDDATA;
+goto fail;
+}
+
+program_date_time.tm_year = y - 1900;
+program_date_time.tm_mon = M - 1;
+program_date_time.tm_mday = d;
+program_date_time.tm_hour = h;
+program_date_time.tm_min = m;
+program_date_time.tm_sec = s;
+program_date_time.tm_isdst = -1;
 
+discont_program_date_time = mktime(&program_date_time);
+discont_program_date_time += (double)(ms / 1000);
 } else if (av_strstart(line, "#", NULL)) {
 continue;
 } else if (line[0]) {
@@ -1250,8 +1272,9 @@ static int parse_playlist(AVFormatContext *s, const char 
*url, VariantStream *vs
 is_segment = 0;
 new_start_pos = avio_tell(vs->avf->pb);
 vs->size = new_start_pos - vs->start_pos;
-vs->initial_prog_date_time -= vs->duration; // this is a 
previously existing segment
 ret = hls_append_segment(s, hls, vs, vs->duration, 
vs->start_pos, vs->size);
+vs->last_segment->discont_program_date_time = 
discont_program_date_time;
+discont_program_date_time += vs->duration;
 if (ret < 0)
 goto fail;
 vs->start_pos = new_start_pos;
@@ -1572,7 +1595,11 @@ static int hls_window(AVFormatContext *s, int last, 
VariantStream *vs)
 ret = ff_hls_write_file_entry(byterange_mode ? hls->m3u

[FFmpeg-cvslog] hlsenc: expand hls_fmp4_init_filename with strftime()

2020-12-08 Thread Nikola Pajkovsky
ffmpeg | branch: master | Nikola Pajkovsky  | Tue Oct 27 
12:28:59 2020 +0100| [3ffed80ebadbd8c10167fd6297d0c2d4797ec6f7] | committer: 
liuqi05

hlsenc: expand hls_fmp4_init_filename with strftime()

the init.mp4 can be expanded with strftime the same way as
hls_segment_filename.

Signed-off-by: Nikola Pajkovsky 
Signed-off-by: liuqi05 

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

 doc/muxers.texi  |  7 +++
 libavformat/hlsenc.c | 54 +---
 2 files changed, 50 insertions(+), 11 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 813b4678f4..179b923951 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -859,6 +859,13 @@ fmp4 files may be used in HLS version 7 and above.
 @item hls_fmp4_init_filename @var{filename}
 Set filename to the fragment files header file, default filename is 
@file{init.mp4}.
 
+Use @code{-strftime 1} on @var{filename} to expand the segment filename with 
localtime.
+@example
+ffmpeg -i in.nut  -hls_segment_type fmp4 -strftime 1 -hls_fmp4_init_filename 
"%s_init.mp4" out.m3u8
+@end example
+This will produce init like this
+@file{1602678741_init.mp4}
+
 @item hls_fmp4_init_resend
 Resend init file after m3u8 file refresh every time, default is @var{0}.
 
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 9bce374605..cafe0e8c69 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -260,6 +260,29 @@ typedef struct HLSContext {
 int has_video_m3u8; /* has video stream m3u8 list */
 } HLSContext;
 
+static int strftime_expand(const char *fmt, char **dest)
+{
+int r = 1;
+time_t now0;
+struct tm *tm, tmpbuf;
+char *buf;
+
+buf = av_mallocz(MAX_URL_SIZE);
+if (!buf)
+return AVERROR(ENOMEM);
+
+time(&now0);
+tm = localtime_r(&now0, &tmpbuf);
+r = strftime(buf, MAX_URL_SIZE, fmt, tm);
+if (!r) {
+av_free(buf);
+return AVERROR(EINVAL);
+}
+*dest = buf;
+
+return r;
+}
+
 static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename,
   AVDictionary **options)
 {
@@ -1687,19 +1710,15 @@ static int hls_start(AVFormatContext *s, VariantStream 
*vs)
 ff_format_set_url(oc, filename);
 } else {
 if (c->use_localtime) {
-time_t now0;
-struct tm *tm, tmpbuf;
-int bufsize = strlen(vs->basename) + MAX_URL_SIZE;
-char *buf = av_mallocz(bufsize);
-if (!buf)
-return AVERROR(ENOMEM);
-time(&now0);
-tm = localtime_r(&now0, &tmpbuf);
-ff_format_set_url(oc, buf);
-if (!strftime(oc->url, bufsize, vs->basename, tm)) {
+int r;
+char *expanded = NULL;
+
+r = strftime_expand(vs->basename, &expanded);
+if (r < 0) {
 av_log(oc, AV_LOG_ERROR, "Could not get segment filename with 
strftime\n");
-return AVERROR(EINVAL);
+return r;
 }
+ff_format_set_url(oc, expanded);
 
 err = sls_flag_use_localtime_filename(oc, c, vs);
 if (err < 0) {
@@ -3007,6 +3026,19 @@ static int hls_init(AVFormatContext *s)
 return ret;
 }
 
+if (hls->use_localtime) {
+int r;
+char *expanded = NULL;
+
+r = strftime_expand(vs->fmp4_init_filename, &expanded);
+if (r < 0) {
+  av_log(s, AV_LOG_ERROR, "Could not get segment filename 
with strftime\n");
+  return r;
+}
+av_free(vs->fmp4_init_filename);
+vs->fmp4_init_filename = expanded;
+}
+
 p = strrchr(vs->m3u8_name, '/');
 if (p) {
 char tmp = *(++p);

___
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] avfilter/aeval: add timeline support for aeval

2020-12-08 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Tue Dec  8 15:17:49 
2020 +0100| [3021c611f55d013229be640434424cb6529bd376] | committer: Paul B Mahol

avfilter/aeval: add timeline support for aeval

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

 libavfilter/aeval.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavfilter/aeval.c b/libavfilter/aeval.c
index 4c62c98097..d5437431ab 100644
--- a/libavfilter/aeval.c
+++ b/libavfilter/aeval.c
@@ -483,6 +483,7 @@ AVFilter ff_af_aeval = {
 .inputs= aeval_inputs,
 .outputs   = aeval_outputs,
 .priv_class= &aeval_class,
+.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
 };
 
 #endif /* CONFIG_AEVAL_FILTER */

___
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] New commits on branch master

2020-12-08 Thread Git System
URL:
http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fa4532a1f767c092656836de62797d71ff42cde0
Author: Andreas Rheinhardt 
Date:   Mon Nov 23 05:12:02 2020 +0100

avcodec/wmadec: Apply VLC offset during init

Signed-off-by: Andreas Rheinhardt 

URL:
http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e5b416daddd0435571c3483621c6953c56e7cf9a
Author: Andreas Rheinhardt 
Date:   Mon Nov 23 05:09:57 2020 +0100

avcodec/wmadec: Reduce the size of tables used to initialize VLC

By switching from ff_init_vlc_sparse() to ff_init_vlc_from_lengths() one
can replace a table of codes of type uint16_t by a table of symbols of
type uint8_t, saving space.

Signed-off-by: Andreas Rheinhardt 

URL:
http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=14be39e44a7dd5f378e93a9fea0e1ca1e6eba9d6
Author: Andreas Rheinhardt 
Date:   Mon Nov 23 04:57:03 2020 +0100

avcodec/ivi: Make initializing VLCs thread-safe

This automatically makes indeo4/5 init-threadsafe.

Signed-off-by: Andreas Rheinhardt 

URL:
http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ee4c129c11a195fa604e4d940e92c36b7425dafa
Author: Andreas Rheinhardt 
Date:   Mon Nov 23 04:33:33 2020 +0100

avcodec/dsddec: Inline constant

Signed-off-by: Andreas Rheinhardt 

URL:
http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4f5bd6177da43263a47239d96ec1776ccf46368e
Author: Andreas Rheinhardt 
Date:   Mon Nov 23 04:20:07 2020 +0100

avcodec/dsd: Make initializing DSD tables thread-safe

This automatically makes the DSD formats as well as DST and WavPack
init-threadsafe.

Signed-off-by: Andreas Rheinhardt 

URL:
http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fd5d66af744462a97237fa0474e77924c71729ec
Author: Andreas Rheinhardt 
Date:   Mon Nov 23 04:09:56 2020 +0100

avcodec/wavpack: Fix leak on init failure

Signed-off-by: Andreas Rheinhardt 

URL:
http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=480761c82fcbf7e3571618b2226d2441a2ea45b8
Author: Andreas Rheinhardt 
Date:   Mon Nov 23 03:21:34 2020 +0100

avcodec/h261enc: Remove unused function parameter

Signed-off-by: Andreas Rheinhardt 

URL:
http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f0f28626c0ce64f3c7e9e59df0c139e9cffbdbfa
Author: Andreas Rheinhardt 
Date:   Mon Nov 23 03:49:35 2020 +0100

avcodec/asvdec: Reindentation

Signed-off-by: Andreas Rheinhardt 

URL:
http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=103e8edd5eda20e343102bba65fb04aad73a232c
Author: Andreas Rheinhardt 
Date:   Mon Nov 23 03:49:05 2020 +0100

avcodec/asvdec: Make decoders init-threadsafe

Signed-off-by: Andreas Rheinhardt 

URL:
http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3e11a7866dc8d1849c4b485f446205d522dbd938
Author: Andreas Rheinhardt 
Date:   Mon Nov 23 02:45:27 2020 +0100

avcodec/sinewin: Fix wrong number of elements of array declaration

There are actually only 14 elements in each ff_sine_windows array.

Signed-off-by: Andreas Rheinhardt 

URL:
http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7184b811690a816861976af2acac18df05512001
Author: Andreas Rheinhardt 
Date:   Sun Nov 22 23:42:40 2020 +0100

avcodec/aactab: Make AAC encoder and decoders actually init-threadsafe

Commit 1a29804558c13ef512d9ef73a9b0d782af4fa5f2 guarded several
initializations of static data in the AAC decoders with an AVOnce and
set the FF_CODEC_CAP_INIT_THREADSAFE flag, believing the former to be
sufficient for the latter. It wasn't, because several of these static
tables are shared with other components, so that there might be data
races if they are initialized from multiple threads. This affected
initializing the ff_sine_* tables as well as initializing the
ff_aac_pow*sf_tab tables (shared between both decoders and encoder) as
well as ff_aac_kbd_* tables (shared between encoder and floating point
decoder).

Commit 3d62e7a30fa552be52d12b31e3e0f79153aff891 set the
FF_CODEC_CAP_INIT_THREADSAFE flag for the AAC encoder. More explicitly,
this commit used the same AVOnce to guard initializing ff_aac_pow*sf_tab
in the encoder and to guard initializing the static data of each
decoder; the ensuing catastrophe was "fixed" in commit
ec0719264cb9a9d5cbaf225da48929aea24997a3 by using a single AVOnce
for each codec again. But the codec cap has not been removed and
therefore the encoder claimed to be init-threadsafe, but wasn't, because
of the same tables as above.

The ff_sine_* tables as well as ff_aac_pow*sf_tab tables have already
been fixed; this commit deals with the ff_aac_kbd_* tables, making the
encoder as well as the floating-point decoder init-threadsafe (the
fixed-point decoder is it already).

Signed-off-by: Andreas Rheinhardt 

URL:
http://git.vi

[FFmpeg-cvslog] avformat/framecrcenc: Don't read after the end of side-data

2020-12-08 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Dec  6 01:45:14 2020 +0100| [b8fe417c1937436ec978dbc20e747f0e30453b81] | 
committer: Andreas Rheinhardt

avformat/framecrcenc: Don't read after the end of side-data

Nothing guarantees that the size of side data containing a palette
is actually divisible by four (although it should be); but for
big-endian systems, an algorithm is used that presupposed this.
So switch to an algorithm that does not overread: It processes
four bytes at a time, but only if all of them are contained in
the side data.

Signed-off-by: Andreas Rheinhardt 

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

 libavformat/framecrcenc.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/libavformat/framecrcenc.c b/libavformat/framecrcenc.c
index a567b5299c..f7c48779a0 100644
--- a/libavformat/framecrcenc.c
+++ b/libavformat/framecrcenc.c
@@ -23,6 +23,7 @@
 
 #include "libavutil/adler32.h"
 #include "libavutil/avstring.h"
+#include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "internal.h"
 
@@ -52,16 +53,17 @@ static int framecrc_write_packet(struct AVFormatContext *s, 
AVPacket *pkt)
 if (pkt->flags != AV_PKT_FLAG_KEY)
 av_strlcatf(buf, sizeof(buf), ", F=0x%0X", pkt->flags);
 if (pkt->side_data_elems) {
-int i, j;
+int i;
 av_strlcatf(buf, sizeof(buf), ", S=%d", pkt->side_data_elems);
 
 for (i=0; iside_data_elems; i++) {
+const AVPacketSideData *const sd = &pkt->side_data[i];
 uint32_t side_data_crc = 0;
 if (HAVE_BIGENDIAN && AV_PKT_DATA_PALETTE == 
pkt->side_data[i].type) {
-for (j=0; jside_data[i].size; j++) {
-side_data_crc = av_adler32_update(side_data_crc,
-  pkt->side_data[i].data + 
(j^3),
-  1);
+for (int j = 0; j < sd->size / 4; j++) {
+uint8_t buf[4];
+AV_WL32(buf, AV_RB32(sd->data + 4 * j));
+side_data_crc = av_adler32_update(side_data_crc, buf, 4);
 }
 } else {
 side_data_crc = av_adler32_update(0,

___
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/framecrcenc: Make side-data checksums endian-independent

2020-12-08 Thread Andreas Rheinhardt
ffmpeg | branch: master | Andreas Rheinhardt  | 
Sun Dec  6 03:48:22 2020 +0100| [0dac317ba31cd10e9df26722ac96adc3f6ef3eb3] | 
committer: Andreas Rheinhardt

avformat/framecrcenc: Make side-data checksums endian-independent

Do this by converting big-endian side data to little endian for
checksumming.

Reviewed-by: Andriy Gelman 
Reviewed-by: Michael Niedermayer 
Signed-off-by: Andreas Rheinhardt 

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

 libavformat/framecrcenc.c | 59 +++
 1 file changed, 54 insertions(+), 5 deletions(-)

diff --git a/libavformat/framecrcenc.c b/libavformat/framecrcenc.c
index f7c48779a0..1fbe4aa4ee 100644
--- a/libavformat/framecrcenc.c
+++ b/libavformat/framecrcenc.c
@@ -21,9 +21,11 @@
 
 #include 
 
+#include "config.h"
 #include "libavutil/adler32.h"
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
+#include "libavcodec/avcodec.h"
 #include "avformat.h"
 #include "internal.h"
 
@@ -43,6 +45,17 @@ static int framecrc_write_header(struct AVFormatContext *s)
 return ff_framehash_write_header(s);
 }
 
+static av_unused void inline bswap(char *buf, int offset, int size)
+{
+if (size == 8) {
+uint64_t val = AV_RN64(buf + offset);
+AV_WN64(buf + offset, av_bswap64(val));
+} else if (size == 4) {
+uint32_t val = AV_RN32(buf + offset);
+AV_WN32(buf + offset, av_bswap32(val));
+}
+}
+
 static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
 {
 uint32_t crc = av_adler32_update(0, pkt->data, pkt->size);
@@ -58,17 +71,53 @@ static int framecrc_write_packet(struct AVFormatContext *s, 
AVPacket *pkt)
 
 for (i=0; iside_data_elems; i++) {
 const AVPacketSideData *const sd = &pkt->side_data[i];
+const uint8_t *data = sd->data;
 uint32_t side_data_crc = 0;
-if (HAVE_BIGENDIAN && AV_PKT_DATA_PALETTE == 
pkt->side_data[i].type) {
+
+switch (sd->type) {
+#if HAVE_BIGENDIAN
+uint8_t bswap_buf[FFMAX(sizeof(AVCPBProperties),
+sizeof(AVProducerReferenceTime))];
+case AV_PKT_DATA_PALETTE:
+case AV_PKT_DATA_REPLAYGAIN:
+case AV_PKT_DATA_DISPLAYMATRIX:
+case AV_PKT_DATA_STEREO3D:
+case AV_PKT_DATA_AUDIO_SERVICE_TYPE:
+case AV_PKT_DATA_FALLBACK_TRACK:
+case AV_PKT_DATA_MASTERING_DISPLAY_METADATA:
+case AV_PKT_DATA_SPHERICAL:
+case AV_PKT_DATA_CONTENT_LIGHT_LEVEL:
+case AV_PKT_DATA_S12M_TIMECODE:
 for (int j = 0; j < sd->size / 4; j++) {
 uint8_t buf[4];
 AV_WL32(buf, AV_RB32(sd->data + 4 * j));
 side_data_crc = av_adler32_update(side_data_crc, buf, 4);
 }
-} else {
-side_data_crc = av_adler32_update(0,
-  pkt->side_data[i].data,
-  pkt->side_data[i].size);
+break;
+case AV_PKT_DATA_CPB_PROPERTIES:
+#define BSWAP(struct, field) bswap(bswap_buf, offsetof(struct, field), 
sizeof(((struct){0}).field))
+if (sd->size == sizeof(AVCPBProperties)) {
+memcpy(bswap_buf, sd->data, sizeof(AVCPBProperties));
+data = bswap_buf;
+BSWAP(AVCPBProperties, max_bitrate);
+BSWAP(AVCPBProperties, min_bitrate);
+BSWAP(AVCPBProperties, avg_bitrate);
+BSWAP(AVCPBProperties, buffer_size);
+BSWAP(AVCPBProperties, vbv_delay);
+}
+goto pod;
+case AV_PKT_DATA_PRFT:
+if (sd->size == sizeof(AVProducerReferenceTime)) {
+memcpy(bswap_buf, sd->data, 
sizeof(AVProducerReferenceTime));
+data = bswap_buf;
+BSWAP(AVProducerReferenceTime, wallclock);
+BSWAP(AVProducerReferenceTime, flags);
+}
+goto pod;
+pod:
+#endif
+default:
+side_data_crc = av_adler32_update(0, data, sd->size);
 }
 av_strlcatf(buf, sizeof(buf), ", %8d, 0x%08"PRIx32, 
pkt->side_data[i].size, side_data_crc);
 }

___
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/libaom: Support monochrome encoding with libaom >= 2.0.1

2020-12-08 Thread Philip Langdale
ffmpeg | branch: master | Philip Langdale  | Mon Dec  7 
16:33:29 2020 -0800| [40135829b613f875ce71c2cc2265e74ccc6b4c71] | committer: 
Philip Langdale

avcodec/libaom: Support monochrome encoding with libaom >= 2.0.1

Monochrome encoding with libaom was buggy for a long time, but this was
finally sorted out in libaom 2.0.1 (2.0.0 is almost there but was still
buggy in realtime mode).

We'll keep support for libaom 1.x around until the LTS distros that
include it are EOL (which is still a long time from now).

Fixes: https://trac.ffmpeg.org/ticket/7599

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

 Changelog  |  1 +
 libavcodec/libaomenc.c | 42 --
 libavcodec/version.h   |  2 +-
 3 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index 503317dfae..8f5e849f8d 100644
--- a/Changelog
+++ b/Changelog
@@ -51,6 +51,7 @@ version :
 - asubcut filter
 - Microsoft Paint (MSP) version 2 decoder
 - Microsoft Paint (MSP) demuxer
+- AV1 monochrome encoding support via libaom >= 2.0.1
 
 
 version 4.3:
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 2b0581b15a..342d0883e4 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -338,6 +338,9 @@ static int set_pix_fmt(AVCodecContext *avctx, 
aom_codec_caps_t codec_caps,
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
 enccfg->g_bit_depth = enccfg->g_input_bit_depth = desc->comp[0].depth;
 switch (avctx->pix_fmt) {
+case AV_PIX_FMT_GRAY8:
+enccfg->monochrome = 1;
+/* Fall-through */
 case AV_PIX_FMT_YUV420P:
 enccfg->g_profile = FF_PROFILE_AV1_MAIN;
 *img_fmt = AOM_IMG_FMT_I420;
@@ -351,6 +354,10 @@ static int set_pix_fmt(AVCodecContext *avctx, 
aom_codec_caps_t codec_caps,
 enccfg->g_profile = FF_PROFILE_AV1_HIGH;
 *img_fmt = AOM_IMG_FMT_I444;
 return 0;
+case AV_PIX_FMT_GRAY10:
+case AV_PIX_FMT_GRAY12:
+enccfg->monochrome = 1;
+/* Fall-through */
 case AV_PIX_FMT_YUV420P10:
 case AV_PIX_FMT_YUV420P12:
 if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) {
@@ -1158,6 +1165,15 @@ static const enum AVPixelFormat av1_pix_fmts[] = {
 AV_PIX_FMT_NONE
 };
 
+static const enum AVPixelFormat av1_pix_fmts_with_gray[] = {
+AV_PIX_FMT_YUV420P,
+AV_PIX_FMT_YUV422P,
+AV_PIX_FMT_YUV444P,
+AV_PIX_FMT_GBRP,
+AV_PIX_FMT_GRAY8,
+AV_PIX_FMT_NONE
+};
+
 static const enum AVPixelFormat av1_pix_fmts_highbd[] = {
 AV_PIX_FMT_YUV420P,
 AV_PIX_FMT_YUV422P,
@@ -1174,13 +1190,35 @@ static const enum AVPixelFormat av1_pix_fmts_highbd[] = 
{
 AV_PIX_FMT_NONE
 };
 
+static const enum AVPixelFormat av1_pix_fmts_highbd_with_gray[] = {
+AV_PIX_FMT_YUV420P,
+AV_PIX_FMT_YUV422P,
+AV_PIX_FMT_YUV444P,
+AV_PIX_FMT_GBRP,
+AV_PIX_FMT_YUV420P10,
+AV_PIX_FMT_YUV422P10,
+AV_PIX_FMT_YUV444P10,
+AV_PIX_FMT_YUV420P12,
+AV_PIX_FMT_YUV422P12,
+AV_PIX_FMT_YUV444P12,
+AV_PIX_FMT_GBRP10,
+AV_PIX_FMT_GBRP12,
+AV_PIX_FMT_GRAY8,
+AV_PIX_FMT_GRAY10,
+AV_PIX_FMT_GRAY12,
+AV_PIX_FMT_NONE
+};
+
 static av_cold void av1_init_static(AVCodec *codec)
 {
+int supports_monochrome = aom_codec_version() >= 20001;
 aom_codec_caps_t codec_caps = aom_codec_get_caps(aom_codec_av1_cx());
 if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH)
-codec->pix_fmts = av1_pix_fmts_highbd;
+codec->pix_fmts = supports_monochrome ? av1_pix_fmts_highbd_with_gray :
+av1_pix_fmts_highbd;
 else
-codec->pix_fmts = av1_pix_fmts;
+codec->pix_fmts = supports_monochrome ? av1_pix_fmts_with_gray :
+av1_pix_fmts;
 
 if (aom_codec_version_major() < 2)
 codec->capabilities |= AV_CODEC_CAP_EXPERIMENTAL;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 1c10d105f6..5b92afe60a 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR  58
 #define LIBAVCODEC_VERSION_MINOR 115
-#define LIBAVCODEC_VERSION_MICRO 101
+#define LIBAVCODEC_VERSION_MICRO 102
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \

___
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/mpegvideo_enc: check for SpeedHQ encoder

2020-12-08 Thread Gyan Doshi
ffmpeg | branch: master | Gyan Doshi  | Tue Dec  8 19:20:41 
2020 +0530| [b9b719fedc532ebc6bbde711d60985e8cb5957b2] | committer: Gyan Doshi

avcodec/mpegvideo_enc: check for SpeedHQ encoder

Avoids build failure when mpegvideo_enc is built but SpeedHQ encoder
isn't.

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

 libavcodec/mpegvideo_enc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index 7afc789ec0..243d3ca632 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -2996,7 +2996,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
 s->first_slice_line = 1;
 s->ptr_lastgob = s->pb.buf;
 for (mb_y_order = s->start_mb_y; mb_y_order < s->end_mb_y; mb_y_order++) {
-if (s->codec_id == AV_CODEC_ID_SPEEDHQ) {
+if (CONFIG_SPEEDHQ_ENCODER && s->codec_id == AV_CODEC_ID_SPEEDHQ) {
 int first_in_slice;
 mb_y = ff_speedhq_mb_y_order_to_mb(mb_y_order, s->mb_height, 
&first_in_slice);
 if (first_in_slice && mb_y_order != s->start_mb_y)

___
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] avfilter/cropdetect: add option for initial skip

2020-12-08 Thread Gyan Doshi
ffmpeg | branch: master | Gyan Doshi  | Tue Dec  8 19:10:37 
2020 +0530| [e5119ad3377e2c4cb20a7aff56448d035b55] | committer: Gyan Doshi

avfilter/cropdetect: add option for initial skip

The cropdetect filter, at present, skips the first two frames. This
behaviour is hardcoded.

New option 'skip' allows users to change this. Convenient for when
input is a single image or a trimmed video stream.

Default is kept at 2 to preserve current behaviour.

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

 doc/filters.texi|  4 
 libavfilter/vf_cropdetect.c | 10 ++
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 62d6e26a02..d9f606604e 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -8899,6 +8899,10 @@ The value which the width/height should be divisible by. 
It defaults to
 get only even dimensions (needed for 4:2:2 video). 16 is best when
 encoding to most video codecs.
 
+@item skip
+Set the number of initial frames for which evaluation is skipped.
+Default is 2. Range is 0 to INT_MAX.
+
 @item reset_count, reset
 Set the counter that determines after how many frames cropdetect will
 reset the previously detected largest video area and start over to
diff --git a/libavfilter/vf_cropdetect.c b/libavfilter/vf_cropdetect.c
index 7c7d0b953a..5ae87cad2d 100644
--- a/libavfilter/vf_cropdetect.c
+++ b/libavfilter/vf_cropdetect.c
@@ -37,6 +37,7 @@ typedef struct CropDetectContext {
 int x1, y1, x2, y2;
 float limit;
 int round;
+int skip;
 int reset_count;
 int frame_nb;
 int max_pixsteps[4];
@@ -127,10 +128,10 @@ static av_cold int init(AVFilterContext *ctx)
 {
 CropDetectContext *s = ctx->priv;
 
-s->frame_nb = -2;
+s->frame_nb = -1 * s->skip;
 
-av_log(ctx, AV_LOG_VERBOSE, "limit:%f round:%d reset_count:%d\n",
-   s->limit, s->round, s->reset_count);
+av_log(ctx, AV_LOG_VERBOSE, "limit:%f round:%d skip:%d reset_count:%d\n",
+   s->limit, s->round, s->skip, s->reset_count);
 
 return 0;
 }
@@ -167,7 +168,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*frame)
 int outliers, last_y;
 int limit = lrint(s->limit);
 
-// ignore first 2 frames - they may be empty
+// ignore first s->skip frames
 if (++s->frame_nb > 0) {
 metadata = &frame->metadata;
 
@@ -247,6 +248,7 @@ static const AVOption cropdetect_options[] = {
 { "limit", "Threshold below which the pixel is considered black", 
OFFSET(limit),   AV_OPT_TYPE_FLOAT, { .dbl = 24.0/255 }, 0, 65535, FLAGS },
 { "round", "Value by which the width/height should be divisible", 
OFFSET(round),   AV_OPT_TYPE_INT, { .i64 = 16 }, 0, INT_MAX, FLAGS },
 { "reset", "Recalculate the crop area after this many frames",
OFFSET(reset_count), AV_OPT_TYPE_INT, { .i64 = 0 },  0, INT_MAX, FLAGS },
+{ "skip",  "Number of initial frames to skip",
OFFSET(skip),AV_OPT_TYPE_INT, { .i64 = 2 },  0, INT_MAX, FLAGS },
 { "reset_count", "Recalculate the crop area after this many 
frames",OFFSET(reset_count),AV_OPT_TYPE_INT,{ .i64 = 0 },  0, INT_MAX, FLAGS },
 { "max_outliers", "Threshold count of outliers",  
OFFSET(max_outliers),AV_OPT_TYPE_INT, { .i64 = 0 },  0, INT_MAX, FLAGS },
 { NULL }

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