[FFmpeg-cvslog] avfilter/vf_w3fdif: fix parity in frame mode

2021-01-15 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Fri Jan 15 11:34:17 
2021 +0100| [d4902751cb111d8f66d481d670cad079228e9f73] | committer: Paul B Mahol

avfilter/vf_w3fdif: fix parity in frame mode

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

 libavfilter/vf_w3fdif.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_w3fdif.c b/libavfilter/vf_w3fdif.c
index a714235ecf..ce98b86e4a 100644
--- a/libavfilter/vf_w3fdif.c
+++ b/libavfilter/vf_w3fdif.c
@@ -382,7 +382,9 @@ static int deinterlace_slice(AVFilterContext *ctx, void 
*arg, int jobnr, int nb_
 const int start = (height * jobnr) / nb_jobs;
 const int end = (height * (jobnr+1)) / nb_jobs;
 const int max = s->max;
-const int tff = (s->field == (s->parity == -1 ? cur->top_field_first == 
cur->interlaced_frame : s->parity == 0 ? !cur->interlaced_frame : 
cur->interlaced_frame));
+const int interlaced = cur->interlaced_frame;
+const int tff = s->field == (s->parity == -1 ? interlaced ? 
cur->top_field_first : 1 :
+ s->parity ^ 1);
 int j, y_in, y_out;
 
 /* copy unchanged the lines of the field */

___
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] movenc: Present durations in mvhd/tkhd/mdhd as they are after edits

2021-01-15 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Sun Dec 20 
00:45:42 2020 +0200| [c2424b1f35a1c6c06f1f9fe5f77a7157ed84e1cd] | committer: 
Martin Storsjö

movenc: Present durations in mvhd/tkhd/mdhd as they are after edits

If the edit lists remove parts of the output timeline, or add a
delay to it, this should be included in the mvhd/tkhd/mdhd durations,
which should correspond to the edit lists.

For tracks starting with pts < 0, the edit list trims out the segment
before pts=0. For tracks starting with pts > 0, a delay element is
added in the edit list, delaying the start of the track data.

In both cases, the practical effect is that the post-edit output
is as if the track had started with pts = 0. Thus calculate the range
from pts=0 to end_pts, for the purposes of mvhd/tkhd/mdhd, unless
edit lists explicitly are disabled.

mov_write_edts_tag needs to operate on the actual pts duration of
the track samples, not the duration that already takes the edit
list effect into account.

Signed-off-by: Martin Storsjö 

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

 libavformat/movenc.c | 41 
 tests/ref/fate/copy-trac3074 |  2 +-
 tests/ref/fate/gaplessenc-itunes-to-ipod-aac |  2 +-
 tests/ref/fate/gaplessenc-pcm-to-mov-aac |  2 +-
 tests/ref/fate/movenc|  2 +-
 5 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 18fa3f9b5e..372c04295d 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2904,21 +2904,50 @@ static int mov_write_minf_tag(AVFormatContext *s, 
AVIOContext *pb, MOVMuxContext
 return update_size(pb, pos);
 }
 
-static int64_t calc_pts_duration(MOVMuxContext *mov, MOVTrack *track)
+static void get_pts_range(MOVMuxContext *mov, MOVTrack *track,
+  int64_t *start, int64_t *end)
 {
 if (track->tag == MKTAG('t','m','c','d') && mov->nb_meta_tmcd) {
 // tmcd tracks gets track_duration set in mov_write_moov_tag from
 // another track's duration, while the end_pts may be left at zero.
 // Calculate the pts duration for that track instead.
-return av_rescale(calc_pts_duration(mov, 
&mov->tracks[track->src_track]),
-  track->timescale, 
mov->tracks[track->src_track].timescale);
+get_pts_range(mov, &mov->tracks[track->src_track], start, end);
+*start = av_rescale(*start, track->timescale,
+mov->tracks[track->src_track].timescale);
+*end   = av_rescale(*end, track->timescale,
+mov->tracks[track->src_track].timescale);
+return;
 }
 if (track->end_pts != AV_NOPTS_VALUE &&
 track->start_dts != AV_NOPTS_VALUE &&
 track->start_cts != AV_NOPTS_VALUE) {
-return track->end_pts - (track->start_dts + track->start_cts);
+*start = track->start_dts + track->start_cts;
+*end   = track->end_pts;
+return;
 }
-return track->track_duration;
+*start = 0;
+*end   = track->track_duration;
+}
+
+static int64_t calc_samples_pts_duration(MOVMuxContext *mov, MOVTrack *track)
+{
+int64_t start, end;
+get_pts_range(mov, track, &start, &end);
+return end - start;
+}
+
+// Calculate the actual duration of the track, after edits.
+// If it starts with a pts < 0, that is removed by the edit list.
+// If it starts with a pts > 0, the edit list adds a delay before that.
+// Thus, with edit lists enabled, the post-edit output of the file is
+// starting with pts=0.
+static int64_t calc_pts_duration(MOVMuxContext *mov, MOVTrack *track)
+{
+int64_t start, end;
+get_pts_range(mov, track, &start, &end);
+if (mov->use_editlist != 0)
+start = 0;
+return end - start;
 }
 
 static int mov_write_mdhd_tag(AVIOContext *pb, MOVMuxContext *mov,
@@ -3145,7 +3174,7 @@ static int mov_write_tapt_tag(AVIOContext *pb, MOVTrack 
*track)
 static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov,
   MOVTrack *track)
 {
-int64_t duration = av_rescale_rnd(calc_pts_duration(mov, track),
+int64_t duration = av_rescale_rnd(calc_samples_pts_duration(mov, track),
   MOV_TIMESCALE, track->timescale,
   AV_ROUND_UP);
 int version = duration < INT32_MAX ? 0 : 1;
diff --git a/tests/ref/fate/copy-trac3074 b/tests/ref/fate/copy-trac3074
index b5b0b6a60b..78b6015ae8 100644
--- a/tests/ref/fate/copy-trac3074
+++ b/tests/ref/fate/copy-trac3074
@@ -1,4 +1,4 @@
-620e3ab4ee6241bec55ea2ec4ef42908 *tests/data/fate/copy-trac3074.mp4
+da6122873fb83ce4340cf5d0ab8d475e *tests/data/fate/copy-trac3074.mp4
 334012 tests/data/fate/copy-trac3074.mp4
 #tb 0: 1/48000
 #media_type 0: audio
diff --git a/tests/ref/fate/gaplessenc-itunes-to-ipod-aac 
b/tests/ref/fate/gaplessenc-itunes-

[FFmpeg-cvslog] avutil/timecode: fix sscanf format string with garbage at the end

2021-01-15 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Sat Dec  5 
09:39:38 2020 +0800| [6696a07ac62bfec49dd488510a719367918b9f7a] | committer: 
Limin Wang

avutil/timecode: fix sscanf format string with garbage at the end

Signed-off-by: Limin Wang 

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

 libavutil/timecode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/timecode.c b/libavutil/timecode.c
index c1fa445d31..5106f642b9 100644
--- a/libavutil/timecode.c
+++ b/libavutil/timecode.c
@@ -252,7 +252,7 @@ int av_timecode_init_from_string(AVTimecode *tc, AVRational 
rate, const char *st
 char c;
 int hh, mm, ss, ff, flags;
 
-if (sscanf(str, "%d:%d:%d%c%d", &hh, &mm, &ss, &c, &ff) != 5) {
+if (sscanf(str, "%02u:%02u:%02u%c%02u", &hh, &mm, &ss, &c, &ff) != 5) {
 av_log(log_ctx, AV_LOG_ERROR, "Unable to parse timecode, "
   "syntax: hh:mm:ss[:;.]ff\n");
 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] avformat/udp: add memory alloc checks

2021-01-15 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Thu Jan  7 
18:22:07 2021 +0800| [5ef20244de8bf5f3d208041c43d9f082e1fb879e] | committer: 
Limin Wang

avformat/udp: add memory alloc checks

Reviewed-by: Marton Balint 
Signed-off-by: Limin Wang 

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

 libavformat/udp.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index c4e403bbfc..9b9d3de197 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -903,6 +903,10 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 if ((!is_output && s->circular_buffer_size) || (is_output && s->bitrate && 
s->circular_buffer_size)) {
 /* start the task going */
 s->fifo = av_fifo_alloc(s->circular_buffer_size);
+if (!s->fifo) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
 ret = pthread_mutex_init(&s->mutex, NULL);
 if (ret != 0) {
 av_log(h, AV_LOG_ERROR, "pthread_mutex_init failed : %s\n", 
strerror(ret));

___
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/hlsenc: reindent the code

2021-01-15 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Thu Dec 24 
22:05:24 2020 +0800| [bf1cc9a43be5d72d8aea24e927e07c7423d8298c] | committer: 
Limin Wang

avformat/hlsenc: reindent the code

Signed-off-by: Limin Wang 

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

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

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index cafe0e8c69..7f38db7058 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -3032,8 +3032,8 @@ static int hls_init(AVFormatContext *s)
 
 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_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;

___
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/udp: return the error code instead of generic EIO

2021-01-15 Thread Limin Wang
ffmpeg | branch: master | Limin Wang  | Wed Jan 13 
07:55:10 2021 +0800| [f6eaa864f363dd9f632bb456b78c134e44904d3b] | committer: 
Limin Wang

avformat/udp: return the error code instead of generic EIO

Reviewed-by: Marton Balint 
Signed-off-by: Limin Wang 

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

 libavformat/udp.c | 58 ++-
 1 file changed, 36 insertions(+), 22 deletions(-)

diff --git a/libavformat/udp.c b/libavformat/udp.c
index 13c346a6a9..c4e403bbfc 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -165,7 +165,7 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
 if (addr->sa_family == AF_INET) {
 if (setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, &mcastTTL, 
sizeof(mcastTTL)) < 0) {
 ff_log_net_error(NULL, AV_LOG_ERROR, 
"setsockopt(IP_MULTICAST_TTL)");
-return -1;
+return ff_neterrno();
 }
 }
 #endif
@@ -173,7 +173,7 @@ static int udp_set_multicast_ttl(int sockfd, int mcastTTL,
 if (addr->sa_family == AF_INET6) {
 if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, &mcastTTL, 
sizeof(mcastTTL)) < 0) {
 ff_log_net_error(NULL, AV_LOG_ERROR, 
"setsockopt(IPV6_MULTICAST_HOPS)");
-return -1;
+return ff_neterrno();
 }
 }
 #endif
@@ -193,7 +193,7 @@ static int udp_join_multicast_group(int sockfd, struct 
sockaddr *addr,struct soc
 mreq.imr_interface.s_addr = INADDR_ANY;
 if (setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const void 
*)&mreq, sizeof(mreq)) < 0) {
 ff_log_net_error(NULL, AV_LOG_ERROR, 
"setsockopt(IP_ADD_MEMBERSHIP)");
-return -1;
+return ff_neterrno();
 }
 }
 #endif
@@ -206,7 +206,7 @@ static int udp_join_multicast_group(int sockfd, struct 
sockaddr *addr,struct soc
 mreq6.ipv6mr_interface = 0;
 if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6, 
sizeof(mreq6)) < 0) {
 ff_log_net_error(NULL, AV_LOG_ERROR, 
"setsockopt(IPV6_ADD_MEMBERSHIP)");
-return -1;
+return ff_neterrno();
 }
 }
 #endif
@@ -633,6 +633,7 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 char buf[256];
 struct sockaddr_storage my_addr;
 socklen_t len;
+int ret;
 
 h->is_streamed = 1;
 
@@ -641,12 +642,12 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_RX_BUF_SIZE;
 
 if (s->sources) {
-if (ff_ip_parse_sources(h, s->sources, &s->filters) < 0)
+if ((ret = ff_ip_parse_sources(h, s->sources, &s->filters)) < 0)
 goto fail;
 }
 
 if (s->block) {
-if (ff_ip_parse_blocks(h, s->block, &s->filters) < 0)
+if ((ret = ff_ip_parse_blocks(h, s->block, &s->filters)) < 0)
 goto fail;
 }
 
@@ -712,11 +713,11 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 av_strlcpy(localaddr, buf, sizeof(localaddr));
 }
 if (av_find_info_tag(buf, sizeof(buf), "sources", p)) {
-if (ff_ip_parse_sources(h, buf, &s->filters) < 0)
+if ((ret = ff_ip_parse_sources(h, buf, &s->filters)) < 0)
 goto fail;
 }
 if (av_find_info_tag(buf, sizeof(buf), "block", p)) {
-if (ff_ip_parse_blocks(h, buf, &s->filters) < 0)
+if ((ret = ff_ip_parse_blocks(h, buf, &s->filters)) < 0)
 goto fail;
 }
 if (!is_output && av_find_info_tag(buf, sizeof(buf), "timeout", p))
@@ -742,7 +743,7 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
 if (!(flags & AVIO_FLAG_READ))
 goto fail;
 } else {
-if (ff_udp_set_remote_url(h, uri) < 0)
+if ((ret = ff_udp_set_remote_url(h, uri)) < 0)
 goto fail;
 }
 
@@ -763,15 +764,22 @@ static int udp_open(URLContext *h, const char *uri, int 
flags)
  */
 if (s->reuse_socket > 0 || (s->is_multicast && s->reuse_socket < 0)) {
 s->reuse_socket = 1;
-if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), 
sizeof(s->reuse_socket)) != 0)
+if (setsockopt (udp_fd, SOL_SOCKET, SO_REUSEADDR, &(s->reuse_socket), 
sizeof(s->reuse_socket)) != 0) {
+ret = ff_neterrno();
 goto fail;
+}
 }
 
 if (s->is_broadcast) {
 #ifdef SO_BROADCAST
-if (setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, &(s->is_broadcast), 
sizeof(s->is_broadcast)) != 0)
+if (setsockopt (udp_fd, SOL_SOCKET, SO_BROADCAST, &(s->is_broadcast), 
sizeof(s->is_broadcast)) != 0) {
+ret = ff_neterrno();
+goto fail;
+}
+#else
+ret = AVERROR(ENOSYS);
+goto fail;
 #endif
-   goto fail;
 }
 
 /* Set the checksum coverage for UDP-Lite (