[FFmpeg-cvslog] avfilter/vf_waveform: add slice threading

2018-05-18 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Tue May 15 09:22:33 
2018 +0200| [e9dd5b4f5eed46c576020b40ebaa87cdac2c633e] | committer: Paul B Mahol

avfilter/vf_waveform: add slice threading

Signed-off-by: Paul B Mahol 

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

 libavfilter/vf_waveform.c | 793 --
 1 file changed, 549 insertions(+), 244 deletions(-)

diff --git a/libavfilter/vf_waveform.c b/libavfilter/vf_waveform.c
index 428147c607..bcee57cf3b 100644
--- a/libavfilter/vf_waveform.c
+++ b/libavfilter/vf_waveform.c
@@ -29,6 +29,14 @@
 #include "internal.h"
 #include "video.h"
 
+typedef struct ThreadData {
+AVFrame *in;
+AVFrame *out;
+int component;
+int offset_y;
+int offset_x;
+} ThreadData;
+
 enum FilterType {
 LOWPASS,
 FLAT,
@@ -94,11 +102,9 @@ typedef struct WaveformContext {
 intshift_w[4], shift_h[4];
 GraticuleLines *glines;
 intnb_glines;
-void (*waveform)(struct WaveformContext *s,
- AVFrame *in, AVFrame *out,
- int component, int intensity,
- int offset_y, int offset_x,
- int column, int mirror);
+
+int (*waveform_slice)(AVFilterContext *ctx, void *arg,
+  int jobnr, int nb_jobs);
 void (*graticulef)(struct WaveformContext *s, AVFrame *out);
 const AVPixFmtDescriptor *desc;
 const AVPixFmtDescriptor *odesc;
@@ -644,7 +650,8 @@ static av_always_inline void lowpass16(WaveformContext *s,
AVFrame *in, AVFrame *out,
int component, int intensity,
int offset_y, int offset_x,
-   int column, int mirror)
+   int column, int mirror,
+   int jobnr, int nb_jobs)
 {
 const int plane = s->desc->comp[component].plane;
 const int shift_w = s->shift_w[component];
@@ -656,22 +663,26 @@ static av_always_inline void lowpass16(WaveformContext *s,
 const int max = limit - intensity;
 const int src_h = AV_CEIL_RSHIFT(in->height, shift_h);
 const int src_w = AV_CEIL_RSHIFT(in->width, shift_w);
-const uint16_t *src_data = (const uint16_t *)in->data[plane];
-uint16_t *dst_data = (uint16_t *)out->data[plane] + offset_y * 
dst_linesize + offset_x;
+const int sliceh_start = !column ? (src_h * jobnr) / nb_jobs : 0;
+const int sliceh_end = !column ? (src_h * (jobnr+1)) / nb_jobs : src_h;
+const int slicew_start = column ? (src_w * jobnr) / nb_jobs : 0;
+const int slicew_end = column ? (src_w * (jobnr+1)) / nb_jobs : src_w;
+const int step = column ? 1 << shift_w : 1 << shift_h;
+const uint16_t *src_data = (const uint16_t *)in->data[plane] + 
sliceh_start * src_linesize;
+uint16_t *dst_data = (uint16_t *)out->data[plane] + (offset_y + 
sliceh_start * step) * dst_linesize + offset_x;
 uint16_t * const dst_bottom_line = dst_data + dst_linesize * (s->size - 1);
 uint16_t * const dst_line = (mirror ? dst_bottom_line : dst_data);
-const int step = column ? 1 << shift_w : 1 << shift_h;
 const uint16_t *p;
 int y;
 
 if (!column && mirror)
 dst_data += s->size;
 
-for (y = 0; y < src_h; y++) {
-const uint16_t *src_data_end = src_data + src_w;
-uint16_t *dst = dst_line;
+for (y = sliceh_start; y < sliceh_end; y++) {
+const uint16_t *src_data_end = src_data + slicew_end;
+uint16_t *dst = dst_line + slicew_start * step;
 
-for (p = src_data; p < src_data_end; p++) {
+for (p = src_data + slicew_start; p < src_data_end; p++) {
 uint16_t *target;
 int i = 0, v = FFMIN(*p, limit);
 
@@ -695,19 +706,26 @@ static av_always_inline void lowpass16(WaveformContext *s,
 src_data += src_linesize;
 dst_data += dst_linesize * step;
 }
-
-envelope16(s, out, plane, plane, column ? offset_x : offset_y);
 }
 
-#define LOWPASS16_FUNC(name, column, mirror)   \
-static void lowpass16_##name(WaveformContext *s,   \
- AVFrame *in, AVFrame *out,\
- int component, int intensity, \
- int offset_y, int offset_x,   \
- int unused1, int unused2) \
-{  \
-lowpass16(s, in, out, component, intensity,\
-  offset_y, offset_x, column, mirror); \
+#define LOWPASS16_FUNC(name, column, mirror)\
+static int lowpass16_##name(AVFilterContext *ctx,   \
+ void *arg, int jobnr,  \
+ int nb_jobs)   \
+{   \
+WaveformContext *s = c

[FFmpeg-cvslog] avfilter/vsrc_testsrc: add pal75bars and pal100bars video filter sources

2018-05-18 Thread Tobias Rapp
ffmpeg | branch: master | Tobias Rapp  | Tue May  8 
11:43:50 2018 +0200| [eb28b5ec8a21d1ac0d3752f81a187e20eb012016] | committer: 
Tobias Rapp

avfilter/vsrc_testsrc: add pal75bars and pal100bars video filter sources

Generates color bar test patterns based on EBU PAL recommendations.

Reviewed-by: Paul B Mahol 
Signed-off-by: Tobias Rapp 

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

 Changelog|   1 +
 doc/filters.texi |  10 +++-
 libavfilter/Makefile |   2 +
 libavfilter/allfilters.c |   2 +
 libavfilter/version.h|   2 +-
 libavfilter/vsrc_testsrc.c   | 106 ++-
 tests/fate/filter-video.mak  |   6 +++
 tests/ref/fate/filter-pal100bars |  10 
 tests/ref/fate/filter-pal75bars  |  10 
 9 files changed, 146 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index c9f1200e13..562fbc49e8 100644
--- a/Changelog
+++ b/Changelog
@@ -7,6 +7,7 @@ version :
 - amplify filter
 - fftdnoiz filter
 - aderivative and aintegral audio filters
+- pal75bars and pal100bars video filter sources
 
 
 version 4.0:
diff --git a/doc/filters.texi b/doc/filters.texi
index 7646efb918..cf15186164 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -17825,13 +17825,15 @@ ffplay -f lavfi 
life=s=300x200:mold=10:r=60:ratio=0.1:death_color=#C83232:life_c
 @anchor{color}
 @anchor{haldclutsrc}
 @anchor{nullsrc}
+@anchor{pal75bars}
+@anchor{pal100bars}
 @anchor{rgbtestsrc}
 @anchor{smptebars}
 @anchor{smptehdbars}
 @anchor{testsrc}
 @anchor{testsrc2}
 @anchor{yuvtestsrc}
-@section allrgb, allyuv, color, haldclutsrc, nullsrc, rgbtestsrc, smptebars, 
smptehdbars, testsrc, testsrc2, yuvtestsrc
+@section allrgb, allyuv, color, haldclutsrc, nullsrc, pal75bars, pal100bars, 
rgbtestsrc, smptebars, smptehdbars, testsrc, testsrc2, yuvtestsrc
 
 The @code{allrgb} source returns frames of size 4096x4096 of all rgb colors.
 
@@ -17846,6 +17848,12 @@ The @code{nullsrc} source returns unprocessed video 
frames. It is
 mainly useful to be employed in analysis / debugging tools, or as the
 source for filters which ignore the input data.
 
+The @code{pal75bars} source generates a color bars pattern, based on
+EBU PAL recommendations with 75% color levels.
+
+The @code{pal100bars} source generates a color bars pattern, based on
+EBU PAL recommendations with 100% color levels.
+
 The @code{rgbtestsrc} source generates an RGB test pattern useful for
 detecting RGB vs BGR issues. You should see a red, green and blue
 stripe from top to bottom.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index f83a2b30ee..c68ef05fdc 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -390,6 +390,8 @@ OBJS-$(CONFIG_MANDELBROT_FILTER) += 
vsrc_mandelbrot.o
 OBJS-$(CONFIG_MPTESTSRC_FILTER)  += vsrc_mptestsrc.o
 OBJS-$(CONFIG_NULLSRC_FILTER)+= vsrc_testsrc.o
 OBJS-$(CONFIG_OPENCLSRC_FILTER)  += vf_program_opencl.o opencl.o
+OBJS-$(CONFIG_PAL75BARS_FILTER)  += vsrc_testsrc.o
+OBJS-$(CONFIG_PAL100BARS_FILTER) += vsrc_testsrc.o
 OBJS-$(CONFIG_RGBTESTSRC_FILTER) += vsrc_testsrc.o
 OBJS-$(CONFIG_SMPTEBARS_FILTER)  += vsrc_testsrc.o
 OBJS-$(CONFIG_SMPTEHDBARS_FILTER)+= vsrc_testsrc.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 099c19157b..b44093d21b 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -380,6 +380,8 @@ extern AVFilter ff_vsrc_mandelbrot;
 extern AVFilter ff_vsrc_mptestsrc;
 extern AVFilter ff_vsrc_nullsrc;
 extern AVFilter ff_vsrc_openclsrc;
+extern AVFilter ff_vsrc_pal75bars;
+extern AVFilter ff_vsrc_pal100bars;
 extern AVFilter ff_vsrc_rgbtestsrc;
 extern AVFilter ff_vsrc_smptebars;
 extern AVFilter ff_vsrc_smptehdbars;
diff --git a/libavfilter/version.h b/libavfilter/version.h
index b1c73be8e2..c32afce3e9 100644
--- a/libavfilter/version.h
+++ b/libavfilter/version.h
@@ -30,7 +30,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVFILTER_VERSION_MAJOR   7
-#define LIBAVFILTER_VERSION_MINOR  23
+#define LIBAVFILTER_VERSION_MINOR  24
 #define LIBAVFILTER_VERSION_MICRO 100
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index a790974d14..8d76ae9271 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -1252,7 +1252,7 @@ AVFilter ff_vsrc_yuvtestsrc = {
 
 #endif /* CONFIG_YUVTESTSRC_FILTER */
 
-#if CONFIG_SMPTEBARS_FILTER || CONFIG_SMPTEHDBARS_FILTER
+#if CONFIG_PAL75_FILTER || CONFIG_PAL100_FILTER || CONFIG_SMPTEBARS_FILTER || 
CONFIG_SMPTEHDBARS_FILTER
 
 static const uint8_t rainbow[7][4] = {
 { 180, 128, 128, 255 }, /* 75% white */
@@ -1264,6 +1264,16 @@ static const uint8_t rainbow[7][4] = {
 {  35, 212, 114, 255 }, /* 75% blue */
 };
 
+static const uin

[FFmpeg-cvslog] tests/checkasm/nlmeans: fix invalid read/write on ii buffer

2018-05-18 Thread Clément Bœsch
ffmpeg | branch: master | Clément Bœsch  | Fri May 18 19:12:11 
2018 +0200| [2940af9389e5cb2a7509655195e5ccb928577ed2] | committer: Clément 
Bœsch

tests/checkasm/nlmeans: fix invalid read/write on ii buffer

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

 tests/checkasm/vf_nlmeans.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/checkasm/vf_nlmeans.c b/tests/checkasm/vf_nlmeans.c
index 5e2c934226..32c6931a4b 100644
--- a/tests/checkasm/vf_nlmeans.c
+++ b/tests/checkasm/vf_nlmeans.c
@@ -80,8 +80,8 @@ void checkasm_check_nlmeans(void)
 av_assert0(startx_safe - s2x >= 0); av_assert0(startx_safe 
- s2x < w);
 av_assert0(starty_safe - s2y >= 0); av_assert0(starty_safe 
- s2y < h);
 
-memset(ii_ref, 0, ii_lz_32 * ii_h * sizeof(*ii_ref));
-memset(ii_new, 0, ii_lz_32 * ii_h * sizeof(*ii_new));
+memset(ii_ref, 0, (ii_lz_32 * ii_h - 1) * sizeof(*ii_ref));
+memset(ii_new, 0, (ii_lz_32 * ii_h - 1) * sizeof(*ii_new));
 
 call_ref(ii_ref + starty_safe*ii_lz_32 + startx_safe, 
ii_lz_32,
  src + (starty_safe - s1y) * src_lz + (startx_safe 
- s1x), src_lz,
@@ -92,10 +92,10 @@ void checkasm_check_nlmeans(void)
  src + (starty_safe - s2y) * src_lz + (startx_safe 
- s2x), src_lz,
  safe_pw, safe_ph);
 
-if (memcmp(ii_ref, ii_new, ii_h * ii_lz_32 * 4))
+if (memcmp(ii_ref, ii_new, (ii_lz_32 * ii_h - 1) * 
sizeof(*ii_ref)))
 fail();
 
-memset(ii_new, 0, ii_lz_32 * ii_h * sizeof(*ii_new));
+memset(ii_new, 0, (ii_lz_32 * ii_h - 1) * sizeof(*ii_new));
 bench_new(ii_new + starty_safe*ii_lz_32 + startx_safe, 
ii_lz_32,
  src + (starty_safe - s1y) * src_lz + (startx_safe 
- s1x), src_lz,
  src + (starty_safe - s2y) * src_lz + (startx_safe 
- s2x), src_lz,

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


[FFmpeg-cvslog] avformat/mpegts: add skip_unknown_pmt option

2018-05-18 Thread Aman Gupta
ffmpeg | branch: master | Aman Gupta  | Tue May  8 12:49:43 2018 
-0700| [e24d768a76b14a1cbea0ec622c89573f7d06fdee] | committer: Aman Gupta

avformat/mpegts: add skip_unknown_pmt option

Some filtered mpegts streams may erroneously include PMTs for
programs that are not advertised in the PAT. This confuses ffmpeg
and most players because multiple audio/video streams are created
and it is unclear which ones actually contain data.

See for example https://tmm1.s3.amazonaws.com/unknown-pmts.ts

In this sample, the PAT advertises exactly one program. But the
pid it points to for the program's PMT contains PMTs for other
programs as well. This is because the broadcaster decided to
re-use the same pid for multiple program PMTs.

The hardware that filtered the original multi-program stream
into a single-program stream did so by rewriting the PAT to
contain only the program that was requested. But since it just
passed through the PMT pid referenced in the PAT, multiple PMTs
are still present for the other programs.

Before:

Input #0, mpegts, from 'unknown-pmts.ts':
  Duration: 00:00:10.11, start: 80741.189700, bitrate: 9655 kb/s
  Program 4
Stream #0:2[0x41]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), 
yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 
11063 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #0:3[0x44](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 
5.1(side), fltp, 384 kb/s
Stream #0:4[0x45](spa): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 
stereo, fltp, 128 kb/s
  No Program
Stream #0:0[0x31]: Video: mpeg2video ([2][0][0][0] / 0x0002), none(tv), 
90k tbr, 90k tbn, 90k tbc
Stream #0:1[0x34](eng): Audio: ac3 (AC-3 / 0x332D4341), 0 channels, fltp
Stream #0:5[0x51]: Video: mpeg2video ([2][0][0][0] / 0x0002), none, 90k 
tbr, 90k tbn
Stream #0:6[0x54](eng): Audio: ac3 (AC-3 / 0x332D4341), 0 channels

With skip_unknown_pmt=1:

Input #0, mpegts, from 'unknown-pmts.ts':
  Duration: 00:00:10.11, start: 80741.189700, bitrate: 9655 kb/s
  Program 4
Stream #0:0[0x41]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), 
yuv420p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], Closed Captions, 
11063 kb/s, 59.94 fps, 59.94 tbr, 90k tbn, 119.88 tbc
Stream #0:1[0x44](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 
5.1(side), fltp, 384 kb/s
Stream #0:2[0x45](spa): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 
stereo, fltp, 128 kb/s

Signed-off-by: Aman Gupta 

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

 doc/demuxers.texi| 3 +++
 libavformat/mpegts.c | 5 +
 2 files changed, 8 insertions(+)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index e7c2abce57..1d2ee5bf37 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -538,6 +538,9 @@ This demuxer accepts the following options:
 Set size limit for looking up a new synchronization. Default value is
 65536.
 
+@item skip_unknown_pmt
+Skip PMTs for programs not defined in the PAT. Default value is 0.
+
 @item fix_teletext_pts
 Override teletext packet PTS and DTS values with the timestamps calculated
 from the PCR of the first program which the teletext stream is part of and is
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index fc9bb3940e..18df1afd9d 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -143,6 +143,7 @@ struct MpegTSContext {
 
 int skip_changes;
 int skip_clear;
+int skip_unknown_pmt;
 
 int scan_all_pmts;
 
@@ -172,6 +173,8 @@ static const AVOption options[] = {
  {.i64 = 0}, 0, 0, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_EXPORT | 
AV_OPT_FLAG_READONLY },
 {"scan_all_pmts", "scan and combine all PMTs", offsetof(MpegTSContext, 
scan_all_pmts), AV_OPT_TYPE_BOOL,
  {.i64 = -1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM },
+{"skip_unknown_pmt", "skip PMTs for programs not advertised in the PAT", 
offsetof(MpegTSContext, skip_unknown_pmt), AV_OPT_TYPE_BOOL,
+ {.i64 = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
 {"skip_changes", "skip changing / adding streams / programs", 
offsetof(MpegTSContext, skip_changes), AV_OPT_TYPE_BOOL,
  {.i64 = 0}, 0, 1, 0 },
 {"skip_clear", "skip clearing programs", offsetof(MpegTSContext, 
skip_clear), AV_OPT_TYPE_BOOL,
@@ -2028,6 +2031,8 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 if (!ts->scan_all_pmts && ts->skip_changes)
 return;
 
+if (ts->skip_unknown_pmt && !get_program(ts, h->id))
+return;
 if (!ts->skip_clear)
 clear_program(ts, h->id);
 

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


[FFmpeg-cvslog] avcodec/videotoolbox: fix decoding of some HEVC videos

2018-05-18 Thread Aman Gupta
ffmpeg | branch: master | Aman Gupta  | Fri May  4 15:41:30 2018 
-0700| [8f146b526ff8d63adc02e1c5db15850f4589230b] | committer: Aman Gupta

avcodec/videotoolbox: fix decoding of some HEVC videos

In a normal hwaccel, the AVHWFramesContext sets AVFrame.hw_frames_ctx
when it initializes a new AVFrame in av_hwframe_get_buffer().

But the VT hwaccel doesn't know what hw_frames_ctx to assign when
the AVFrame is first created, because it depends on the format of
the pixbuf that the decoder eventually decides to return. Thus
newly created AVFrames always have a NULL hw_frames_ctx, and the
hwaccel would only assign the ctx once a frame was done decoding.
This worked fine with the H264 decoder, but with the HEVC decoder
the frame's data may be moved to another empty AVFrame. Since the
empty AVFrame never had hw_frames_ctx set, a frame with a NULL
ctx could be returned to the API user.

This patch works around the issue by moving the derived
hw_frames_ctx from the AVFrame to a new VTHWFrame which now holds
both the CVPixelBufferRef and the AVBuffer. The hw_frames_ctx
is only copied to the AVFrame right before it is about to be
returned to the user in videotoolbox_postproc_frame() (since
in the case of VT, the hw_frames_ctx is only there for the API
user anyway).

Fixes playback on macOS and iOS of some hevc videos like
https://s3.amazonaws.com/tmm1/videotoolbox/germany-hevc-zdf.ts

Signed-off-by: Aman Gupta 

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

 libavcodec/videotoolbox.c | 67 +--
 1 file changed, 35 insertions(+), 32 deletions(-)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index fe5c9004b4..ac45e23c16 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -46,10 +46,16 @@ enum { kCMVideoCodecType_HEVC = 'hvc1' };
 
 #define VIDEOTOOLBOX_ESDS_EXTRADATA_PADDING  12
 
+typedef struct VTHWFrame {
+CVPixelBufferRef pixbuf;
+AVBufferRef *hw_frames_ctx;
+} VTHWFrame;
+
 static void videotoolbox_buffer_release(void *opaque, uint8_t *data)
 {
-CVPixelBufferRef cv_buffer = *(CVPixelBufferRef *)data;
-CVPixelBufferRelease(cv_buffer);
+VTHWFrame *ref = (VTHWFrame *)data;
+av_buffer_unref(&ref->hw_frames_ctx);
+CVPixelBufferRelease(ref->pixbuf);
 
 av_free(data);
 }
@@ -76,22 +82,29 @@ static int videotoolbox_buffer_copy(VTContext *vtctx,
 
 static int videotoolbox_postproc_frame(void *avctx, AVFrame *frame)
 {
-CVPixelBufferRef ref = *(CVPixelBufferRef *)frame->buf[0]->data;
+VTHWFrame *ref = (VTHWFrame *)frame->buf[0]->data;
 
-if (!ref) {
+if (!ref->pixbuf) {
 av_log(avctx, AV_LOG_ERROR, "No frame decoded?\n");
 av_frame_unref(frame);
 return AVERROR_EXTERNAL;
 }
 
-frame->data[3] = (uint8_t*)ref;
+frame->data[3] = (uint8_t*)ref->pixbuf;
+
+if (ref->hw_frames_ctx) {
+av_buffer_unref(&frame->hw_frames_ctx);
+frame->hw_frames_ctx = av_buffer_ref(ref->hw_frames_ctx);
+if (!frame->hw_frames_ctx)
+return AVERROR(ENOMEM);
+}
 
 return 0;
 }
 
 int ff_videotoolbox_alloc_frame(AVCodecContext *avctx, AVFrame *frame)
 {
-size_t  size = sizeof(CVPixelBufferRef);
+size_t  size = sizeof(VTHWFrame);
 uint8_t*data = NULL;
 AVBufferRef *buf = NULL;
 int ret = ff_attach_decode_data(frame);
@@ -318,26 +331,6 @@ CFDataRef 
ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx)
 return data;
 }
 
-static int videotoolbox_set_frame(AVCodecContext *avctx, AVFrame *frame)
-{
-VTContext *vtctx = avctx->internal->hwaccel_priv_data;
-if (!frame->buf[0] || frame->data[3]) {
-av_log(avctx, AV_LOG_ERROR, "videotoolbox: invalid state\n");
-av_frame_unref(frame);
-return AVERROR_EXTERNAL;
-}
-
-CVPixelBufferRef *ref = (CVPixelBufferRef *)frame->buf[0]->data;
-
-if (*ref)
-CVPixelBufferRelease(*ref);
-
-*ref = vtctx->frame;
-vtctx->frame = NULL;
-
-return 0;
-}
-
 int ff_videotoolbox_h264_start_frame(AVCodecContext *avctx,
  const uint8_t *buffer,
  uint32_t size)
@@ -446,11 +439,21 @@ static int videotoolbox_buffer_create(AVCodecContext 
*avctx, AVFrame *frame)
 int width = CVPixelBufferGetWidth(pixbuf);
 int height = CVPixelBufferGetHeight(pixbuf);
 AVHWFramesContext *cached_frames;
+VTHWFrame *ref;
 int ret;
 
-ret = videotoolbox_set_frame(avctx, frame);
-if (ret < 0)
-return ret;
+if (!frame->buf[0] || frame->data[3]) {
+av_log(avctx, AV_LOG_ERROR, "videotoolbox: invalid state\n");
+av_frame_unref(frame);
+return AVERROR_EXTERNAL;
+}
+
+ref = (VTHWFrame *)frame->buf[0]->data;
+
+if (ref->pixbuf)
+CVPixelBufferRelease(ref->pixbuf);
+ref->pixbuf = vtctx->frame;
+vtctx->frame = NULL;
 
 // Old API code 

[FFmpeg-cvslog] avfilter/vsrc_testsrc: fix a preprocessor check

2018-05-18 Thread James Almer
ffmpeg | branch: master | James Almer  | Fri May 18 17:42:57 
2018 -0300| [79126ce80e21f2bc986fef7b8f0d6335136538da] | committer: James Almer

avfilter/vsrc_testsrc: fix a preprocessor check

Signed-off-by: James Almer 

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

 libavfilter/vsrc_testsrc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vsrc_testsrc.c b/libavfilter/vsrc_testsrc.c
index 8d76ae9271..f06714807f 100644
--- a/libavfilter/vsrc_testsrc.c
+++ b/libavfilter/vsrc_testsrc.c
@@ -1252,7 +1252,7 @@ AVFilter ff_vsrc_yuvtestsrc = {
 
 #endif /* CONFIG_YUVTESTSRC_FILTER */
 
-#if CONFIG_PAL75_FILTER || CONFIG_PAL100_FILTER || CONFIG_SMPTEBARS_FILTER || 
CONFIG_SMPTEHDBARS_FILTER
+#if CONFIG_PAL75BARS_FILTER || CONFIG_PAL100BARS_FILTER || 
CONFIG_SMPTEBARS_FILTER || CONFIG_SMPTEHDBARS_FILTER
 
 static const uint8_t rainbow[7][4] = {
 { 180, 128, 128, 255 }, /* 75% white */

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


[FFmpeg-cvslog] avformat/mpegts: keep track of PMT details in AVProgram/AVStream

2018-05-18 Thread Aman Gupta
ffmpeg | branch: master | Aman Gupta  | Thu May 17 15:31:11 2018 
-0700| [24579bf53747176bc288fdcca98d1f3209099ade] | committer: Aman Gupta

avformat/mpegts: keep track of PMT details in AVProgram/AVStream

With these fields, the user has enough information to
detect PMT changes and switch to new streams when the PMT
is updated with new ES pids.

To do so, the user would monitor the AVProgram they're interested
in for changes to pmt_version. If the version changes, they would
iterate over the program's streams to find new streams added with
the updated version number.

If new versions of streams are found, then the user would first try
to replace existing streams where stream_identifier matched.
If stream_identifier is not available, then the user would compare
pmt_stream_idx instead to replace the stream that was previously
at the same position within the PMT.

Signed-off-by: Aman Gupta 

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

 libavformat/mpegts.c | 30 +-
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 18df1afd9d..b21e55d3a7 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -333,12 +333,23 @@ static void set_pmt_found(MpegTSContext *ts, unsigned int 
programid)
 p->pmt_found = 1;
 }
 
-static void set_pcr_pid(AVFormatContext *s, unsigned int programid, unsigned 
int pid)
+static void update_av_program_info(AVFormatContext *s, unsigned int programid,
+   unsigned int pid, int version)
 {
 int i;
 for (i = 0; i < s->nb_programs; i++) {
-if (s->programs[i]->id == programid) {
-s->programs[i]->pcr_pid = pid;
+AVProgram *program = s->programs[i];
+if (program->id == programid) {
+int old_pcr_pid = program->pcr_pid,
+old_version = program->pmt_version;
+program->pcr_pid = pid;
+program->pmt_version = version;
+
+if (old_version != -1 && old_version != version) {
+av_log(s, AV_LOG_VERBOSE,
+   "detected PMT change (program=%d, version=%d/%d, 
pcr_pid=0x%x/0x%x)\n",
+   programid, old_version, version, old_pcr_pid, pid);
+}
 break;
 }
 }
@@ -2041,7 +2052,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 return;
 pcr_pid &= 0x1fff;
 add_pid_to_pmt(ts, h->id, pcr_pid);
-set_pcr_pid(ts->stream, h->id, pcr_pid);
+update_av_program_info(ts->stream, h->id, pcr_pid, h->version);
 
 av_log(ts->stream, AV_LOG_TRACE, "pcr_pid=0x%x\n", pcr_pid);
 
@@ -2083,7 +2094,7 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 set_pmt_found(ts, h->id);
 
 
-for (;;) {
+for (i = 0; ; i++) {
 st = 0;
 pes = NULL;
 stream_type = get8(&p, p_end);
@@ -2104,6 +2115,9 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 if (!pes->st)
 goto out;
 pes->st->id = pes->pid;
+pes->st->program_num = h->id;
+pes->st->pmt_version = h->version;
+pes->st->pmt_stream_idx = i;
 }
 st = pes->st;
 } else if (is_pes_stream(stream_type, prog_reg_desc)) {
@@ -2115,6 +2129,9 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 if (!st)
 goto out;
 st->id = pes->pid;
+st->program_num = h->id;
+st->pmt_version = h->version;
+st->pmt_stream_idx = i;
 }
 } else {
 int idx = ff_find_stream_index(ts->stream, pid);
@@ -2125,6 +2142,9 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 if (!st)
 goto out;
 st->id = pid;
+st->program_num = h->id;
+st->pmt_version = h->version;
+st->pmt_stream_idx = i;
 st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
 if (stream_type == 0x86 && prog_reg_desc == AV_RL32("CUEI")) {
 mpegts_find_stream_type(st, stream_type, SCTE_types);

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


[FFmpeg-cvslog] avformat/mpegts: add merge_pmt_versions option

2018-05-18 Thread Aman Gupta
ffmpeg | branch: master | Aman Gupta  | Tue May  8 16:12:12 2018 
-0700| [16b4f97b721dfb1118c5c0acb03e6a4e80726179] | committer: Aman Gupta

avformat/mpegts: add merge_pmt_versions option

This new optional flag makes it easier to deal with mpegts
samples where the PMT is updated and elementary streams move
to different PIDs in the middle of playback.

Previously, new AVStreams were created per PID, and it was up
to the user to figure out which streams had migrated to a new PID
(by iterating over the list of AVProgram and making guesses), and
switch seamlessly to the new AVStream during playback.

Transcoding or remuxing these streams with ffmpeg on the CLI was
also quite painful, and the user would need to extract each set
of PIDs into a separate file and then stitch them back together.

With this new option, the mpegts demuxer will automatically detect
PMT changes and feed data from the new PID to the original AVStream
that was created for the orignal PID. For mpegts samples with
stream_identifier_descriptor available, the unique ID is used to
merge PIDs together. If the stream id is not available, the demuxer
attempts to map PIDs based on their position within the PMT.

With this change, I am able to playback and transcode/remux these
two samples which previously caused issues:

https://tmm1.s3.amazonaws.com/pmt-version-change.ts
https://kuroko.fushizen.eu/videos/pid_switch_sample.ts

I also have another longer sample in which the PMT changes
repeatedly and ES streams move to different pids three times
during playback:

https://tmm1.s3.amazonaws.com/multiple-pmt-change.ts

Demuxing this sample with the new option shows several new log
messages as the PMT changes are handled:

[mpegts] detected PMT change (program=1, version=3/6, pcr_pid=0xf98/0xfb7)
[mpegts] re-using existing video stream 0 (pid=0xf98) for new pid=0xfb7
[mpegts] re-using existing audio stream 1 (pid=0xf99) for new pid=0xfb8
[mpegts] re-using existing audio stream 2 (pid=0xf9a) for new pid=0xfb9
[mpegts] detected PMT change (program=1, version=6/3, pcr_pid=0xfb7/0xf98)
[mpegts] detected PMT change (program=1, version=3/4, pcr_pid=0xf98/0xf9b)
[mpegts] re-using existing video stream 0 (pid=0xf98) for new pid=0xf9b
[mpegts] re-using existing audio stream 1 (pid=0xf99) for new pid=0xf9c
[mpegts] re-using existing audio stream 2 (pid=0xf9a) for new pid=0xf9d
[mpegts] detected PMT change (program=1, version=4/5, pcr_pid=0xf9b/0xfa9)
[mpegts] re-using existing video stream 0 (pid=0xf98) for new pid=0xfa9
[mpegts] re-using existing audio stream 1 (pid=0xf99) for new pid=0xfaa
[mpegts] re-using existing audio stream 2 (pid=0xf9a) for new pid=0xfab
[mpegts] detected PMT change (program=1, version=5/6, pcr_pid=0xfa9/0xfb7)

Signed-off-by: Aman Gupta 

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

 doc/demuxers.texi |  4 ++
 libavformat/mpegts.c  | 99 +--
 tests/fate/mpegts.mak |  5 ++
 tests/ref/fate/mpegts-probe-pmt-merge | 32 +++
 4 files changed, 137 insertions(+), 3 deletions(-)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 1d2ee5bf37..072918be28 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -555,6 +555,10 @@ Show the detected raw packet size, cannot be set by the 
user.
 Scan and combine all PMTs. The value is an integer with value from -1
 to 1 (-1 means automatic setting, 1 means enabled, 0 means
 disabled). Default value is -1.
+
+@item merge_pmt_versions
+Re-use existing streams when a PMT's version is updated and elementary
+streams move to different PIDs. Default value is 0.
 @end table
 
 @section mpjpeg
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index b21e55d3a7..0c9847f85b 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -148,6 +148,7 @@ struct MpegTSContext {
 int scan_all_pmts;
 
 int resync_size;
+int merge_pmt_versions;
 
 /**/
 /* private mpegts data */
@@ -175,6 +176,8 @@ static const AVOption options[] = {
  {.i64 = -1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM },
 {"skip_unknown_pmt", "skip PMTs for programs not advertised in the PAT", 
offsetof(MpegTSContext, skip_unknown_pmt), AV_OPT_TYPE_BOOL,
  {.i64 = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
+{"merge_pmt_versions", "re-use streams when PMT's version/pids change", 
offsetof(MpegTSContext, merge_pmt_versions), AV_OPT_TYPE_BOOL,
+ {.i64 = 0}, 0, 1,  AV_OPT_FLAG_DECODING_PARAM },
 {"skip_changes", "skip changing / adding streams / programs", 
offsetof(MpegTSContext, skip_changes), AV_OPT_TYPE_BOOL,
  {.i64 = 0}, 0, 1, 0 },
 {"skip_clear", "skip clearing programs", offsetof(MpegTSContext, 
skip_clear), AV_OPT_TYPE_BOOL,
@@ -1086,6 +1089,8 @@ static int mpegts_push_data(MpegTSFilter *filter,
 if (!pes->st) 

[FFmpeg-cvslog] avformat: add fields to AVProgram/AVStream for PMT change tracking

2018-05-18 Thread Aman Gupta
ffmpeg | branch: master | Aman Gupta  | Thu May 17 15:30:21 2018 
-0700| [2b2f2f65f38cdd64fe126079f84872c0b06c6afc] | committer: Aman Gupta

avformat: add fields to AVProgram/AVStream for PMT change tracking

These fields will allow the mpegts demuxer to expose details about
the PMT/program which created the AVProgram and its AVStreams.

In mpegts, a PMT which advertises streams has a version number
which can be incremented at any time. When the version changes,
the pids which correspond to each of it's streams can also change.

Since ffmpeg creates a new AVStream per pid by default, an API user
needs the ability to (a) detect when the PMT changed, and (b) tell
which AVStream were added to replace earlier streams.

This has been a long-standing issue with ffmpeg's handling of mpegts
streams with PMT changes, and I found two related patches in the wild
that attempt to solve the same problem:

The first is in MythTV's ffmpeg fork, where they added a
void (*streams_changed)(void*); to AVFormatContext and call it from
their fork of the mpegts demuxer whenever the PMT changes.

The second was proposed by XBMC in
https://ffmpeg.org/pipermail/ffmpeg-devel/2012-December/135036.html,
where they created a new AVMEDIA_TYPE_DATA stream with id=0 and
attempted to send packets to it whenever the PMT changed.

Signed-off-by: Aman Gupta 

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

 doc/APIchanges | 4 
 libavformat/avformat.h | 8 
 libavformat/utils.c| 1 +
 libavformat/version.h  | 2 +-
 4 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index befa58c84a..a592073ca5 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2018-05-xx - xx - lavf 58.15.100 - avformat.h
+  Add pmt_version field to AVProgram
+  Add program_num, pmt_version, pmt_stream_idx to AVStream
+
 2018-05-xx - xx - lavf 58.14.100 - avformat.h
   Add AV_DISPOSITION_STILL_IMAGE
 
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 6dce88fad5..ade918f99c 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1103,6 +1103,13 @@ typedef struct AVStream {
  */
 int stream_identifier;
 
+/**
+ * Details of the MPEG-TS program which created this stream.
+ */
+int program_num;
+int pmt_version;
+int pmt_stream_idx;
+
 int64_t interleaver_chunk_size;
 int64_t interleaver_chunk_duration;
 
@@ -1260,6 +1267,7 @@ typedef struct AVProgram {
 int program_num;
 int pmt_pid;
 int pcr_pid;
+int pmt_version;
 
 /*
  * All fields below this line are not part of the public API. They
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 636fae3779..a4aa4e10b1 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4569,6 +4569,7 @@ AVProgram *av_new_program(AVFormatContext *ac, int id)
 return NULL;
 dynarray_add(&ac->programs, &ac->nb_programs, program);
 program->discard = AVDISCARD_NONE;
+program->pmt_version = -1;
 }
 program->id = id;
 program->pts_wrap_reference = AV_NOPTS_VALUE;
diff --git a/libavformat/version.h b/libavformat/version.h
index e9b94cc216..c8e89cdce1 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  58
-#define LIBAVFORMAT_VERSION_MINOR  14
+#define LIBAVFORMAT_VERSION_MINOR  15
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \

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


[FFmpeg-cvslog] avcodec/videotoolbox: improve logging of decoder errors

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Fri May  4 18:24:31 
2018 -0700| [13d83899df3c5c6b96f807a6b54801c7f24b83d4] | committer: Aman Gupta

avcodec/videotoolbox: improve logging of decoder errors

Signed-off-by: Aman Gupta 
(cherry picked from commit 84e03db9a334611d261cb09c534a56bf57a49cd9)

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

 libavcodec/videotoolbox.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index 57b6698e1b..6dd800daf8 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -833,6 +833,9 @@ static int videotoolbox_start(AVCodecContext *avctx)
 case kVTVideoDecoderUnsupportedDataFormatErr:
 av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox does not support this 
format.\n");
 return AVERROR(ENOSYS);
+case kVTCouldNotFindVideoDecoderErr:
+av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox decoder for this format 
not found.\n");
+return AVERROR(ENOSYS);
 case kVTVideoDecoderMalfunctionErr:
 av_log(avctx, AV_LOG_VERBOSE, "VideoToolbox malfunction.\n");
 return AVERROR(EINVAL);
@@ -842,7 +845,7 @@ static int videotoolbox_start(AVCodecContext *avctx)
 case 0:
 return 0;
 default:
-av_log(avctx, AV_LOG_VERBOSE, "Unknown VideoToolbox session creation 
error %u\n", (unsigned)status);
+av_log(avctx, AV_LOG_VERBOSE, "Unknown VideoToolbox session creation 
error %d\n", (int)status);
 return AVERROR_UNKNOWN;
 }
 }

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


[FFmpeg-cvslog] avcodec/videotoolbox: fix kVTCouldNotFindVideoDecoderErr trying to decode HEVC on iOS

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Thu Apr 19 15:34:01 
2018 -0700| [ef9478d2646342b900d156ea64d3a3c9035529ac] | committer: Aman Gupta

avcodec/videotoolbox: fix kVTCouldNotFindVideoDecoderErr trying to decode HEVC 
on iOS

Older iOS devices don't have a hardware HEVC decoder, but the
software decoder offered by VideoToolbox is well-optimized and
performs much better than the ffmpeg decoder.

Signed-off-by: Aman Gupta 
(cherry picked from commit bcff983dc340e7651893546c0e1daf4cb37b)

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

 libavcodec/videotoolbox.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index 6dd800daf8..8671608a35 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -36,6 +36,9 @@
 #ifndef kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder
 #  define kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder 
CFSTR("RequireHardwareAcceleratedVideoDecoder")
 #endif
+#ifndef kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder
+#  define kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder 
CFSTR("EnableHardwareAcceleratedVideoDecoder")
+#endif
 
 #if !HAVE_KCMVIDEOCODECTYPE_HEVC
 enum { kCMVideoCodecType_HEVC = 'hvc1' };
@@ -709,7 +712,9 @@ static CFDictionaryRef 
videotoolbox_decoder_config_create(CMVideoCodecType codec

&kCFTypeDictionaryValueCallBacks);
 
 CFDictionarySetValue(config_info,
- 
kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder,
+ codec_type == kCMVideoCodecType_HEVC ?
+
kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder :
+
kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder,
  kCFBooleanTrue);
 
 CFMutableDictionaryRef avc_info;

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


[FFmpeg-cvslog] avcodec/videotoolbox: split h264/hevc callbacks

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Fri May  4 14:58:08 
2018 -0700| [e8caf67f56c6cc731ac4294ae7df0f635b99aec1] | committer: Aman Gupta

avcodec/videotoolbox: split h264/hevc callbacks

Previously the shared callbacks were trying to interpret
avctx->priv_data as H264Context*

Signed-off-by: Aman Gupta 
(cherry picked from commit 07d175d0b0b22912784f35d29e139cf025a03221)

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

 libavcodec/videotoolbox.c | 43 +--
 1 file changed, 33 insertions(+), 10 deletions(-)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index 49f7f9e7dd..fe5c9004b4 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -375,17 +375,13 @@ static int videotoolbox_h264_decode_params(AVCodecContext 
*avctx,
 return ff_videotoolbox_h264_decode_slice(avctx, buffer, size);
 }
 
-int ff_videotoolbox_h264_decode_slice(AVCodecContext *avctx,
-  const uint8_t *buffer,
-  uint32_t size)
+static int videotoolbox_common_decode_slice(AVCodecContext *avctx,
+const uint8_t *buffer,
+uint32_t size)
 {
 VTContext *vtctx = avctx->internal->hwaccel_priv_data;
-H264Context *h  = avctx->priv_data;
 void *tmp;
 
-if (h->is_avc == 1)
-return 0;
-
 tmp = av_fast_realloc(vtctx->bitstream,
   &vtctx->allocated_size,
   vtctx->bitstream_size+size+4);
@@ -402,6 +398,18 @@ int ff_videotoolbox_h264_decode_slice(AVCodecContext 
*avctx,
 return 0;
 }
 
+int ff_videotoolbox_h264_decode_slice(AVCodecContext *avctx,
+  const uint8_t *buffer,
+  uint32_t size)
+{
+H264Context *h = avctx->priv_data;
+
+if (h->is_avc == 1)
+return 0;
+
+return videotoolbox_common_decode_slice(avctx, buffer, size);
+}
+
 int ff_videotoolbox_uninit(AVCodecContext *avctx)
 {
 VTContext *vtctx = avctx->internal->hwaccel_priv_data;
@@ -930,12 +938,27 @@ static int videotoolbox_h264_end_frame(AVCodecContext 
*avctx)
 return ret;
 }
 
+static int videotoolbox_hevc_start_frame(AVCodecContext *avctx,
+ const uint8_t *buffer,
+ uint32_t size)
+{
+return 0;
+}
+
+static int videotoolbox_hevc_decode_slice(AVCodecContext *avctx,
+  const uint8_t *buffer,
+  uint32_t size)
+{
+return videotoolbox_common_decode_slice(avctx, buffer, size);
+}
+
+
 static int videotoolbox_hevc_decode_params(AVCodecContext *avctx,
int type,
const uint8_t *buffer,
uint32_t size)
 {
-return ff_videotoolbox_h264_decode_slice(avctx, buffer, size);
+return videotoolbox_common_decode_slice(avctx, buffer, size);
 }
 
 static int videotoolbox_hevc_end_frame(AVCodecContext *avctx)
@@ -1092,8 +1115,8 @@ const AVHWAccel ff_hevc_videotoolbox_hwaccel = {
 .id = AV_CODEC_ID_HEVC,
 .pix_fmt= AV_PIX_FMT_VIDEOTOOLBOX,
 .alloc_frame= ff_videotoolbox_alloc_frame,
-.start_frame= ff_videotoolbox_h264_start_frame,
-.decode_slice   = ff_videotoolbox_h264_decode_slice,
+.start_frame= videotoolbox_hevc_start_frame,
+.decode_slice   = videotoolbox_hevc_decode_slice,
 .decode_params  = videotoolbox_hevc_decode_params,
 .end_frame  = videotoolbox_hevc_end_frame,
 .frame_params   = videotoolbox_frame_params,

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


[FFmpeg-cvslog] avcodec/mediacodecdec: add workaround for buggy amlogic mpeg2 decoder

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Thu Apr 26 11:51:15 
2018 -0700| [bb6a34f237ecfb78d04d7f5b6d6fb21f69778a59] | committer: Aman Gupta

avcodec/mediacodecdec: add workaround for buggy amlogic mpeg2 decoder

I tested the previous mediacodec changes on seven different Android
TV devices, with both mpeg2 and h264 content. All except one worked
as expected. The exception was the MiBox3 running Android 6.0.1,
where playback would freeze on a frame every few seconds. I tested
two other AMLogic devices with newer Android versions that did not
show the same problem. H264 decoding on the MiBox3 was also not affected,
so this workaround applies only to OMX.amlogic.mpeg2.decoder.awesome
on Android API22.

There is a rumor that Xiaomi is planning to release Android Oreo for
the MiBox3, so I will revisit in a few months to confirm whether this
is specific to os/driver version or the chipset used in that device.

Signed-off-by: Aman Gupta 
Signed-off-by: Matthieu Bouron 
(cherry picked from commit 9b563f6584b5ba2292975f0917268ac7b37497eb)

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

 libavcodec/mediacodecdec.c | 22 +++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
index 2ac22dd1f6..3a4240aa95 100644
--- a/libavcodec/mediacodecdec.c
+++ b/libavcodec/mediacodecdec.c
@@ -48,6 +48,7 @@ typedef struct MediaCodecH264DecContext {
 AVPacket buffered_pkt;
 
 int delay_flush;
+int amlogic_mpeg2_api23_workaround;
 
 } MediaCodecH264DecContext;
 
@@ -287,6 +288,7 @@ static int common_set_extradata(AVCodecContext *avctx, 
FFAMediaFormat *format)
 static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
 {
 int ret;
+int sdk_int;
 
 const char *codec_mime = NULL;
 
@@ -377,7 +379,17 @@ static av_cold int mediacodec_decode_init(AVCodecContext 
*avctx)
 goto done;
 }
 
-av_log(avctx, AV_LOG_INFO, "MediaCodec started successfully, ret = %d\n", 
ret);
+av_log(avctx, AV_LOG_INFO,
+   "MediaCodec started successfully: codec = %s, ret = %d\n",
+   s->ctx->codec_name, ret);
+
+sdk_int = ff_Build_SDK_INT(avctx);
+if (sdk_int <= 23 &&
+strcmp(s->ctx->codec_name, "OMX.amlogic.mpeg2.decoder.awesome") == 0) {
+av_log(avctx, AV_LOG_INFO, "Enabling workaround for %s on API=%d\n",
+   s->ctx->codec_name, sdk_int);
+s->amlogic_mpeg2_api23_workaround = 1;
+}
 
 done:
 if (format) {
@@ -434,8 +446,12 @@ static int mediacodec_receive_frame(AVCodecContext *avctx, 
AVFrame *frame)
 return ret;
 }
 
-/* poll for space again */
-continue;
+if (s->amlogic_mpeg2_api23_workaround && s->buffered_pkt.size <= 
0) {
+/* fallthrough to fetch next packet regardless of input buffer 
space */
+} else {
+/* poll for space again */
+continue;
+}
 }
 
 /* fetch new packet or eof */

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


[FFmpeg-cvslog] avcodec/videotoolbox: cleanups

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Fri May  4 14:57:32 
2018 -0700| [e40922c16c3e80e1f68f4517bb9a01516400289f] | committer: Aman Gupta

avcodec/videotoolbox: cleanups

No functional changes.

Signed-off-by: Aman Gupta 
(cherry picked from commit dd77cca1c4b45ec499435f4c484838f6b0b045fe)

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

 libavcodec/videotoolbox.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index 8671608a35..49f7f9e7dd 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -343,7 +343,7 @@ int ff_videotoolbox_h264_start_frame(AVCodecContext *avctx,
  uint32_t size)
 {
 VTContext *vtctx = avctx->internal->hwaccel_priv_data;
-H264Context *h  = avctx->priv_data;
+H264Context *h = avctx->priv_data;
 
 if (h->is_avc == 1) {
 return videotoolbox_buffer_copy(vtctx, buffer, size);
@@ -943,9 +943,7 @@ static int videotoolbox_hevc_end_frame(AVCodecContext 
*avctx)
 HEVCContext *h = avctx->priv_data;
 AVFrame *frame = h->ref->frame;
 VTContext *vtctx = avctx->internal->hwaccel_priv_data;
-int ret;
-
-ret = videotoolbox_common_end_frame(avctx, frame);
+int ret = videotoolbox_common_end_frame(avctx, frame);
 vtctx->bitstream_size = 0;
 return ret;
 }

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


[FFmpeg-cvslog] avformat/mpegts: reindent after last change

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Wed May  9 14:31:30 
2018 -0700| [852f78443a9d665cf19d874321f82fcec9e495b6] | committer: Aman Gupta

avformat/mpegts: reindent after last change

Signed-off-by: Aman Gupta 
(cherry picked from commit 7db022e67bab568a560c8bd55f5840e71a34dc15)

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

 libavformat/mpegts.c | 70 ++--
 1 file changed, 35 insertions(+), 35 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 9e2bfeca58..a6d0624882 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -412,44 +412,44 @@ static void write_section_data(MpegTSContext *ts, 
MpegTSFilter *tss1,
 offset = 0;
 cur_section_buf = tss->section_buf;
 while (cur_section_buf - tss->section_buf < MAX_SECTION_SIZE && 
cur_section_buf[0] != 0xff) {
-/* compute section length if possible */
-if (tss->section_h_size == -1 && tss->section_index - offset >= 3) {
-len = (AV_RB16(cur_section_buf + 1) & 0xfff) + 3;
-if (len > MAX_SECTION_SIZE)
-return;
-tss->section_h_size = len;
-}
-
-if (tss->section_h_size != -1 &&
-tss->section_index >= offset + tss->section_h_size) {
-int crc_valid = 1;
-tss->end_of_section_reached = 1;
-
-if (tss->check_crc) {
-crc_valid = !av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, 
cur_section_buf, tss->section_h_size);
-if (tss->section_h_size >= 4)
-tss->crc = AV_RB32(cur_section_buf + tss->section_h_size - 4);
+/* compute section length if possible */
+if (tss->section_h_size == -1 && tss->section_index - offset >= 3) {
+len = (AV_RB16(cur_section_buf + 1) & 0xfff) + 3;
+if (len > MAX_SECTION_SIZE)
+return;
+tss->section_h_size = len;
+}
 
+if (tss->section_h_size != -1 &&
+tss->section_index >= offset + tss->section_h_size) {
+int crc_valid = 1;
+tss->end_of_section_reached = 1;
+
+if (tss->check_crc) {
+crc_valid = !av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, 
cur_section_buf, tss->section_h_size);
+if (tss->section_h_size >= 4)
+tss->crc = AV_RB32(cur_section_buf + tss->section_h_size - 
4);
+
+if (crc_valid) {
+ts->crc_validity[ tss1->pid ] = 100;
+}else if (ts->crc_validity[ tss1->pid ] > -10) {
+ts->crc_validity[ tss1->pid ]--;
+}else
+crc_valid = 2;
+}
 if (crc_valid) {
-ts->crc_validity[ tss1->pid ] = 100;
-}else if (ts->crc_validity[ tss1->pid ] > -10) {
-ts->crc_validity[ tss1->pid ]--;
-}else
-crc_valid = 2;
-}
-if (crc_valid) {
-tss->section_cb(tss1, cur_section_buf, tss->section_h_size);
-if (crc_valid != 1)
-tss->last_ver = -1;
-}
+tss->section_cb(tss1, cur_section_buf, tss->section_h_size);
+if (crc_valid != 1)
+tss->last_ver = -1;
+}
 
-cur_section_buf += tss->section_h_size;
-offset += tss->section_h_size;
-tss->section_h_size = -1;
-} else {
-tss->end_of_section_reached = 0;
-break;
-}
+cur_section_buf += tss->section_h_size;
+offset += tss->section_h_size;
+tss->section_h_size = -1;
+} else {
+tss->end_of_section_reached = 0;
+break;
+}
 }
 }
 

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


[FFmpeg-cvslog] avcodec/mediacodecdec: clarify delay_flush specific code

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Mon Apr 23 19:21:19 
2018 -0700| [84bf631018e99c3d72a97da522b9c1614cd55136] | committer: Aman Gupta

avcodec/mediacodecdec: clarify delay_flush specific code

As of 2a0eb8685, ff_mediacodec_dec_is_flushing() only returns
true in delay_flush mode. Make this more obvious by adding
delay_flush to the if statement.

Signed-off-by: Matthieu Bouron 
Signed-off-by: Aman Gupta 
(cherry picked from commit 6a7a84b2d11e6c5e2ca2023a6886ca75b8b10030)

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

 libavcodec/mediacodecdec.c| 24 +++-
 libavcodec/mediacodecdec_common.c | 12 
 2 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
index 0d4a853f07..86ceee5a83 100644
--- a/libavcodec/mediacodecdec.c
+++ b/libavcodec/mediacodecdec.c
@@ -419,27 +419,9 @@ static int mediacodec_receive_frame(AVCodecContext *avctx, 
AVFrame *frame)
 MediaCodecH264DecContext *s = avctx->priv_data;
 int ret;
 
-/*
- * MediaCodec.flush() discards both input and output buffers, thus we
- * need to delay the call to this function until the user has released or
- * renderered the frames he retains.
- *
- * After we have buffered an input packet, check if the codec is in the
- * flushing state. If it is, we need to call ff_mediacodec_dec_flush.
- *
- * ff_mediacodec_dec_flush returns 0 if the flush cannot be performed on
- * the codec (because the user retains frames). The codec stays in the
- * flushing state.
- *
- * ff_mediacodec_dec_flush returns 1 if the flush can actually be
- * performed on the codec. The codec leaves the flushing state and can
- * process again packets.
- *
- * ff_mediacodec_dec_flush returns a negative value if an error has
- * occurred.
- *
- */
-if (ff_mediacodec_dec_is_flushing(avctx, s->ctx)) {
+/* In delay_flush mode, wait until the user has released or rendered
+   all retained frames. */
+if (s->delay_flush && ff_mediacodec_dec_is_flushing(avctx, s->ctx)) {
 if (!ff_mediacodec_dec_flush(avctx, s->ctx)) {
 return AVERROR(EAGAIN);
 }
diff --git a/libavcodec/mediacodecdec_common.c 
b/libavcodec/mediacodecdec_common.c
index e59cf19aad..0c27624dea 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -764,6 +764,18 @@ int ff_mediacodec_dec_receive(AVCodecContext *avctx, 
MediaCodecDecContext *s,
 return AVERROR(EAGAIN);
 }
 
+/*
+* ff_mediacodec_dec_flush returns 0 if the flush cannot be performed on
+* the codec (because the user retains frames). The codec stays in the
+* flushing state.
+*
+* ff_mediacodec_dec_flush returns 1 if the flush can actually be
+* performed on the codec. The codec leaves the flushing state and can
+* process again packets.
+*
+* ff_mediacodec_dec_flush returns a negative value if an error has
+* occurred.
+*/
 int ff_mediacodec_dec_flush(AVCodecContext *avctx, MediaCodecDecContext *s)
 {
 if (!s->surface || atomic_load(&s->refcount) == 1) {

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


[FFmpeg-cvslog] avformat/mpegts: parse sections with multiple tables

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Wed May  9 14:20:48 
2018 -0700| [c343eabfb77cd68c104acdf09d811eee7bc2caf9] | committer: Aman Gupta

avformat/mpegts: parse sections with multiple tables

Fixes PMT parsing in some mpegts streams which contain
multiple tables within the PMT pid. Previously, the parser
assumed only one table was present in each packet, and discarded
the rest of the section data after attempting to parse the first
table.

A similar issue was documented in the BeyondTV software[1], which
helped me diagnose the same bug in the ffmpeg mpegts demuxer. I also
tried DVBInspector, libdvbpsi's dvbinfo, and tstools' tsinfo to
help debug. The former two properly read PMTs with multiple tables,
whereas the last has the same bug as ffmpeg.

I've created a minimal sample[2] which contains the combined PMT.
Here's what ffmpeg probe shows before and after this patch:

Before:

Input #0, mpegts, from 'combined-pmt-tids.ts':
  Duration: 00:00:01.08, start: 4932.966167, bitrate: 741 kb/s
  Program 1
  No Program
Stream #0:0[0xf9d]: Audio: ac3, 48000 Hz, mono, fltp, 96 kb/s
Stream #0:1[0xf9b]: Audio: mp3, 0 channels, fltp
Stream #0:2[0xf9c]: Unknown: none

After:

Input #0, mpegts, from 'combined-pmt-tids.ts':
  Duration: 00:00:01.11, start: 4932.966167, bitrate: 718 kb/s
  Program 1
Stream #0:0[0xf9b]: Video: mpeg2video ([2][0][0][0] / 0x0002), none(tv, 
top first), 29.97 fps, 29.97 tbr, 90k tbn, 90k tbc
Stream #0:1[0xf9c](eng): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 
5.1(side), fltp, 384 kb/s
Stream #0:2[0xf9d](spa): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, 
mono, fltp, 96 kb/s

With the patch, the PMT is parsed correctly so the streams are
created in the correct order, are associated with "Program 1",
and their codecs are set correctly.

[1] http://forums.snapstream.com/vb/showpost.php?p=343816&postcount=201
[2] https://s3.amazonaws.com/tmm1/combined-pmt-tids.ts

Signed-off-by: Aman Gupta 
Signed-off-by: Michael Niedermayer 
(cherry picked from commit 9152c1e495551535886cfd7a8d7c0a206691443e)

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

 libavformat/mpegts.c | 26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index c09ba638c6..9e2bfeca58 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -391,7 +391,8 @@ static void write_section_data(MpegTSContext *ts, 
MpegTSFilter *tss1,
const uint8_t *buf, int buf_size, int is_start)
 {
 MpegTSSectionFilter *tss = &tss1->u.section_filter;
-int len;
+uint8_t *cur_section_buf = NULL;
+int len, offset;
 
 if (is_start) {
 memcpy(tss->section_buf, buf, buf_size);
@@ -408,23 +409,26 @@ static void write_section_data(MpegTSContext *ts, 
MpegTSFilter *tss1,
 tss->section_index += len;
 }
 
+offset = 0;
+cur_section_buf = tss->section_buf;
+while (cur_section_buf - tss->section_buf < MAX_SECTION_SIZE && 
cur_section_buf[0] != 0xff) {
 /* compute section length if possible */
-if (tss->section_h_size == -1 && tss->section_index >= 3) {
-len = (AV_RB16(tss->section_buf + 1) & 0xfff) + 3;
+if (tss->section_h_size == -1 && tss->section_index - offset >= 3) {
+len = (AV_RB16(cur_section_buf + 1) & 0xfff) + 3;
 if (len > MAX_SECTION_SIZE)
 return;
 tss->section_h_size = len;
 }
 
 if (tss->section_h_size != -1 &&
-tss->section_index >= tss->section_h_size) {
+tss->section_index >= offset + tss->section_h_size) {
 int crc_valid = 1;
 tss->end_of_section_reached = 1;
 
 if (tss->check_crc) {
-crc_valid = !av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, 
tss->section_buf, tss->section_h_size);
+crc_valid = !av_crc(av_crc_get_table(AV_CRC_32_IEEE), -1, 
cur_section_buf, tss->section_h_size);
 if (tss->section_h_size >= 4)
-tss->crc = AV_RB32(tss->section_buf + tss->section_h_size - 4);
+tss->crc = AV_RB32(cur_section_buf + tss->section_h_size - 4);
 
 if (crc_valid) {
 ts->crc_validity[ tss1->pid ] = 100;
@@ -434,10 +438,18 @@ static void write_section_data(MpegTSContext *ts, 
MpegTSFilter *tss1,
 crc_valid = 2;
 }
 if (crc_valid) {
-tss->section_cb(tss1, tss->section_buf, tss->section_h_size);
+tss->section_cb(tss1, cur_section_buf, tss->section_h_size);
 if (crc_valid != 1)
 tss->last_ver = -1;
 }
+
+cur_section_buf += tss->section_h_size;
+offset += tss->section_h_size;
+tss->section_h_size = -1;
+} else {
+tss->end_of_section_reached = 0;
+break;
+}
 }
 }
 

___
ffmpeg-cvslo

[FFmpeg-cvslog] ffprobe: fix SEGV when new streams are added

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Tue May  8 12:46:12 
2018 -0700| [da399903c76db5d04c651d1589060bb9c5c76587] | committer: Aman Gupta

ffprobe: fix SEGV when new streams are added

Signed-off-by: Aman Gupta 
(cherry picked from commit 12ceaf0fbacb20b86bdc343ba2bbc71d2fff72e0)

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

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

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 8b2a18b6b1..544786ec72 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2371,11 +2371,11 @@ static int read_interval_packets(WriterContext *w, 
InputFile *ifile,
 goto end;
 }
 while (!av_read_frame(fmt_ctx, &pkt)) {
-if (ifile->nb_streams > nb_streams) {
+if (fmt_ctx->nb_streams > nb_streams) {
 REALLOCZ_ARRAY_STREAM(nb_streams_frames,  nb_streams, 
fmt_ctx->nb_streams);
 REALLOCZ_ARRAY_STREAM(nb_streams_packets, nb_streams, 
fmt_ctx->nb_streams);
 REALLOCZ_ARRAY_STREAM(selected_streams,   nb_streams, 
fmt_ctx->nb_streams);
-nb_streams = ifile->nb_streams;
+nb_streams = fmt_ctx->nb_streams;
 }
 if (selected_streams[pkt.stream_index]) {
 AVRational tb = ifile->streams[pkt.stream_index].st->time_base;

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


[FFmpeg-cvslog] avcodec/mediacodec_wrapper: add helper to fetch SDK_INT

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Thu Apr 26 11:50:55 
2018 -0700| [6f55a36be9a218755af59b11a63b214300ef4be8] | committer: Aman Gupta

avcodec/mediacodec_wrapper: add helper to fetch SDK_INT

Signed-off-by: Matthieu Bouron 
Signed-off-by: Aman Gupta 
(cherry picked from commit fe0a6bcbda0f51d0613dbbd42a7635c22530ce95)

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

 libavcodec/mediacodec_wrapper.c | 15 +++
 libavcodec/mediacodec_wrapper.h |  2 ++
 2 files changed, 17 insertions(+)

diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c
index 9bf96e9383..c47c2c9a41 100644
--- a/libavcodec/mediacodec_wrapper.c
+++ b/libavcodec/mediacodec_wrapper.c
@@ -1687,3 +1687,18 @@ int ff_AMediaCodec_cleanOutputBuffers(FFAMediaCodec 
*codec)
 fail:
 return ret;
 }
+
+int ff_Build_SDK_INT(AVCodecContext *avctx)
+{
+int ret = -1;
+JNIEnv *env = NULL;
+jclass versionClass;
+jfieldID sdkIntFieldID;
+JNI_GET_ENV_OR_RETURN(env, avctx, -1);
+
+versionClass = (*env)->FindClass(env, "android/os/Build$VERSION");
+sdkIntFieldID = (*env)->GetStaticFieldID(env, versionClass, "SDK_INT", 
"I");
+ret = (*env)->GetStaticIntField(env, versionClass, sdkIntFieldID);
+(*env)->DeleteLocalRef(env, versionClass);
+return ret;
+}
diff --git a/libavcodec/mediacodec_wrapper.h b/libavcodec/mediacodec_wrapper.h
index 1b4f3a9492..f0de16d669 100644
--- a/libavcodec/mediacodec_wrapper.h
+++ b/libavcodec/mediacodec_wrapper.h
@@ -124,4 +124,6 @@ int ff_AMediaCodec_getConfigureFlagEncode(FFAMediaCodec 
*codec);
 
 int ff_AMediaCodec_cleanOutputBuffers(FFAMediaCodec *codec);
 
+int ff_Build_SDK_INT(AVCodecContext *avctx);
+
 #endif /* AVCODEC_MEDIACODEC_WRAPPER_H */

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


[FFmpeg-cvslog] avcodec/mediacodecdec: restructure mediacodec_receive_frame

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Tue Apr 24 12:40:38 
2018 -0700| [df2c811b7ce32348198b8bf2fa3dc884696c2160] | committer: Aman Gupta

avcodec/mediacodecdec: restructure mediacodec_receive_frame

The new logic follows a recommendation by @rcombs to use
dequeueInputBuffer with a timeout of 0 as a way to detect
whether the codec wants more data. The dequeued buffer index is
kept in MediaCodecDecContext until it can be used next.

A similar technique is also used by the Google's official media
player Exoplayer: see MediaCodecRenderer.feedInputBuffer().

Signed-off-by: Aman Gupta 
Signed-off-by: Matthieu Bouron 
(cherry picked from commit f6681feda641c026d84f6d207f661bf9b87d9d70)

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

 libavcodec/mediacodecdec.c| 80 ---
 libavcodec/mediacodecdec_common.c | 28 --
 libavcodec/mediacodecdec_common.h |  4 +-
 3 files changed, 61 insertions(+), 51 deletions(-)

diff --git a/libavcodec/mediacodecdec.c b/libavcodec/mediacodecdec.c
index 86ceee5a83..2ac22dd1f6 100644
--- a/libavcodec/mediacodecdec.c
+++ b/libavcodec/mediacodecdec.c
@@ -391,33 +391,11 @@ done:
 return ret;
 }
 
-static int mediacodec_send_receive(AVCodecContext *avctx,
-   MediaCodecH264DecContext *s,
-   AVFrame *frame, bool wait)
-{
-int ret;
-
-/* send any pending data from buffered packet */
-while (s->buffered_pkt.size) {
-ret = ff_mediacodec_dec_send(avctx, s->ctx, &s->buffered_pkt);
-if (ret == AVERROR(EAGAIN))
-break;
-else if (ret < 0)
-return ret;
-s->buffered_pkt.size -= ret;
-s->buffered_pkt.data += ret;
-if (s->buffered_pkt.size <= 0)
-av_packet_unref(&s->buffered_pkt);
-}
-
-/* check for new frame */
-return ff_mediacodec_dec_receive(avctx, s->ctx, frame, wait);
-}
-
 static int mediacodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
 {
 MediaCodecH264DecContext *s = avctx->priv_data;
 int ret;
+ssize_t index;
 
 /* In delay_flush mode, wait until the user has released or rendered
all retained frames. */
@@ -427,28 +405,54 @@ static int mediacodec_receive_frame(AVCodecContext 
*avctx, AVFrame *frame)
 }
 }
 
-/* flush buffered packet and check for new frame */
-ret = mediacodec_send_receive(avctx, s, frame, false);
+/* poll for new frame */
+ret = ff_mediacodec_dec_receive(avctx, s->ctx, frame, false);
 if (ret != AVERROR(EAGAIN))
 return ret;
 
-/* skip fetching new packet if we still have one buffered */
-if (s->buffered_pkt.size > 0)
-return mediacodec_send_receive(avctx, s, frame, true);
+/* feed decoder */
+while (1) {
+if (s->ctx->current_input_buffer < 0) {
+/* poll for input space */
+index = ff_AMediaCodec_dequeueInputBuffer(s->ctx->codec, 0);
+if (index < 0) {
+/* no space, block for an output frame to appear */
+return ff_mediacodec_dec_receive(avctx, s->ctx, frame, true);
+}
+s->ctx->current_input_buffer = index;
+}
 
-/* fetch new packet or eof */
-ret = ff_decode_get_packet(avctx, &s->buffered_pkt);
-if (ret == AVERROR_EOF) {
-AVPacket null_pkt = { 0 };
-ret = ff_mediacodec_dec_send(avctx, s->ctx, &null_pkt);
-if (ret < 0)
+/* try to flush any buffered packet data */
+if (s->buffered_pkt.size > 0) {
+ret = ff_mediacodec_dec_send(avctx, s->ctx, &s->buffered_pkt, 
false);
+if (ret >= 0) {
+s->buffered_pkt.size -= ret;
+s->buffered_pkt.data += ret;
+if (s->buffered_pkt.size <= 0)
+av_packet_unref(&s->buffered_pkt);
+} else if (ret < 0 && ret != AVERROR(EAGAIN)) {
+return ret;
+}
+
+/* poll for space again */
+continue;
+}
+
+/* fetch new packet or eof */
+ret = ff_decode_get_packet(avctx, &s->buffered_pkt);
+if (ret == AVERROR_EOF) {
+AVPacket null_pkt = { 0 };
+ret = ff_mediacodec_dec_send(avctx, s->ctx, &null_pkt, true);
+if (ret < 0)
+return ret;
+} else if (ret == AVERROR(EAGAIN) && s->ctx->current_input_buffer < 0) 
{
+return ff_mediacodec_dec_receive(avctx, s->ctx, frame, true);
+} else if (ret < 0) {
 return ret;
+}
 }
-else if (ret < 0)
-return ret;
 
-/* crank decoder with new packet */
-return mediacodec_send_receive(avctx, s, frame, true);
+return AVERROR(EAGAIN);
 }
 
 static void mediacodec_decode_flush(AVCodecContext *avctx)
diff --git a/libavcodec/mediacodecdec_common.c 
b/libavcodec/mediacodecdec_common.c
index c

[FFmpeg-cvslog] avformat/mpegts: skip non-PMT tids earlier

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Tue May  8 15:07:35 
2018 -0700| [97aea63340d1c971df7313dd8ec642017b5cd0c1] | committer: Aman Gupta

avformat/mpegts: skip non-PMT tids earlier

This mimics the logic flow in all the other callbacks
(pat_cb, sdt_cb, m4sl_cb), and avoids calling skip_identical()
for non PMT_TID packets.

Since skip_identical modifies internal state like
MpegTSSectionFilter.last_ver, this change prevents unnecessary
reprocessing on some streams which contain multiple tables in
the PMT pid. This can be observed with streams from certain US
cable providers, which include both tid=0x2 and another unspecified
tid=0xc0.

Signed-off-by: Aman Gupta 
(cherry picked from commit 2c500f50972c19f25ebca783ba9374d6a0c23efb)

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

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

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 37a6aa8bff..cfdd03125b 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -1970,14 +1970,14 @@ static void pmt_cb(MpegTSFilter *filter, const uint8_t 
*section, int section_len
 p = section;
 if (parse_section_header(h, &p, p_end) < 0)
 return;
+if (h->tid != PMT_TID)
+return;
 if (skip_identical(h, tssf))
 return;
 
 av_log(ts->stream, AV_LOG_TRACE, "sid=0x%x sec_num=%d/%d version=%d 
tid=%d\n",
 h->id, h->sec_num, h->last_sec_num, h->version, h->tid);
 
-if (h->tid != PMT_TID)
-return;
 if (!ts->scan_all_pmts && ts->skip_changes)
 return;
 

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


[FFmpeg-cvslog] avcodec/videotoolbox: fix decoding of some HEVC videos

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Fri May  4 15:41:30 
2018 -0700| [2884575d97cb6a52045f3ed68443c8e42bc7a914] | committer: Aman Gupta

avcodec/videotoolbox: fix decoding of some HEVC videos

In a normal hwaccel, the AVHWFramesContext sets AVFrame.hw_frames_ctx
when it initializes a new AVFrame in av_hwframe_get_buffer().

But the VT hwaccel doesn't know what hw_frames_ctx to assign when
the AVFrame is first created, because it depends on the format of
the pixbuf that the decoder eventually decides to return. Thus
newly created AVFrames always have a NULL hw_frames_ctx, and the
hwaccel would only assign the ctx once a frame was done decoding.
This worked fine with the H264 decoder, but with the HEVC decoder
the frame's data may be moved to another empty AVFrame. Since the
empty AVFrame never had hw_frames_ctx set, a frame with a NULL
ctx could be returned to the API user.

This patch works around the issue by moving the derived
hw_frames_ctx from the AVFrame to a new VTHWFrame which now holds
both the CVPixelBufferRef and the AVBuffer. The hw_frames_ctx
is only copied to the AVFrame right before it is about to be
returned to the user in videotoolbox_postproc_frame() (since
in the case of VT, the hw_frames_ctx is only there for the API
user anyway).

Fixes playback on macOS and iOS of some hevc videos like
https://s3.amazonaws.com/tmm1/videotoolbox/germany-hevc-zdf.ts

Signed-off-by: Aman Gupta 
(cherry picked from commit 8f146b526ff8d63adc02e1c5db15850f4589230b)

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

 libavcodec/videotoolbox.c | 67 +--
 1 file changed, 35 insertions(+), 32 deletions(-)

diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index fe5c9004b4..ac45e23c16 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -46,10 +46,16 @@ enum { kCMVideoCodecType_HEVC = 'hvc1' };
 
 #define VIDEOTOOLBOX_ESDS_EXTRADATA_PADDING  12
 
+typedef struct VTHWFrame {
+CVPixelBufferRef pixbuf;
+AVBufferRef *hw_frames_ctx;
+} VTHWFrame;
+
 static void videotoolbox_buffer_release(void *opaque, uint8_t *data)
 {
-CVPixelBufferRef cv_buffer = *(CVPixelBufferRef *)data;
-CVPixelBufferRelease(cv_buffer);
+VTHWFrame *ref = (VTHWFrame *)data;
+av_buffer_unref(&ref->hw_frames_ctx);
+CVPixelBufferRelease(ref->pixbuf);
 
 av_free(data);
 }
@@ -76,22 +82,29 @@ static int videotoolbox_buffer_copy(VTContext *vtctx,
 
 static int videotoolbox_postproc_frame(void *avctx, AVFrame *frame)
 {
-CVPixelBufferRef ref = *(CVPixelBufferRef *)frame->buf[0]->data;
+VTHWFrame *ref = (VTHWFrame *)frame->buf[0]->data;
 
-if (!ref) {
+if (!ref->pixbuf) {
 av_log(avctx, AV_LOG_ERROR, "No frame decoded?\n");
 av_frame_unref(frame);
 return AVERROR_EXTERNAL;
 }
 
-frame->data[3] = (uint8_t*)ref;
+frame->data[3] = (uint8_t*)ref->pixbuf;
+
+if (ref->hw_frames_ctx) {
+av_buffer_unref(&frame->hw_frames_ctx);
+frame->hw_frames_ctx = av_buffer_ref(ref->hw_frames_ctx);
+if (!frame->hw_frames_ctx)
+return AVERROR(ENOMEM);
+}
 
 return 0;
 }
 
 int ff_videotoolbox_alloc_frame(AVCodecContext *avctx, AVFrame *frame)
 {
-size_t  size = sizeof(CVPixelBufferRef);
+size_t  size = sizeof(VTHWFrame);
 uint8_t*data = NULL;
 AVBufferRef *buf = NULL;
 int ret = ff_attach_decode_data(frame);
@@ -318,26 +331,6 @@ CFDataRef 
ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx)
 return data;
 }
 
-static int videotoolbox_set_frame(AVCodecContext *avctx, AVFrame *frame)
-{
-VTContext *vtctx = avctx->internal->hwaccel_priv_data;
-if (!frame->buf[0] || frame->data[3]) {
-av_log(avctx, AV_LOG_ERROR, "videotoolbox: invalid state\n");
-av_frame_unref(frame);
-return AVERROR_EXTERNAL;
-}
-
-CVPixelBufferRef *ref = (CVPixelBufferRef *)frame->buf[0]->data;
-
-if (*ref)
-CVPixelBufferRelease(*ref);
-
-*ref = vtctx->frame;
-vtctx->frame = NULL;
-
-return 0;
-}
-
 int ff_videotoolbox_h264_start_frame(AVCodecContext *avctx,
  const uint8_t *buffer,
  uint32_t size)
@@ -446,11 +439,21 @@ static int videotoolbox_buffer_create(AVCodecContext 
*avctx, AVFrame *frame)
 int width = CVPixelBufferGetWidth(pixbuf);
 int height = CVPixelBufferGetHeight(pixbuf);
 AVHWFramesContext *cached_frames;
+VTHWFrame *ref;
 int ret;
 
-ret = videotoolbox_set_frame(avctx, frame);
-if (ret < 0)
-return ret;
+if (!frame->buf[0] || frame->data[3]) {
+av_log(avctx, AV_LOG_ERROR, "videotoolbox: invalid state\n");
+av_frame_unref(frame);
+return AVERROR_EXTERNAL;
+}
+
+ref = (VTHWFrame *)frame->buf[0]->data;
+
+if (ref->pixbuf)
+CVPixelBufferRelease(ref->pixbuf);
+ref

[FFmpeg-cvslog] avformat/mpegts: use MAX_SECTION_SIZE instead of hardcoded value

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Wed May  9 12:42:14 
2018 -0700| [ef28571efe234453133f12c00e5d32300518cfe8] | committer: Aman Gupta

avformat/mpegts: use MAX_SECTION_SIZE instead of hardcoded value

Signed-off-by: Aman Gupta 
(cherry picked from commit 1a14e39145816597b97db46dbb30e37feddf246c)

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

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

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index cfdd03125b..c6a0228253 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -401,7 +401,7 @@ static void write_section_data(MpegTSContext *ts, 
MpegTSFilter *tss1,
 } else {
 if (tss->end_of_section_reached)
 return;
-len = 4096 - tss->section_index;
+len = MAX_SECTION_SIZE - tss->section_index;
 if (buf_size < len)
 len = buf_size;
 memcpy(tss->section_buf + tss->section_index, buf, len);
@@ -411,7 +411,7 @@ static void write_section_data(MpegTSContext *ts, 
MpegTSFilter *tss1,
 /* compute section length if possible */
 if (tss->section_h_size == -1 && tss->section_index >= 3) {
 len = (AV_RB16(tss->section_buf + 1) & 0xfff) + 3;
-if (len > 4096)
+if (len > MAX_SECTION_SIZE)
 return;
 tss->section_h_size = len;
 }

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


[FFmpeg-cvslog] avcodec/mediacodecdec: use AV_TIME_BASE_Q

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Tue Apr 24 13:45:30 
2018 -0700| [3054e53ddcfa5d5e1d73db97c3fe5715da944028] | committer: Aman Gupta

avcodec/mediacodecdec: use AV_TIME_BASE_Q

Signed-off-by: Matthieu Bouron 
Signed-off-by: Jan Ekström 
Signed-off-by: Aman Gupta 
(cherry picked from commit 7a4639b1eba31f88490c85663c75fb1414307680)

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

 libavcodec/mediacodecdec_common.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/mediacodecdec_common.c 
b/libavcodec/mediacodecdec_common.c
index 0c27624dea..56b3c4fd1e 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -209,7 +209,7 @@ static int mediacodec_wrap_hw_buffer(AVCodecContext *avctx,
 
 if (avctx->pkt_timebase.num && avctx->pkt_timebase.den) {
 frame->pts = av_rescale_q(info->presentationTimeUs,
-  av_make_q(1, 100),
+  AV_TIME_BASE_Q,
   avctx->pkt_timebase);
 } else {
 frame->pts = info->presentationTimeUs;
@@ -298,7 +298,7 @@ static int mediacodec_wrap_sw_buffer(AVCodecContext *avctx,
  *   * 0-sized avpackets are pushed to flush remaining frames at EOS */
 if (avctx->pkt_timebase.num && avctx->pkt_timebase.den) {
 frame->pts = av_rescale_q(info->presentationTimeUs,
-  av_make_q(1, 100),
+  AV_TIME_BASE_Q,
   avctx->pkt_timebase);
 } else {
 frame->pts = info->presentationTimeUs;
@@ -610,7 +610,7 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, 
MediaCodecDecContext *s,
 uint32_t flags = ff_AMediaCodec_getBufferFlagEndOfStream(codec);
 
 if (s->surface) {
-pts = av_rescale_q(pts, avctx->pkt_timebase, av_make_q(1, 
100));
+pts = av_rescale_q(pts, avctx->pkt_timebase, AV_TIME_BASE_Q);
 }
 
 av_log(avctx, AV_LOG_DEBUG, "Sending End Of Stream signal\n");
@@ -634,7 +634,7 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, 
MediaCodecDecContext *s,
 offset += size;
 
 if (avctx->pkt_timebase.num && avctx->pkt_timebase.den) {
-pts = av_rescale_q(pts, avctx->pkt_timebase, av_make_q(1, 
100));
+pts = av_rescale_q(pts, avctx->pkt_timebase, AV_TIME_BASE_Q);
 }
 
 status = ff_AMediaCodec_queueInputBuffer(codec, index, 0, size, 
pts, 0);

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


[FFmpeg-cvslog] avcodec/hevc: remove videotoolbox hack

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Fri May  4 14:57:50 
2018 -0700| [76716518a8174ca4931cb673e70c6fdc24302e88] | committer: Aman Gupta

avcodec/hevc: remove videotoolbox hack

No longer required since 63d875772d. The equivalent hack
for h264 was removed in that commit, but this one was missed.

Signed-off-by: Aman Gupta 
(cherry picked from commit a19bac8fc8b6a8df4030f79a6192b20492b02cef)

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

 libavcodec/hevc_refs.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index e159a23a4e..7cf3a55725 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -208,9 +208,6 @@ int ff_hevc_output_frame(HEVCContext *s, AVFrame *out, int 
flush)
 if (nb_output) {
 HEVCFrame *frame = &s->DPB[min_idx];
 
-if (frame->frame->format == AV_PIX_FMT_VIDEOTOOLBOX && 
frame->frame->buf[0]->size == 1)
-return 0;
-
 ret = av_frame_ref(out, frame->frame);
 if (frame->flags & HEVC_FRAME_FLAG_BUMPING)
 ff_hevc_unref_frame(s, frame, HEVC_FRAME_FLAG_OUTPUT | 
HEVC_FRAME_FLAG_BUMPING);

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


[FFmpeg-cvslog] avcodec/mediacodecdec: wait on first frame after input buffers are full

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Tue Apr 24 18:54:45 
2018 -0700| [db5631e4087f8034c47257542fb813c9417dcf23] | committer: Aman Gupta

avcodec/mediacodecdec: wait on first frame after input buffers are full

The output_buffer_count==0 special case is no longer required, and
can cause spurious EAGAIN to surface to the user when input buffers
are filled up. Since the caller now knows if the decoder is accepting
new input (via current_input_buffer>=0), let the wait parameter
control whether we block or not.

Signed-off-by: Aman Gupta 
Signed-off-by: Matthieu Bouron 
(cherry picked from commit a75bb5496ac6e7e194f1c6fd3b87f02a52e74adb)

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

 libavcodec/mediacodecdec_common.c | 8 +---
 libavcodec/mediacodecdec_common.h | 1 -
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/libavcodec/mediacodecdec_common.c 
b/libavcodec/mediacodecdec_common.c
index 887865a281..40a2ee6778 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -443,8 +443,6 @@ static int mediacodec_dec_flush_codec(AVCodecContext 
*avctx, MediaCodecDecContex
 FFAMediaCodec *codec = s->codec;
 int status;
 
-s->output_buffer_count = 0;
-
 s->draining = 0;
 s->flushing = 0;
 s->eos = 0;
@@ -672,10 +670,7 @@ int ff_mediacodec_dec_receive(AVCodecContext *avctx, 
MediaCodecDecContext *s,
 /* If the codec is flushing or need to be flushed, block for a fair
  * amount of time to ensure we got a frame */
 output_dequeue_timeout_us = OUTPUT_DEQUEUE_BLOCK_TIMEOUT_US;
-} else if (s->output_buffer_count == 0 || !wait) {
-/* If the codec hasn't produced any frames, do not block so we
- * can push data to it as fast as possible, and get the first
- * frame */
+} else if (!wait) {
 output_dequeue_timeout_us = 0;
 }
 
@@ -709,7 +704,6 @@ int ff_mediacodec_dec_receive(AVCodecContext *avctx, 
MediaCodecDecContext *s,
 }
 }
 
-s->output_buffer_count++;
 return 0;
 } else {
 status = ff_AMediaCodec_releaseOutputBuffer(codec, index, 0);
diff --git a/libavcodec/mediacodecdec_common.h 
b/libavcodec/mediacodecdec_common.h
index 0b21129fee..d280236b8e 100644
--- a/libavcodec/mediacodecdec_common.h
+++ b/libavcodec/mediacodecdec_common.h
@@ -64,7 +64,6 @@ typedef struct MediaCodecDecContext {
 int display_width;
 int display_height;
 
-uint64_t output_buffer_count;
 ssize_t current_input_buffer;
 
 bool delay_flush;

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


[FFmpeg-cvslog] avformat/mpegts: fix incorrect indentation

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Tue May 15 11:47:30 
2018 -0700| [8336a6627045291470b54b7058ec54bd45772d29] | committer: Aman Gupta

avformat/mpegts: fix incorrect indentation

Signed-off-by: Aman Gupta 
(cherry picked from commit 64bf915cd851ab604cb87cd463725fd1c6460a1c)

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

 libavformat/mpegts.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 8fff8d4934..9a553554db 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -1745,10 +1745,10 @@ int ff_parse_mpeg2_descriptor(AVFormatContext *fc, 
AVStream *st, int stream_type
 }
 }
 
-   if (st->codecpar->extradata_size < language_count * 2)
-   return AVERROR_INVALIDDATA;
+if (st->codecpar->extradata_size < language_count * 2)
+return AVERROR_INVALIDDATA;
 
-   extradata = st->codecpar->extradata;
+extradata = st->codecpar->extradata;
 
 for (i = 0; i < language_count; i++) {
 language[i * 4 + 0] = get8(pp, desc_end);

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


[FFmpeg-cvslog] avcodec/mediacodecdec: refactor pts handling

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Tue Apr 24 13:51:15 
2018 -0700| [33042d632d12e3b69801057780742f8c3d13de55] | committer: Aman Gupta

avcodec/mediacodecdec: refactor pts handling

Also fixes a bug where EOS buffer was sent with incorrect
pts when not using surface generation.

Signed-off-by: Matthieu Bouron 
Signed-off-by: Aman Gupta 
(cherry picked from commit d8e92a89edd8e73cdc7f125f078c576df10b66f2)

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

 libavcodec/mediacodecdec_common.c | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/libavcodec/mediacodecdec_common.c 
b/libavcodec/mediacodecdec_common.c
index 56b3c4fd1e..c0f0a6b983 100644
--- a/libavcodec/mediacodecdec_common.c
+++ b/libavcodec/mediacodecdec_common.c
@@ -571,6 +571,7 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, 
MediaCodecDecContext *s,
 FFAMediaCodec *codec = s->codec;
 int status;
 int64_t input_dequeue_timeout_us = INPUT_DEQUEUE_TIMEOUT_US;
+int64_t pts;
 
 if (s->flushing) {
 av_log(avctx, AV_LOG_ERROR, "Decoder is flushing and cannot accept new 
buffer "
@@ -605,14 +606,14 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, 
MediaCodecDecContext *s,
 return AVERROR_EXTERNAL;
 }
 
+pts = pkt->pts;
+if (pts != AV_NOPTS_VALUE && avctx->pkt_timebase.num && 
avctx->pkt_timebase.den) {
+pts = av_rescale_q(pts, avctx->pkt_timebase, AV_TIME_BASE_Q);
+}
+
 if (need_draining) {
-int64_t pts = pkt->pts;
 uint32_t flags = ff_AMediaCodec_getBufferFlagEndOfStream(codec);
 
-if (s->surface) {
-pts = av_rescale_q(pts, avctx->pkt_timebase, AV_TIME_BASE_Q);
-}
-
 av_log(avctx, AV_LOG_DEBUG, "Sending End Of Stream signal\n");
 
 status = ff_AMediaCodec_queueInputBuffer(codec, index, 0, 0, pts, 
flags);
@@ -627,16 +628,10 @@ int ff_mediacodec_dec_send(AVCodecContext *avctx, 
MediaCodecDecContext *s,
 s->draining = 1;
 break;
 } else {
-int64_t pts = pkt->pts;
-
 size = FFMIN(pkt->size - offset, size);
 memcpy(data, pkt->data + offset, size);
 offset += size;
 
-if (avctx->pkt_timebase.num && avctx->pkt_timebase.den) {
-pts = av_rescale_q(pts, avctx->pkt_timebase, AV_TIME_BASE_Q);
-}
-
 status = ff_AMediaCodec_queueInputBuffer(codec, index, 0, size, 
pts, 0);
 if (status < 0) {
 av_log(avctx, AV_LOG_ERROR, "Failed to queue input buffer 
(status = %d)\n", status);

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


[FFmpeg-cvslog] avformat/mpegts: clean up whitespace

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Wed May  9 12:43:38 
2018 -0700| [7ad163c258f2068961433c15a7281d25c5a302ba] | committer: Aman Gupta

avformat/mpegts: clean up whitespace

Signed-off-by: Aman Gupta 
(cherry picked from commit 07d9c31055e6e07629506246d68d93b84bec1507)

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

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

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index c6a0228253..c09ba638c6 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -170,8 +170,8 @@ static const AVOption options[] = {
  {.i64 = 1}, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
 {"ts_packetsize", "output option carrying the raw packet size", 
offsetof(MpegTSContext, raw_packet_size), AV_OPT_TYPE_INT,
  {.i64 = 0}, 0, 0, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_EXPORT | 
AV_OPT_FLAG_READONLY },
-{"scan_all_pmts",   "scan and combine all PMTs", offsetof(MpegTSContext, 
scan_all_pmts), AV_OPT_TYPE_BOOL,
- { .i64 =  -1}, -1, 1,  AV_OPT_FLAG_DECODING_PARAM },
+{"scan_all_pmts", "scan and combine all PMTs", offsetof(MpegTSContext, 
scan_all_pmts), AV_OPT_TYPE_BOOL,
+ {.i64 = -1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM },
 {"skip_changes", "skip changing / adding streams / programs", 
offsetof(MpegTSContext, skip_changes), AV_OPT_TYPE_BOOL,
  {.i64 = 0}, 0, 1, 0 },
 {"skip_clear", "skip clearing programs", offsetof(MpegTSContext, 
skip_clear), AV_OPT_TYPE_BOOL,

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


[FFmpeg-cvslog] avformat/mpegts: initialize section_buf to fix valgrind test failure

2018-05-18 Thread Aman Gupta
ffmpeg | branch: release/4.0 | Aman Gupta  | Mon May 14 10:24:44 
2018 -0700| [d1845e7f1a3960bfbaf06c9b280121e8499204f8] | committer: Aman Gupta

avformat/mpegts: initialize section_buf to fix valgrind test failure

http://fate.ffmpeg.org/report.cgi?slot=x86_64-archlinux-gcc-valgrind&time=20180513001958

Signed-off-by: Aman Gupta 
(cherry picked from commit 42a03e77000692ad6de032b8cf684e1d6ec73790)

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

 libavformat/mpegts.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index a6d0624882..8fff8d4934 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -490,7 +490,7 @@ static MpegTSFilter 
*mpegts_open_section_filter(MpegTSContext *ts,
 sec = &filter->u.section_filter;
 sec->section_cb  = section_cb;
 sec->opaque  = opaque;
-sec->section_buf = av_malloc(MAX_SECTION_SIZE);
+sec->section_buf = av_mallocz(MAX_SECTION_SIZE);
 sec->check_crc   = check_crc;
 sec->last_ver= -1;
 

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