Re: [FFmpeg-devel] [PATCH 6/8] Add suppoort for using libklvanc from within decklink capture module

2017-12-29 Thread Aaron Levinson

Patch title:  "suppoort" -> "support", also "decklink" -> "DeckLink"

On 12/29/2017 10:12 AM, Devin Heitmueller wrote:

Make use of libklvanc from within the decklink capture module,
initially for EIA-708 and AFD.  Support for other VANC types will
come in subsequent patches.

Incorporates feedback from Derek Buitenhuis 
and James Almer 

Signed-off-by: Devin Heitmueller 
---
  libavdevice/decklink_dec.cpp | 133 +++
  1 file changed, 133 insertions(+)

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 8d4070eecd..86db6d8fbd 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -3,6 +3,7 @@
   * Copyright (c) 2013-2014 Luca Barbato, Deti Fliegl
   * Copyright (c) 2014 Rafaël Carré
   * Copyright (c) 2017 Akamai Technologies, Inc.
+ * Copyright (c) 2017 LTN Global Communications, Inc.
   *
   * This file is part of FFmpeg.
   *
@@ -671,10 +672,123 @@ error:
  return ret;
  }
  
+#if CONFIG_LIBKLVANC

+/* VANC Callbacks */
+struct vanc_cb_ctx {
+AVFormatContext *avctx;
+AVPacket *pkt;
+};
+static int cb_AFD(void *callback_context, struct klvanc_context_s *ctx,
+  struct klvanc_packet_afd_s *pkt)
+{
+struct vanc_cb_ctx *cb_ctx = (struct vanc_cb_ctx *)callback_context;
+uint8_t *afd;
+
+afd = av_packet_new_side_data(cb_ctx->pkt, AV_PKT_DATA_AFD, 1);
+if (afd == NULL) {
+return AVERROR(ENOMEM);
+}
+afd[0] = pkt->hdr.payload[0] >> 3;
+
+return 0;
+}
+
+static int cb_EIA_708B(void *callback_context, struct klvanc_context_s *ctx,
+   struct klvanc_packet_eia_708b_s *pkt)
+{
+struct vanc_cb_ctx *cb_ctx = (struct vanc_cb_ctx *)callback_context;
+decklink_cctx *cctx = (struct decklink_cctx *)cb_ctx->avctx->priv_data;
+struct decklink_ctx *decklink_ctx = (struct decklink_ctx *)cctx->ctx;
+uint16_t expected_cdp;
+uint8_t *cc;
+
+if (!pkt->checksum_valid)
+return 0;
+
+if (!pkt->header.ccdata_present)
+return 0;
+
+expected_cdp = decklink_ctx->cdp_sequence_num + 1;
+decklink_ctx->cdp_sequence_num = pkt->header.cdp_hdr_sequence_cntr;
+if (pkt->header.cdp_hdr_sequence_cntr != expected_cdp) {
+av_log(cb_ctx->avctx, AV_LOG_DEBUG,
+   "CDP counter inconsistent.  Received=0x%04x Expected=%04x\n",
+   pkt->header.cdp_hdr_sequence_cntr, expected_cdp);
+return 0;
+}
+
+cc = av_packet_new_side_data(cb_ctx->pkt, AV_PKT_DATA_A53_CC, 
pkt->ccdata.cc_count * 3);
+if (cc == NULL)
+return AVERROR(ENOMEM);
+
+for (int i = 0; i < pkt->ccdata.cc_count; i++) {
+cc[3*i] = 0xf8 | (pkt->ccdata.cc[i].cc_valid ? 0x04 : 0x00) |
+  (pkt->ccdata.cc[i].cc_type & 0x03);
+cc[3*i+1] = pkt->ccdata.cc[i].cc_data[0];
+cc[3*i+2] = pkt->ccdata.cc[i].cc_data[1];
+}
+
+return 0;
+}
+
+static struct klvanc_callbacks_s callbacks =
+{
+cb_AFD,
+cb_EIA_708B,
+NULL,
+NULL,
+NULL,
+NULL,
+};
+/* End: VANC Callbacks */
+
+/* Take one line of V210 from VANC, colorspace convert and feed it to the
+ * VANC parser. We'll expect our VANC message callbacks to happen on this
+ * same calling thread.
+ */
+static int klvanc_handle_line(AVFormatContext *avctx, struct klvanc_context_s 
*vanc_ctx,
+  unsigned char *buf, unsigned int uiWidth, 
unsigned int lineNr,
+  AVPacket *pkt)
+{
+/* Convert the vanc line from V210 to CrCB422, then vanc parse it */
+
+/* We need two kinds of type pointers into the source vbi buffer */
+/* TODO: What the hell is this, two ptrs? */
+const uint32_t *src = (const uint32_t *)buf;
+
+/* Convert Blackmagic pixel format to nv20.
+ * src pointer gets mangled during conversion, hence we need its own
+ * ptr instead of passing vbiBufferPtr.
+ * decoded_words should be atleast 2 * uiWidth.
+ */
+uint16_t decoded_words[16384];
+
+/* On output each pixel will be decomposed into three 16-bit words (one 
for Y, U, V) */
+memset(_words[0], 0, sizeof(decoded_words));
+uint16_t *p_anc = decoded_words;
+if (klvanc_v210_line_to_nv20_c(src, p_anc, sizeof(decoded_words), (uiWidth / 
6) * 6) < 0)
+return AVERROR(EINVAL);
+
+if (vanc_ctx) {
+struct vanc_cb_ctx cb_ctx = {
+.avctx = avctx,
+.pkt = pkt
+};
+vanc_ctx->callback_context = _ctx;
+int ret = klvanc_packet_parse(vanc_ctx, lineNr, decoded_words, 
sizeof(decoded_words) / (sizeof(uint16_t)));
+if (ret < 0) {
+return AVERROR(EINVAL);
+}
+}
+return 0;
+}
+#endif
+
  HRESULT decklink_input_callback::VideoInputFrameArrived(
  IDeckLinkVideoInputFrame *videoFrame, IDeckLinkAudioInputPacket 
*audioFrame)
  {
  decklink_cctx *cctx = (struct decklink_cctx 

Re: [FFmpeg-devel] [PATCH 5/8] Support encoding of Active Format Description (AFD) in libx264

2017-12-29 Thread Aaron Levinson

On 12/29/2017 10:12 AM, Devin Heitmueller wrote:

If AFD side data is present, include it in an H.264 SEI payload when
encoding with libx264.

This is done in the same manner that we currently handle A53 closed
captions (where the business logic for constructing the SEI is in
libavcodec/utils.c), so it should be portable to the other encoder
types (i.e. videotoolbox, etc).

Updated to reflect feedback from Derek Buitenhuis 

Signed-off-by: Devin Heitmueller 
---
  libavcodec/internal.h |  3 +++
  libavcodec/libx264.c  | 47 +++
  libavcodec/utils.c| 36 
  3 files changed, 82 insertions(+), 4 deletions(-)

diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 6deaf1d204..4db33eb020 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -408,6 +408,9 @@ int ff_side_data_set_encoder_stats(AVPacket *pkt, int 
quality, int64_t *error, i
  int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len,
   void **data, size_t *sei_size);
  
+int ff_alloc_afd_sei(const AVFrame *frame, size_t prefix_len,

+ void **data, size_t *sei_size);
+
  /**
   * Get an estimated video bitrate based on frame size, frame rate and coded
   * bits per pixel.
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 9c67c91f33..9a9667079e 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -86,6 +86,7 @@ typedef struct X264Context {
  int forced_idr;
  int coder;
  int a53_cc;
+int afd;
  int b_frame_strategy;
  int chroma_offset;
  int scenechange_threshold;
@@ -275,6 +276,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, 
const AVFrame *frame,
  x264_nal_t *nal;
  int nnal, i, ret;
  x264_picture_t pic_out = {0};
+int num_payloads = 0;
  int pict_type;
  
  x264_picture_init( >pic );

@@ -323,10 +325,46 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, 
const AVFrame *frame,
  } else {
  x4->pic.extra_sei.sei_free = av_free;
  
-x4->pic.extra_sei.payloads[0].payload_size = sei_size;

-x4->pic.extra_sei.payloads[0].payload = sei_data;
-x4->pic.extra_sei.num_payloads = 1;
-x4->pic.extra_sei.payloads[0].payload_type = 4;
+x4->pic.extra_sei.payloads[num_payloads].payload_size = 
sei_size;
+x4->pic.extra_sei.payloads[num_payloads].payload = 
sei_data;
+x4->pic.extra_sei.payloads[num_payloads].payload_type = 4;
+x4->pic.extra_sei.num_payloads++;
+num_payloads++;
+}
+}
+}
+
+/* Active Format Description */
+if (x4->afd) {
+void *sei_data;
+size_t sei_size;
+
+ret = ff_alloc_afd_sei(frame, 0, _data, _size);
+if (ret < 0) {
+for (i = 0; i < num_payloads; i++)
+av_free(x4->pic.extra_sei.payloads[i].payload);
+av_free(x4->pic.extra_sei.payloads);


Seems like it would be appropriate to use av_freep() for the last one to 
make sure that payloads is zeroed out before returning.  Applies in 
other places.



+return AVERROR(ENOMEM);
+} else if (sei_data) {
+x264_sei_payload_t *payloads;
+payloads = av_realloc(x4->pic.extra_sei.payloads,
+  sizeof(x4->pic.extra_sei.payloads[0]) * 
(num_payloads + 1));
+if (payloads == NULL) {
+av_log(ctx, AV_LOG_ERROR, "Not enough memory for AFD, 
skipping\n");
+for (i = 0; i < num_payloads; i++)
+av_free(x4->pic.extra_sei.payloads[i].payload);
+av_free(x4->pic.extra_sei.payloads);
+av_free(sei_data);
+return AVERROR(ENOMEM);
+} else {
+x4->pic.extra_sei.payloads = payloads;
+x4->pic.extra_sei.sei_free = av_free;
+
+x4->pic.extra_sei.payloads[num_payloads].payload_size = 
sei_size;
+x4->pic.extra_sei.payloads[num_payloads].payload = 
sei_data;
+x4->pic.extra_sei.payloads[num_payloads].payload_type = 4;
+x4->pic.extra_sei.num_payloads++;
+num_payloads++;
  }
  }
  }
@@ -892,6 +930,7 @@ static const AVOption options[] = {
  {"passlogfile", "Filename for 2 pass stats", OFFSET(stats), 
AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE},
  {"wpredp", "Weighted prediction for P-frames", OFFSET(wpredp), 
AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE},
  {"a53cc",  "Use A53 Closed Captions (if available)",  
OFFSET(a53_cc),

Re: [FFmpeg-devel] [PATCH, V2] avformat/concat: Fix wrong wrapped timestamp

2017-12-29 Thread Wu Zhiqiang
On Sat, Dec 30, 2017 at 5:19 AM, Carl Eugen Hoyos 
wrote:

> 2017-12-29 18:38 GMT+01:00 Nicolas George :
>
> > I am sorry, I do not understand what you are saying at all.
> >
> > Maybe it would help if you were to give a fully detailed of the simplest
> > use case you are trying to fix
>
> Maybe ticket #6908?
>
> Carl Eugen
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
i am not sure ticket #6908 is the same case.

The command to  generate sample video:

ffmpeg -f lavfi -i testsrc=duration=120  -c:v h264 -profile:v high -level:v
10 -pix_fmt yuv420p -r 30 -g 30 -c:a aac test.flv
echo -e "file test.flv\nduration 120" > playlist
ffplay -f concat playlist -ss 90 -max_ts_probe 0

then seek to time before 30s , the result timestamp  is huge and
print:"Invalid timestamps stream"

ffmpeg version N-89656-g0c78b6a Copyright (c) 2000-2017 the FFmpeg
developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
Thanks
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/8] decklink: Introduce support for capture of multiple audio streams

2017-12-29 Thread Aaron Levinson

On 12/29/2017 10:12 AM, Devin Heitmueller wrote:

Add support for the ability to capture all audio pairs available
to the capture hardware.  Each pair is exposed as a different audio
stream, which matches up with the most common use cases for the
broadcast space (i.e. where there is one stereo pair per audio
language).

To support the existing use case where multi-channel audio can be
captured (i.e. 7.1), we introduced a new configuration option, which
defaults to the existing behavior.
---
  libavdevice/decklink_common.cpp |   9 +++
  libavdevice/decklink_common.h   |   8 ++-
  libavdevice/decklink_common_c.h |   6 ++
  libavdevice/decklink_dec.cpp| 134 +++-
  libavdevice/decklink_dec_c.c|   3 +
  5 files changed, 130 insertions(+), 30 deletions(-)

diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index ba091dadea..91a626221d 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -480,5 +480,14 @@ int ff_decklink_init_device(AVFormatContext *avctx, const 
char* name)
  return AVERROR_EXTERNAL;
  }
  
+if (ctx->attr->GetInt(BMDDeckLinkMaximumAudioChannels, >max_audio_channels) != S_OK) {

+av_log(avctx, AV_LOG_WARNING, "Could not determine number of audio 
channels\n");
+ctx->max_audio_channels = 0;
+}
+if (ctx->max_audio_channels > DECKLINK_MAX_AUDIO_CHANNELS) {
+av_log(avctx, AV_LOG_WARNING, "Decklink card reported support for more 
channels than ffmpeg supports\n");


"Decklink" -> "DeckLink", "ffmpeg" -> "FFmpeg".  Also, I think it is 
preferable to not state "FFmpeg" in this log message, as technically 
this is in libavdevice.  If, say, libav were to merge your changes into 
their codebase, then this particular log message would make that 
annoying.  Could be something as simple as "Max audio channels for 
DeckLink reduced from %d to %d.\n".



+ctx->max_audio_channels = DECKLINK_MAX_AUDIO_CHANNELS;
+}
+
  return 0;
  }
diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h
index 143bbb951a..06b241029e 100644
--- a/libavdevice/decklink_common.h
+++ b/libavdevice/decklink_common.h
@@ -37,6 +37,10 @@
  #define DECKLINK_BOOL bool
  #endif
  
+/* Maximum number of channels possible across variants of Blackmagic cards.

+   Actual number for any particular model of card may be lower */
+#define DECKLINK_MAX_AUDIO_CHANNELS 32
+
  class decklink_output_callback;
  class decklink_input_callback;
  
@@ -71,6 +75,7 @@ struct decklink_ctx {

  int bmd_height;
  int bmd_field_dominance;
  int supports_vanc;
+int64_t max_audio_channels;


Rationale for using an int64_t here when an int would likely be 
sufficient?  I understand that GetInt() takes an int64_t as input, but 
you could use a temporary int64_t with GetInt() and store the value in a 
int max_audio_channels.


  
  /* Capture buffer queue */

  AVPacketQueue queue;
@@ -85,7 +90,8 @@ struct decklink_ctx {
  int64_t last_pts;
  unsigned long frameCount;
  unsigned int dropped;
-AVStream *audio_st;
+AVStream *audio_st[DECKLINK_MAX_AUDIO_CHANNELS];
+int num_audio_streams;
  AVStream *video_st;
  AVStream *teletext_st;
  uint16_t cdp_sequence_num;
diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h
index 368ac259e4..02011ed53b 100644
--- a/libavdevice/decklink_common_c.h
+++ b/libavdevice/decklink_common_c.h
@@ -30,6 +30,11 @@ typedef enum DecklinkPtsSource {
  PTS_SRC_WALLCLOCK = 4,
  } DecklinkPtsSource;
  
+typedef enum DecklinkAudioMode {

+AUDIO_MODE_DISCRETE = 0,
+AUDIO_MODE_PAIRS = 1,
+} DecklinkAudioMode;
>   struct decklink_cctx {
  const AVClass *cclass;
  
@@ -42,6 +47,7 @@ struct decklink_cctx {

  double preroll;
  int v210;
  int audio_channels;
+int audio_mode;
  int audio_depth;
  int duplex_mode;
  DecklinkPtsSource audio_pts_source;
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 94dae26003..8d4070eecd 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -627,9 +627,54 @@ static int64_t get_pkt_pts(IDeckLinkVideoInputFrame 
*videoFrame,
  return pts;
  }
  
+static int setup_audio(AVFormatContext *avctx)

+{
+struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
+struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
+AVStream *st;
+int ret = 0;
+
+if (cctx->audio_mode == AUDIO_MODE_DISCRETE) {
+st = avformat_new_stream(avctx, NULL);
+if (!st) {
+av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
+ret = AVERROR(ENOMEM);
+goto error;
+}
+st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
+st->codecpar->codec_id= ctx->audio_depth == 32 ? 
AV_CODEC_ID_PCM_S32LE : AV_CODEC_ID_PCM_S16LE;
+st->codecpar->sample_rate = bmdAudioSampleRate48kHz;
+ 

Re: [FFmpeg-devel] [PATCH 1/8] libavdevice/decklink: Add support for EIA-708 output over SDI

2017-12-29 Thread Aaron Levinson

On 12/29/2017 10:12 AM, Devin Heitmueller wrote:

Hook in libklvanc and use it for output of EIA-708 captions over
SDI.  The bulk of this patch is just general support for ancillary
data for the Decklink SDI module - the real work for construction
of the EIA-708 CDP and VANC line construction is done by libklvanc.

Libklvanc can be found at: https://github.com/stoth68000/libklvanc

Updated to reflect feedback from Marton Balint 

Signed-off-by: Devin Heitmueller 
---
  configure   |   4 ++
  libavcodec/v210enc.c|  10 +++
  libavdevice/decklink_common.cpp |  17 +++--
  libavdevice/decklink_common.h   |  10 +++
  libavdevice/decklink_enc.cpp| 154 ++--
  5 files changed, 185 insertions(+), 10 deletions(-)

diff --git a/configure b/configure
index 6748ef8bc9..19fd04bb6f 100755
--- a/configure
+++ b/configure
@@ -238,6 +238,7 @@ External library support:
--enable-libiec61883 enable iec61883 via libiec61883 [no]
--enable-libilbc enable iLBC de/encoding via libilbc [no]
--enable-libjack enable JACK audio sound server [no]
+  --enable-libklvanc   enable Kernel Labs VANC processing [no]
--enable-libkvazaar  enable HEVC encoding via libkvazaar [no]
--enable-libmodplug  enable ModPlug via libmodplug [no]
--enable-libmp3lame  enable MP3 encoding via libmp3lame [no]
@@ -1602,6 +1603,7 @@ EXTERNAL_LIBRARY_LIST="
  libiec61883
  libilbc
  libjack
+libklvanc
  libkvazaar
  libmodplug
  libmp3lame
@@ -3074,6 +3076,7 @@ decklink_deps_any="libdl LoadLibrary"
  decklink_indev_deps="decklink threads"
  decklink_indev_extralibs="-lstdc++"
  decklink_outdev_deps="decklink threads"
+decklink_outdev_suggest="libklvanc"
  decklink_outdev_extralibs="-lstdc++"
  libndi_newtek_indev_deps="libndi_newtek"
  libndi_newtek_indev_extralibs="-lndi"
@@ -5835,6 +5838,7 @@ enabled libgsm&& { for gsm_hdr in "gsm.h" 
"gsm/gsm.h"; do
 check_lib libgsm "${gsm_hdr}" gsm_create -lgsm 
&& break;
 done || die "ERROR: libgsm not found"; }
  enabled libilbc   && require libilbc ilbc.h WebRtcIlbcfix_InitDecode 
-lilbc $pthreads_extralibs
+enabled libklvanc && require libklvanc libklvanc/vanc.h 
klvanc_context_create -lklvanc
  enabled libkvazaar&& require_pkg_config libkvazaar "kvazaar >= 0.8.1" 
kvazaar.h kvz_api_get
  # While it may appear that require is being used as a pkg-config
  # fallback for libmfx, it is actually being used to detect a different
diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index a6afbbfc41..51804e3bac 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -123,6 +123,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
  int aligned_width = ((avctx->width + 47) / 48) * 48;
  int stride = aligned_width * 8 / 3;
  int line_padding = stride - ((avctx->width * 8 + 11) / 12) * 4;
+AVFrameSideData *side_data;
  int h, w, ret;
  uint8_t *dst;
  
@@ -233,6 +234,15 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,

  }
  }
  
+side_data = av_frame_get_side_data(pic, AV_FRAME_DATA_A53_CC);

+if (side_data && side_data->size) {
+uint8_t *buf = av_packet_new_side_data(pkt, AV_PKT_DATA_A53_CC, 
side_data->size);
+if (buf)
+memcpy(buf, side_data->data, side_data->size);
+else
+return AVERROR(ENOMEM);
+}
+
  pkt->flags |= AV_PKT_FLAG_KEY;
  *got_packet = 1;
  return 0;
diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index 6ef2c529f4..ba091dadea 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -254,10 +254,19 @@ int ff_decklink_set_format(AVFormatContext *avctx,
 , NULL) != S_OK)
  return -1;
  } else {
-if (ctx->dlo->DoesSupportVideoMode(ctx->bmd_mode, bmdFormat8BitYUV,
-   bmdVideoOutputFlagDefault,
-   , NULL) != S_OK)
-return -1;
+ctx->supports_vanc = 1;
+if (ctx->dlo->DoesSupportVideoMode(ctx->bmd_mode, ctx->raw_format,
+   bmdVideoOutputVANC,
+   , NULL) != S_OK) {
+/* Try again, but without VANC enabled */
+if (ctx->dlo->DoesSupportVideoMode(ctx->bmd_mode, ctx->raw_format,
+   bmdVideoOutputFlagDefault,
+   , NULL) != S_OK) {
+return -1;
+}
+ctx->supports_vanc = 0;
+}
+
  }
  if (support == bmdDisplayModeSupported)
  return 0;
diff --git a/libavdevice/decklink_common.h 

Re: [FFmpeg-devel] [PATCH 2/8] decklink: Add support for output of Active Format Description (AFD)

2017-12-29 Thread Aaron Levinson

On 12/29/2017 1:20 PM, Devin Heitmueller wrote:



On Dec 29, 2017, at 4:09 PM, Carl Eugen Hoyos  wrote:

2017-12-29 22:02 GMT+01:00 Devin Heitmueller :



On Dec 29, 2017, at 3:48 PM, Carl Eugen Hoyos  wrote:

2017-12-29 19:12 GMT+01:00 Devin Heitmueller :


+/* FIXME: Should really rely on the coded_width but seems like that
+   is not accessible to libavdevice outputs */
+if ((st->codecpar->width == 1280 && st->codecpar->height == 720) ||
+(st->codecpar->width == 1920 && st->codecpar->height == 1080))
+pkt->aspectRatio = ASPECT_16x9;
+else
+pkt->aspectRatio = ASPECT_4x3;


I most likely won't use this (and I have never seen a decklink card)
so please feel free to ignore:
Similar code has caused some trouble with mxf files, is there
really no saner solution? Like comparing what the actual aspect
ratio is more similar to? Is SAR really always 1 for decklink?
("All the world's a VAX.")


So this is definitely a confusing block of code, and you aren’t the first one to
ask about it (there were questions in the last round of review as well). The
aspect ratio referred to here is actually of the original coded video - not how
it’s supposed to be displayed.  Hence, for example, 720x480 in widescreen
with a non-square PAR would still have the aspect ratio set to 4x3, since
that particular field describes the coded video (i.e. *not* how it’s supposed
to be rendered).


And a resolution of 1024x576 does not exist for decklink?

What about 1920x1088?



The Blackmagic cards have a fairly constrained set of modes which are supported (see 
the definition of BMDDisplayMode in the Decklink SDK documentation).  Neither of the 
modes you mentioned are available for output, although I’m not sure what 
st->codecpar->width would be set to if swscale is used between the decoder and 
the output.

Bear in mind, I’m not particularly happy with how that block of code is done 
either (which is why I marked it with a FIXME), but it’s probably good enough 
for 95% of use cases.

Devin


Technically, there are a number of 2K and 4K video modes supported by 
some DeckLink cards that have a 16x9 aspect ratio as well.  This code 
would treat such video modes at 4:3.  The various 4K DCI video modes 
supported by Blackmagic use an aspect ratio of 256:135, although perhaps 
it is sufficient to treat those as 16:9.  Perhaps the logic should be, 
anything with a width of 1280 or greater (or a height of 720 or greater) 
is 16:9--everything else can be treated as 4:3.


Admittedly, libklvanc may not support VANC for 2K and 4K video anyway, 
but the Blackmagic devices do support it, so if you want to rule those 
out, then some explicit code to only support up to 720p/1080i (maybe 
1080p?) probably ought to be added.


On a separate note, based on a similar review I did awhile back, if this 
set of patches only supports a specific set of video modes, then there 
probably ought to be checks to make sure the code changes are only 
exercised for those video modes.


Aaron Levinson
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] avformat/hls: ignore http_persistent for segments requring crypto

2017-12-29 Thread Aman Gupta
From: Aman Gupta 

Encrypted HLS segments have regular http:// urls, but open_input()
actually prefixes them with crypto+ before calling open_url(), so
they end up using the crypto protocol and not the http protocol.

This means invoking ff_http_do_new_request will fail, so we avoid
calling it in the first place. After the previous commit, the failure
results in a warning printed to the user. In earlier versions, the
failure would cause a segfault.

Signed-off-by: Aman Gupta 
---
 libavformat/hls.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index dccc7c7dd2..d9f7c6de4d 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1479,7 +1479,7 @@ reload:
 
 seg = next_segment(v);
 if (c->http_multiple == 1 && !v->input_next_requested &&
-seg && av_strstart(seg->url, "http", NULL)) {
+seg && seg->key_type == KEY_NONE && av_strstart(seg->url, "http", 
NULL)) {
 ret = open_input(c, v, seg, >input_next);
 if (ret < 0) {
 if (ff_check_interrupt(c->interrupt_callback))
@@ -1511,7 +1511,8 @@ reload:
 
 return ret;
 }
-if (c->http_persistent && av_strstart(seg->url, "http", NULL)) {
+if (c->http_persistent &&
+seg->key_type == KEY_NONE && av_strstart(seg->url, "http", NULL)) {
 v->input_read_done = 1;
 } else {
 ff_format_io_close(v->parent, >input);
-- 
2.14.2

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


[FFmpeg-devel] [PATCH 1/2] avformat/http: return EINVAL if ff_http_do_new_request is called with non-http URLContext

2017-12-29 Thread Aman Gupta
From: Aman Gupta 

Signed-off-by: Aman Gupta 
---
 libavformat/http.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavformat/http.c b/libavformat/http.c
index a376f1a488..8f7e56de54 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -311,6 +311,11 @@ int ff_http_do_new_request(URLContext *h, const char *uri)
 char hostname1[1024], hostname2[1024], proto1[10], proto2[10];
 int port1, port2;
 
+if (!h->prot ||
+!(!strcmp(h->prot->name, "http") ||
+  !strcmp(h->prot->name, "https")))
+return AVERROR(EINVAL);
+
 av_url_split(proto1, sizeof(proto1), NULL, 0,
  hostname1, sizeof(hostname1), ,
  NULL, 0, s->location);
-- 
2.14.2

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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/hls: use AVIOContext new_http_request callback

2017-12-29 Thread Aman Gupta
On Fri, Dec 29, 2017 at 2:45 PM, Nicolas George  wrote:

> Aman Gupta (2017-12-29):
> > From: Aman Gupta 
> >
> > This fixes a segfault when streaming from an HLS playlist which uses
> > crypto, by ensuring ff_http_do_new_request will never be invoked on a
> > non-http URLContext.
> >
> > Additionally it simplifies the demuxer by removing http.h and all the
> > http specific code in open_url_keepalive.
>
> It it awfully specific for something quite minor. And it is messing with
> the public API, that requires careful design.
>

I understand the public API should not be changed lightly, but I believe
this approach is far
superior to the mess of http specific checks currently present all over
hls.c. It also makes it easier
in the future to add http keepalive support to other consumers like the
dash demuxer and the
crypto protocol.


>
> I suggest to have ff_http_do_new_request() check that its argument is
> really a HTTP context and return EINVAL or ENOSYS otherwise.
>

I'll go ahead and submit another patchset using this approach to fix the
immediate
segfault while we consider a larger API change.

Thanks,
Aman


>
> Regards,
>
> --
>   Nicolas George
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avformat/hls: use AVIOContext new_http_request callback

2017-12-29 Thread Nicolas George
Aman Gupta (2017-12-29):
> From: Aman Gupta 
> 
> This fixes a segfault when streaming from an HLS playlist which uses
> crypto, by ensuring ff_http_do_new_request will never be invoked on a
> non-http URLContext.
> 
> Additionally it simplifies the demuxer by removing http.h and all the
> http specific code in open_url_keepalive.

It it awfully specific for something quite minor. And it is messing with
the public API, that requires careful design.

I suggest to have ff_http_do_new_request() check that its argument is
really a HTTP context and return EINVAL or ENOSYS otherwise.

Regards,

-- 
  Nicolas George


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavf/mov: Do not blindly allocate stts entries

2017-12-29 Thread Carl Eugen Hoyos
2017-11-28 21:32 GMT+01:00 Michael Niedermayer :
> On Mon, Nov 27, 2017 at 05:24:14AM +0100, Carl Eugen Hoyos wrote:

>>  for (i = 0; i < entries && !pb->eof_reached; i++) {
>> -int sample_duration;
>> +int sample_duration, ret;
>>  unsigned int sample_count;
>> +if (i > sc->stts_count) {
>> +ret = av_reallocp_array(>stts_data,
>> +FFMIN(sc->stts_count * 2LL, entries),
>> +sizeof(*sc->stts_data));
>
> this should use a variant of av_fast_realloc

Do you prefer the new patch?
The old variant here looks slightly saner to me.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavf/mov: Do not blindly allocate stts entries

2017-12-29 Thread Carl Eugen Hoyos
2017-12-29 22:32 GMT+01:00 Derek Buitenhuis :

> Completely Unrelated: Multiple types of atoms are similar to the stts atom,
> in that they contain a coded number of entries we allocate - maybe we should
> consistently apply this sort of allocation strategy to them, too (out of
> scope of this patch, though)?

This is correct but I don't immediately see how this can be done
except on a case-by-case basis.

(And I prefer working with actual samples.)

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/2] avformat/hls: use AVIOContext new_http_request callback

2017-12-29 Thread Aman Gupta
From: Aman Gupta 

This fixes a segfault when streaming from an HLS playlist which uses
crypto, by ensuring ff_http_do_new_request will never be invoked on a
non-http URLContext.

Additionally it simplifies the demuxer by removing http.h and all the
http specific code in open_url_keepalive.

Signed-off-by: Aman Gupta 
Signed-off-by: wm4 
---
 libavformat/hls.c | 19 ++-
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index dccc7c7dd2..6c638537ff 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -26,7 +26,6 @@
  * http://tools.ietf.org/html/draft-pantos-http-live-streaming
  */
 
-#include "libavformat/http.h"
 #include "libavutil/avstring.h"
 #include "libavutil/avassert.h"
 #include "libavutil/intreadwrite.h"
@@ -611,19 +610,13 @@ static void update_options(char **dest, const char *name, 
void *src)
 static int open_url_keepalive(AVFormatContext *s, AVIOContext **pb,
   const char *url)
 {
-#if !CONFIG_HTTP_PROTOCOL
-return AVERROR_PROTOCOL_NOT_FOUND;
-#else
 int ret;
-URLContext *uc = ffio_geturlcontext(*pb);
-av_assert0(uc);
 (*pb)->eof_reached = 0;
-ret = ff_http_do_new_request(uc, url);
+ret = (*pb)->new_http_request(*pb, url);
 if (ret < 0) {
 ff_format_io_close(s, pb);
 }
 return ret;
-#endif
 }
 
 static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
@@ -670,7 +663,7 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
const char *url,
 else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5))
 return AVERROR_INVALIDDATA;
 
-if (is_http && c->http_persistent && *pb) {
+if (c->http_persistent && *pb && (*pb)->new_http_request) {
 ret = open_url_keepalive(c->ctx, pb, url);
 if (ret == AVERROR_EXIT) {
 return ret;
@@ -725,9 +718,9 @@ static int parse_playlist(HLSContext *c, const char *url,
 struct variant_info variant_info;
 char tmp_str[MAX_URL_SIZE];
 struct segment *cur_init_section = NULL;
-int is_http = av_strstart(url, "http", NULL);
 
-if (is_http && !in && c->http_persistent && c->playlist_pb) {
+if (!in && c->http_persistent &&
+c->playlist_pb && c->playlist_pb->new_http_request) {
 in = c->playlist_pb;
 ret = open_url_keepalive(c->ctx, >playlist_pb, url);
 if (ret == AVERROR_EXIT) {
@@ -761,7 +754,7 @@ static int parse_playlist(HLSContext *c, const char *url,
 if (ret < 0)
 return ret;
 
-if (is_http && c->http_persistent)
+if (c->http_persistent && in && in->new_http_request)
 c->playlist_pb = in;
 else
 close_in = 1;
@@ -1511,7 +1504,7 @@ reload:
 
 return ret;
 }
-if (c->http_persistent && av_strstart(seg->url, "http", NULL)) {
+if (c->http_persistent && v->input && v->input->new_http_request) {
 v->input_read_done = 1;
 } else {
 ff_format_io_close(v->parent, >input);
-- 
2.14.2

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


[FFmpeg-devel] [PATCH 1/2] avformat/avio: add new_http_request callback

2017-12-29 Thread Aman Gupta
From: Aman Gupta 

This callback is implemented on AVIOContext which are backed by an
HTTP URLContext. This allows the owner of the IO context to both
discover that it is capable of making additional http requests, and
to make such requests without including http.h. In particular this
avoids the use of internal functions to fetch the URLContext, and
prevents accidentally calling ff_http_do_new_request on a URLContext
which is not actually part of an HTTPContext.

Signed-off-by: Aman Gupta 
Signed-off-by: wm4 
---
 libavformat/avio.h|  6 ++
 libavformat/aviobuf.c | 10 ++
 libavformat/http.c|  2 ++
 libavformat/url.h |  1 +
 4 files changed, 19 insertions(+)

diff --git a/libavformat/avio.h b/libavformat/avio.h
index 75912ce6be..640ca9f9e2 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -349,6 +349,12 @@ typedef struct AVIOContext {
  * Try to buffer at least this amount of data before flushing it
  */
 int min_packet_size;
+
+/**
+ * Make a new request on the underlying http connection.
+ * This is internal only, do not use from outside.
+ */
+int (*new_http_request)(struct AVIOContext *pb, const char *uri);
 } AVIOContext;
 
 /**
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 86eb6579f4..8530c78823 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -922,6 +922,14 @@ static int64_t io_read_seek(void *opaque, int 
stream_index, int64_t timestamp, i
 return internal->h->prot->url_read_seek(internal->h, stream_index, 
timestamp, flags);
 }
 
+static int io_new_http_request(AVIOContext *s, const char *uri)
+{
+URLContext *uc = ffio_geturlcontext(s);
+if (!uc)
+return AVERROR(ENOSYS);
+return uc->prot->url_new_http_request(uc, uri);
+}
+
 int ffio_fdopen(AVIOContext **s, URLContext *h)
 {
 AVIOInternal *internal = NULL;
@@ -970,6 +978,8 @@ int ffio_fdopen(AVIOContext **s, URLContext *h)
 
 if (h->prot->url_read_seek)
 (*s)->seekable |= AVIO_SEEKABLE_TIME;
+if (h->prot->url_new_http_request)
+(*s)->new_http_request = io_new_http_request;
 }
 (*s)->short_seek_get = io_short_seek;
 (*s)->av_class = _avio_class;
diff --git a/libavformat/http.c b/libavformat/http.c
index a376f1a488..1dad129bdd 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -1712,6 +1712,7 @@ const URLProtocol ff_http_protocol = {
 .url_write   = http_write,
 .url_seek= http_seek,
 .url_close   = http_close,
+.url_new_http_request= ff_http_do_new_request,
 .url_get_file_handle = http_get_file_handle,
 .url_get_short_seek  = http_get_short_seek,
 .url_shutdown= http_shutdown,
@@ -1732,6 +1733,7 @@ const URLProtocol ff_https_protocol = {
 .url_write   = http_write,
 .url_seek= http_seek,
 .url_close   = http_close,
+.url_new_http_request= ff_http_do_new_request,
 .url_get_file_handle = http_get_file_handle,
 .url_get_short_seek  = http_get_short_seek,
 .url_shutdown= http_shutdown,
diff --git a/libavformat/url.h b/libavformat/url.h
index 4750bfff82..2f2d62e54f 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -62,6 +62,7 @@ typedef struct URLProtocol {
 int (*url_open2)(URLContext *h, const char *url, int flags, 
AVDictionary **options);
 int (*url_accept)(URLContext *s, URLContext **c);
 int (*url_handshake)(URLContext *c);
+int (*url_new_http_request)(URLContext *h, const char *uri);
 
 /**
  * Read data from the protocol.
-- 
2.14.2

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


Re: [FFmpeg-devel] h264: fix RTSP stream decoding

2017-12-29 Thread ser...@gavrushkin.com
> Please add "Fixes ticket #6422" to the commit message.
> 
> And maybe remove "rtsp" from the commit title, the issue
> is reproducible with files.

Done.

Please feel free to edit commit title/message as you wish for merge.

Thank you, 
Sergey

-



From e90ef7b56d4147ff6555468f0154321b55596846 Mon Sep 17 00:00:00 2001
From: Sergey Gavrushkin >
Date: Fri, 29 Dec 2017 20:03:50 +0300
Subject: [PATCH] h264: fix decoding

Fixes ticket #6422 . It is a regression fix for an issue that was introduced in 
commit
98c97994c5b90bdae02accb155eeceeb5224b8ef. Variable err_recognition is
ignored while extradata is decoded and the whole decoding process is
failed due to timeout.
---
libavcodec/h264_parse.c | 12 ++--
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
index fee28d9..009d50c 100644
--- a/libavcodec/h264_parse.c
+++ b/libavcodec/h264_parse.c
@@ -347,7 +347,7 @@ int ff_h264_init_poc(int pic_field_poc[2], int *pic_poc,
}

static int decode_extradata_ps(const uint8_t *data, int size, H264ParamSets *ps,
-   int is_avc, void *logctx)
+   int is_avc, int err_recognition, void *logctx)
{
H2645Packet pkt = { 0 };
int i, ret = 0;
@@ -363,13 +363,13 @@ static int decode_extradata_ps(const uint8_t *data, int 
size, H264ParamSets *ps,
switch (nal->type) {
case H264_NAL_SPS:
ret = ff_h264_decode_seq_parameter_set(>gb, logctx, ps, 0);
-if (ret < 0)
+if (ret < 0 && (err_recognition & AV_EF_EXPLODE))
goto fail;
break;
case H264_NAL_PPS:
ret = ff_h264_decode_picture_parameter_set(>gb, logctx, ps,
   nal->size_bits);
-if (ret < 0)
+if (ret < 0 && (err_recognition & AV_EF_EXPLODE))
goto fail;
break;
default:
@@ -393,7 +393,7 @@ static int decode_extradata_ps_mp4(const uint8_t *buf, int 
buf_size, H264ParamSe
{
int ret;

-ret = decode_extradata_ps(buf, buf_size, ps, 1, logctx);
+ret = decode_extradata_ps(buf, buf_size, ps, 1, err_recognition, logctx);
if (ret < 0 && !(err_recognition & AV_EF_EXPLODE)) {
GetByteContext gbc;
PutByteContext pbc;
@@ -425,7 +425,7 @@ static int decode_extradata_ps_mp4(const uint8_t *buf, int 
buf_size, H264ParamSe
escaped_buf_size = bytestream2_tell_p();
AV_WB16(escaped_buf, escaped_buf_size - 2);

-(void)decode_extradata_ps(escaped_buf, escaped_buf_size, ps, 1, 
logctx);
+(void)decode_extradata_ps(escaped_buf, escaped_buf_size, ps, 1, 
err_recognition, logctx);
// lorex.mp4 decodes ok even with extradata decoding failing
av_freep(_buf);
}
@@ -486,7 +486,7 @@ int ff_h264_decode_extradata(const uint8_t *data, int size, 
H264ParamSets *ps,
*nal_length_size = (data[4] & 0x03) + 1;
} else {
*is_avc = 0;
-ret = decode_extradata_ps(data, size, ps, 0, logctx);
+ret = decode_extradata_ps(data, size, ps, 0, err_recognition, logctx);
if (ret < 0)
return ret;
}
-- 
2.6.4
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavf/mov: Do not blindly allocate stts entries

2017-12-29 Thread Derek Buitenhuis
On 12/29/2017 9:32 PM, Derek Buitenhuis wrote:
> Because the buffer is now grown exponentially (by a factor of 2 every
> time it is resizes), it's possible that it ends up with almost double
> the size of 'entries' after resizes.
> 
> For example, consider a valid MP4 file with (1024 * 1024 + 1) entries.
> With the new code, the final buffer sizes will be (1024 * 1024 * 2) after
> iterating over everything. I don't know if it's something we care about.

Ah, actually disregard this too. Sigh. I must be on some sort of Christmas
drugs or something, because I'm misreading everything. Maybe too much eggnog.

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


Re: [FFmpeg-devel] [PATCH]lavf/mov: Do not blindly allocate stts entries

2017-12-29 Thread Derek Buitenhuis
On 12/29/2017 8:42 PM, Carl Eugen Hoyos wrote:
> Sorry, I don't understand this sentence - could you try with
> other words?

Because the buffer is now grown exponentially (by a factor of 2 every
time it is resizes), it's possible that it ends up with almost double
the size of 'entries' after resizes.

For example, consider a valid MP4 file with (1024 * 1024 + 1) entries.
With the new code, the final buffer sizes will be (1024 * 1024 * 2) after
iterating over everything. I don't know if it's something we care about.

Completely Unrelated: Multiple types of atoms are similar to the stts atom,
in that they contain a coded number of entries we allocate - maybe we should
consistently apply this sort of allocation strategy to them, too (out of
scope of this patch, though)?

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


Re: [FFmpeg-devel] [PATCH 3/8] decklink: Introduce support for capture of multiple audio streams

2017-12-29 Thread Devin Heitmueller

> On Dec 29, 2017, at 4:17 PM, Carl Eugen Hoyos  wrote:
> 
> 2017-12-29 22:14 GMT+01:00 Devin Heitmueller :
>> Hi Carl,
>> 
>>> On Dec 29, 2017, at 3:55 PM, Carl Eugen Hoyos  wrote:
>>> 
>>> 2017-12-29 19:12 GMT+01:00 Devin Heitmueller :
>>> 
 +for (int i = 0; i < ctx->max_audio_channels / 2; i++) {
 +st = avformat_new_stream(avctx, NULL);
 +if (!st) {
 +av_log(avctx, AV_LOG_ERROR, "Cannot add stream %d\n", i);
 +ret = AVERROR(ENOMEM);
 +goto error;
 +}
 +st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
 +st->codecpar->codec_id= ctx->audio_depth == 32 ?
 AV_CODEC_ID_PCM_S32LE : AV_CODEC_ID_PCM_S16LE;
 +st->codecpar->sample_rate = bmdAudioSampleRate48kHz;
 +st->codecpar->channels= 2;
 +avpriv_set_pts_info(st, 64, 1, 100);  /* 64 bits pts in 
 us */
 +ctx->audio_st[i] = st;
 +ctx->num_audio_streams++;
 +}
>>> 
>>> I would have expected that the channel_layout is set to STEREO in
>>> this case, is that not always true?
>> 
>> I’m not sure I understand your comment.  Is there some channel layout
>> property of the codec parameters I should be setting?
> 
> Yes, AVCodecParameters->channel_layout.

Ah, ok.  I will fix that and resubmit in the next series.

Thanks,

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


Re: [FFmpeg-devel] [PATCH 2/8] decklink: Add support for output of Active Format Description (AFD)

2017-12-29 Thread Devin Heitmueller

> On Dec 29, 2017, at 4:09 PM, Carl Eugen Hoyos  wrote:
> 
> 2017-12-29 22:02 GMT+01:00 Devin Heitmueller :
>> 
>>> On Dec 29, 2017, at 3:48 PM, Carl Eugen Hoyos  wrote:
>>> 
>>> 2017-12-29 19:12 GMT+01:00 Devin Heitmueller :
>>> 
 +/* FIXME: Should really rely on the coded_width but seems like 
 that
 +   is not accessible to libavdevice outputs */
 +if ((st->codecpar->width == 1280 && st->codecpar->height == 720) 
 ||
 +(st->codecpar->width == 1920 && st->codecpar->height == 1080))
 +pkt->aspectRatio = ASPECT_16x9;
 +else
 +pkt->aspectRatio = ASPECT_4x3;
>>> 
>>> I most likely won't use this (and I have never seen a decklink card)
>>> so please feel free to ignore:
>>> Similar code has caused some trouble with mxf files, is there
>>> really no saner solution? Like comparing what the actual aspect
>>> ratio is more similar to? Is SAR really always 1 for decklink?
>>> ("All the world's a VAX.")
>> 
>> So this is definitely a confusing block of code, and you aren’t the first 
>> one to
>> ask about it (there were questions in the last round of review as well). The
>> aspect ratio referred to here is actually of the original coded video - not 
>> how
>> it’s supposed to be displayed.  Hence, for example, 720x480 in widescreen
>> with a non-square PAR would still have the aspect ratio set to 4x3, since
>> that particular field describes the coded video (i.e. *not* how it’s supposed
>> to be rendered).
> 
> And a resolution of 1024x576 does not exist for decklink?
> 
> What about 1920x1088?
> 

The Blackmagic cards have a fairly constrained set of modes which are supported 
(see the definition of BMDDisplayMode in the Decklink SDK documentation).  
Neither of the modes you mentioned are available for output, although I’m not 
sure what st->codecpar->width would be set to if swscale is used between the 
decoder and the output.

Bear in mind, I’m not particularly happy with how that block of code is done 
either (which is why I marked it with a FIXME), but it’s probably good enough 
for 95% of use cases.

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


Re: [FFmpeg-devel] [PATCH, V2] avformat/concat: Fix wrong wrapped timestamp

2017-12-29 Thread Carl Eugen Hoyos
2017-12-29 18:38 GMT+01:00 Nicolas George :

> I am sorry, I do not understand what you are saying at all.
>
> Maybe it would help if you were to give a fully detailed of the simplest
> use case you are trying to fix

Maybe ticket #6908?

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/8] decklink: Introduce support for capture of multiple audio streams

2017-12-29 Thread Carl Eugen Hoyos
2017-12-29 22:14 GMT+01:00 Devin Heitmueller :
> Hi Carl,
>
>> On Dec 29, 2017, at 3:55 PM, Carl Eugen Hoyos  wrote:
>>
>> 2017-12-29 19:12 GMT+01:00 Devin Heitmueller :
>>
>>> +for (int i = 0; i < ctx->max_audio_channels / 2; i++) {
>>> +st = avformat_new_stream(avctx, NULL);
>>> +if (!st) {
>>> +av_log(avctx, AV_LOG_ERROR, "Cannot add stream %d\n", i);
>>> +ret = AVERROR(ENOMEM);
>>> +goto error;
>>> +}
>>> +st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
>>> +st->codecpar->codec_id= ctx->audio_depth == 32 ?
>>> AV_CODEC_ID_PCM_S32LE : AV_CODEC_ID_PCM_S16LE;
>>> +st->codecpar->sample_rate = bmdAudioSampleRate48kHz;
>>> +st->codecpar->channels= 2;
>>> +avpriv_set_pts_info(st, 64, 1, 100);  /* 64 bits pts in us 
>>> */
>>> +ctx->audio_st[i] = st;
>>> +ctx->num_audio_streams++;
>>> +}
>>
>> I would have expected that the channel_layout is set to STEREO in
>> this case, is that not always true?
>
> I’m not sure I understand your comment.  Is there some channel layout
> property of the codec parameters I should be setting?

Yes, AVCodecParameters->channel_layout.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] h264: fix RTSP stream decoding

2017-12-29 Thread Carl Eugen Hoyos
2017-12-29 18:43 GMT+01:00 ser...@gavrushkin.com :

> From e90ef7b56d4147ff6555468f0154321b55596846 Mon Sep 17 00:00:00 2001
> From: Sergey Gavrushkin 
> Date: Fri, 29 Dec 2017 20:03:50 +0300
> Subject: [PATCH] h264: fix RTSP stream decoding
>
> It is a regression fix for an issue that was introduced in commit
> 98c97994c5b90bdae02accb155eeceeb5224b8ef. Variable err_recognition is
> ignored while extradata is decoded and the whole decoding process is
> failed due to timeout.

Please add "Fixes ticket #6422" to the commit message.

And maybe remove "rtsp" from the commit title, the issue
is reproducible with files.

Thank you, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/8] decklink: Introduce support for capture of multiple audio streams

2017-12-29 Thread Devin Heitmueller
Hi Carl,

> On Dec 29, 2017, at 3:55 PM, Carl Eugen Hoyos  wrote:
> 
> 2017-12-29 19:12 GMT+01:00 Devin Heitmueller :
> 
>> +for (int i = 0; i < ctx->max_audio_channels / 2; i++) {
>> +st = avformat_new_stream(avctx, NULL);
>> +if (!st) {
>> +av_log(avctx, AV_LOG_ERROR, "Cannot add stream %d\n", i);
>> +ret = AVERROR(ENOMEM);
>> +goto error;
>> +}
>> +st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
>> +st->codecpar->codec_id= ctx->audio_depth == 32 ?
>> AV_CODEC_ID_PCM_S32LE : AV_CODEC_ID_PCM_S16LE;
>> +st->codecpar->sample_rate = bmdAudioSampleRate48kHz;
>> +st->codecpar->channels= 2;
>> +avpriv_set_pts_info(st, 64, 1, 100);  /* 64 bits pts in us 
>> */
>> +ctx->audio_st[i] = st;
>> +ctx->num_audio_streams++;
>> +}
> 
> I would have expected that the channel_layout is set to STEREO in
> this case, is that not always true?

I’m not sure I understand your comment.  Is there some channel layout property 
of the codec parameters I should be setting?

For the moment, it’s true that we’re only supporting capturing stereo pairs.  
But coming down the pipe is support for compressed audio over SDI pairs, as 
well as more complex layouts which involve discrete 5.1 or 7.1 channels.  This 
patch is a stepping stone to that (I’ve designed it with those use cases in 
mind, even though I haven’t implemented them yet).

For example, it’s not uncommon to have a series of SDI pairs such as the 
following:

SDI channels 1-6 contain discrete 5.1 audio as PCM
SDI channels 7-8 contain a stereo PCM pair with a second language
SDI channels 9-10 contain a compressed 5.1 AC-3 stream.

This patch doesn’t let you do the above, but it’s working in that direction.

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


Re: [FFmpeg-devel] [PATCH 2/8] decklink: Add support for output of Active Format Description (AFD)

2017-12-29 Thread Carl Eugen Hoyos
2017-12-29 22:02 GMT+01:00 Devin Heitmueller :
>
>> On Dec 29, 2017, at 3:48 PM, Carl Eugen Hoyos  wrote:
>>
>> 2017-12-29 19:12 GMT+01:00 Devin Heitmueller :
>>
>>> +/* FIXME: Should really rely on the coded_width but seems like that
>>> +   is not accessible to libavdevice outputs */
>>> +if ((st->codecpar->width == 1280 && st->codecpar->height == 720) ||
>>> +(st->codecpar->width == 1920 && st->codecpar->height == 1080))
>>> +pkt->aspectRatio = ASPECT_16x9;
>>> +else
>>> +pkt->aspectRatio = ASPECT_4x3;
>>
>> I most likely won't use this (and I have never seen a decklink card)
>> so please feel free to ignore:
>> Similar code has caused some trouble with mxf files, is there
>> really no saner solution? Like comparing what the actual aspect
>> ratio is more similar to? Is SAR really always 1 for decklink?
>> ("All the world's a VAX.")
>
> So this is definitely a confusing block of code, and you aren’t the first one 
> to
> ask about it (there were questions in the last round of review as well). The
> aspect ratio referred to here is actually of the original coded video - not 
> how
> it’s supposed to be displayed.  Hence, for example, 720x480 in widescreen
> with a non-square PAR would still have the aspect ratio set to 4x3, since
> that particular field describes the coded video (i.e. *not* how it’s supposed
> to be rendered).

And a resolution of 1024x576 does not exist for decklink?

What about 1920x1088?

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 8/8] decklink: Add support for compressed AC-3 output over SDI

2017-12-29 Thread Devin Heitmueller

> On Dec 29, 2017, at 3:59 PM, Carl Eugen Hoyos  wrote:
> 
> 2017-12-29 19:12 GMT+01:00 Devin Heitmueller :
> 
>> +uint8_t *outbuf = NULL;
> 
>> +if (st->codecpar->codec_id == AV_CODEC_ID_AC3)
>> +av_free(outbuf);
> 
> The "if()" should not be necessary, free() and av_free()
> may be called with argument "NULL”.

We don’t want to call av_free() if outbuf points to the original pkt->data 
field (i.e. if we’re receiving PCM audio).  We only want to free the memory if 
we allocated new memory to hold the S337 packet.

The concern isn’t the notion of calling av_free() if outbuf is NULL.  It’s 
about calling av_free() if outbuf points to pkt->data.

In short, I believe the logic here is correct.

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


Re: [FFmpeg-devel] [PATCH 1/8] libavdevice/decklink: Add support for EIA-708 output over SDI

2017-12-29 Thread Carl Eugen Hoyos
2017-12-29 22:00 GMT+01:00 Devin Heitmueller :

> I’m not discounting your concerns - just there isn’t much I can do about
> them but continue to try to improve the quality of the code until it’s
> reliable enough for wider adoption.  :-)

Thank you for the comments!

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/8] decklink: Add support for output of Active Format Description (AFD)

2017-12-29 Thread Devin Heitmueller

> On Dec 29, 2017, at 3:48 PM, Carl Eugen Hoyos  wrote:
> 
> 2017-12-29 19:12 GMT+01:00 Devin Heitmueller :
> 
>> +/* FIXME: Should really rely on the coded_width but seems like that
>> +   is not accessible to libavdevice outputs */
>> +if ((st->codecpar->width == 1280 && st->codecpar->height == 720) ||
>> +(st->codecpar->width == 1920 && st->codecpar->height == 1080))
>> +pkt->aspectRatio = ASPECT_16x9;
>> +else
>> +pkt->aspectRatio = ASPECT_4x3;
> 
> I most likely won't use this (and I have never seen a decklink card)
> so please feel free to ignore:
> Similar code has caused some trouble with mxf files, is there
> really no saner solution? Like comparing what the actual aspect
> ratio is more similar to? Is SAR really always 1 for decklink?
> ("All the world's a VAX.")

So this is definitely a confusing block of code, and you aren’t the first one 
to ask about it (there were questions in the last round of review as well).  
The aspect ratio referred to here is actually of the original coded video - not 
how it’s supposed to be displayed.  Hence, for example, 720x480 in widescreen 
with a non-square PAR would still have the aspect ratio set to 4x3, since that 
particular field describes the coded video (i.e. *not* how it’s supposed to be 
rendered).

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


Re: [FFmpeg-devel] [PATCH 8/8] decklink: Add support for compressed AC-3 output over SDI

2017-12-29 Thread Carl Eugen Hoyos
2017-12-29 19:12 GMT+01:00 Devin Heitmueller :

> +uint8_t *outbuf = NULL;

> +if (st->codecpar->codec_id == AV_CODEC_ID_AC3)
> +av_free(outbuf);

The "if()" should not be necessary, free() and av_free()
may be called with argument "NULL".

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/8] libavdevice/decklink: Add support for EIA-708 output over SDI

2017-12-29 Thread Devin Heitmueller
Hi Carl,

Thanks for your feedback.  Comments inline>

> On Dec 29, 2017, at 3:41 PM, Carl Eugen Hoyos  wrote:
> 
> 2017-12-29 19:12 GMT+01:00 Devin Heitmueller :
> 
>> +side_data = av_frame_get_side_data(pic, AV_FRAME_DATA_A53_CC);
>> +if (side_data && side_data->size) {
>> +uint8_t *buf = av_packet_new_side_data(pkt, AV_PKT_DATA_A53_CC, 
>> side_data->size);
>> +if (buf)
>> +memcpy(buf, side_data->data, side_data->size);
>> +else
>> +return AVERROR(ENOMEM);
> 
> 
> Maybe you disagree but the following is slightly simpler imo:
> 
>  if (!buf)
>return AVERROR();
>  memcpy(buf, data, size);

I don’t feel strongly one way or the other.  If changing it gets it merged, 
then I will resubmit.

> 
> [...]
> 
>> +#if CONFIG_LIBKLVANC
> 
> I tried to voice this before and I assume there is no solution
> but this is a large optional code block depending on an
> external library inside an optional feature depending on
> another - not super-common - external library: This will not
> get much testing, not even for compilation.

It’s a bit of a chicken-and-egg problem.  People who are most likely to use SDI 
are in the broadcast industry, and they typically can’t use ffmpeg in 
production due to all this missing functionality.  My hope is that as we fill 
those holes there will be increased use of the ffmpeg decklink module.

Separating the functionality into a separate library (libklvanc) was 
intentional, as it allows us to use the same VANC processing code across 
multiple open source products (we have versions of VLC and OBE which 
incorporate the library and have been deployed in production for months).  It 
also allows us to share the same code across multiple card manufacturers, 
although there aren’t many to choose from at this point.

I don’t doubt it won’t see much testing at this point given the relatively 
small number of users making use of decklink in ffmpeg.  However that can 
describe a bunch of features in ffmpeg, and I still think there is a lot of 
benefit to getting this stuff upstreamed for those who do want to do SDI 
capture/output.

I’m not discounting your concerns - just there isn’t much I can do about them 
but continue to try to improve the quality of the code until it’s reliable 
enough for wider adoption.  :-)

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


Re: [FFmpeg-devel] [PATCH 3/8] decklink: Introduce support for capture of multiple audio streams

2017-12-29 Thread Carl Eugen Hoyos
2017-12-29 19:12 GMT+01:00 Devin Heitmueller :

> +for (int i = 0; i < ctx->max_audio_channels / 2; i++) {
> +st = avformat_new_stream(avctx, NULL);
> +if (!st) {
> +av_log(avctx, AV_LOG_ERROR, "Cannot add stream %d\n", i);
> +ret = AVERROR(ENOMEM);
> +goto error;
> +}
> +st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
> +st->codecpar->codec_id= ctx->audio_depth == 32 ?
> AV_CODEC_ID_PCM_S32LE : AV_CODEC_ID_PCM_S16LE;
> +st->codecpar->sample_rate = bmdAudioSampleRate48kHz;
> +st->codecpar->channels= 2;
> +avpriv_set_pts_info(st, 64, 1, 100);  /* 64 bits pts in us */
> +ctx->audio_st[i] = st;
> +ctx->num_audio_streams++;
> +}

I would have expected that the channel_layout is set to STEREO in
this case, is that not always true?

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/8] decklink: Add support for output of Active Format Description (AFD)

2017-12-29 Thread Carl Eugen Hoyos
2017-12-29 19:12 GMT+01:00 Devin Heitmueller :

> +/* FIXME: Should really rely on the coded_width but seems like that
> +   is not accessible to libavdevice outputs */
> +if ((st->codecpar->width == 1280 && st->codecpar->height == 720) ||
> +(st->codecpar->width == 1920 && st->codecpar->height == 1080))
> +pkt->aspectRatio = ASPECT_16x9;
> +else
> +pkt->aspectRatio = ASPECT_4x3;

I most likely won't use this (and I have never seen a decklink card)
so please feel free to ignore:
Similar code has caused some trouble with mxf files, is there
really no saner solution? Like comparing what the actual aspect
ratio is more similar to? Is SAR really always 1 for decklink?
("All the world's a VAX.")

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/8] libavdevice/decklink: Add support for EIA-708 output over SDI

2017-12-29 Thread Carl Eugen Hoyos
2017-12-29 19:12 GMT+01:00 Devin Heitmueller :

> +side_data = av_frame_get_side_data(pic, AV_FRAME_DATA_A53_CC);
> +if (side_data && side_data->size) {
> +uint8_t *buf = av_packet_new_side_data(pkt, AV_PKT_DATA_A53_CC, 
> side_data->size);
> +if (buf)
> +memcpy(buf, side_data->data, side_data->size);
> +else
> +return AVERROR(ENOMEM);


Maybe you disagree but the following is slightly simpler imo:

  if (!buf)
return AVERROR();
  memcpy(buf, data, size);

[...]

> +#if CONFIG_LIBKLVANC

I tried to voice this before and I assume there is no solution
but this is a large optional code block depending on an
external library inside an optional feature depending on
another - not super-common - external library: This will not
get much testing, not even for compilation.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavf/mov: Do not blindly allocate stts entries

2017-12-29 Thread Derek Buitenhuis
On 12/29/2017 8:25 PM, Carl Eugen Hoyos wrote:
> 2017-12-29 20:47 GMT+01:00 Derek Buitenhuis :
>> On 12/29/2017 1:10 AM, Carl Eugen Hoyos wrote:
>>> New patch attached, only tested with fate.
>>
>>> +if (INT_MAX / sizeof(*sc->stts_data) <= entries)
> 
> This is an arbitrary limit...

Yeah, true. I should have pointed that out too.

> 
>>>  return AVERROR(ENOMEM);
>>
>> Should probably be something thing AVERROR(EINVAL), I think.
> 
> ... and it is therefore - imo - not correct to return EINVAL.

ENOMEM is arguably even more incorrect, though.

> 
>>> +sc->stts_count = FFMIN(1024 * 1024, entries);
> 
> This is not a limit and therefore not an arbitrary limit.

... what? It is a limit on the size of stts_count. A arbitrary (1mb) one.

In any case, I misunderstood this part, and it is OK. Sorry about that - 
disregard
my complaint.

FFMIN(sc->stts_count * 2, entries) could in theory end up using more memory
for legitimate large files though, due to exponential buffer growth. Is that
something worth caring about?

Other than that, seems OK. Sorry for the noise.

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


Re: [FFmpeg-devel] [PATCH]lavf/mov: Do not blindly allocate stts entries

2017-12-29 Thread Carl Eugen Hoyos
2017-12-29 20:47 GMT+01:00 Derek Buitenhuis :
> On 12/29/2017 1:10 AM, Carl Eugen Hoyos wrote:
>> New patch attached, only tested with fate.
>
>> +if (INT_MAX / sizeof(*sc->stts_data) <= entries)

This is an arbitrary limit...

>>  return AVERROR(ENOMEM);
>
> Should probably be something thing AVERROR(EINVAL), I think.

... and it is therefore - imo - not correct to return EINVAL.

>> +sc->stts_count = FFMIN(1024 * 1024, entries);

This is not a limit and therefore not an arbitrary limit.

> As stated in the past many times, I am not a fan of hardcoding
> arbitrary max hard limits.

There is no hard limit here (but only above), it just doesn't make much
sense to allocate several G for a file that's just a few bytes long.

Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] configure: check SDL2 function with a header

2017-12-29 Thread Derek Buitenhuis
On 12/29/2017 6:36 AM, KO Myung-Hun wrote:
> Sorry about that.
> 
> SDL2 uses SDLCALL to specify a calling convention. On OS/2, it's defined
> to `_System' which is similar to `_cdecl' but does not prepend '_'.
> 
> After all, without a header, a function is used without `_System'. And
> linker will try to `_func' but fail because the function is `func' not
> `_func'.

Thanks for the explanation. Patch LGTM with this added to the commit message.

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


Re: [FFmpeg-devel] [PATCH]lavf/mov: Do not blindly allocate stts entries

2017-12-29 Thread Derek Buitenhuis
On 12/29/2017 1:10 AM, Carl Eugen Hoyos wrote:
> New patch attached, only tested with fate.

> +if (INT_MAX / sizeof(*sc->stts_data) <= entries)
>  return AVERROR(ENOMEM);

Should probably be something thing AVERROR(EINVAL), I think.

> +sc->stts_count = FFMIN(1024 * 1024, entries);

As stated in the past many times, I am not a fan of hardcoding arbitrary
max hard limits. It's the OS's job to handle large allocation issues, not
the library, for what could be perfectly valid files.

However, if we insist on doing it, I believe 1024 * 1024 is too low. Very
long MP4/MOV files are not as uncommon as you think; I have many many 10-20hr
MP4s and even a 55 hour one, and this hardcoded (i.e. unchangeable by the user)
would/could break such files with no way to fix them from the user-side.

> +sc->stts_count = FFMIN(sc->stts_count * 2, entries);

This one seems especially sketchy to me... it can't be that odd of a scenario
to double the count.

In general, I am not a fan of arbitrary limits.

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


Re: [FFmpeg-devel] h264: fix RTSP stream decoding

2017-12-29 Thread Tristan Matthews
Hi,

On Fri, Dec 29, 2017 at 12:43 PM, ser...@gavrushkin.com
 wrote:
> Hello,
>
> FFmpeg stop working with the latest model of camera that I work now. I've 
> investigated it and found that "bad" commit is 
> 98c97994c5b90bdae02accb155eeceeb5224b8ef. There was additional check for ret 
> value and err_recognition, that was ignored while refactoring to h264_parse.c 
> function.
>
> Test RTSP streams are available here:
>
> rtsp://admin:123456@69.42.237.230:1569/mpeg4cif 
> 
> rtsp://admin:123456@69.42.237.230:1568/mpeg4cif

This seems to fix the reported issue here.

Best,
Tristan

>
> P.S. It is my first patch so please write any notes what I should provide for 
> accepting.
>
> Thank you,
> Sergey
>
>
> -
>
>
>
> From e90ef7b56d4147ff6555468f0154321b55596846 Mon Sep 17 00:00:00 2001
> From: Sergey Gavrushkin 
> Date: Fri, 29 Dec 2017 20:03:50 +0300
> Subject: [PATCH] h264: fix RTSP stream decoding
>
> It is a regression fix for an issue that was introduced in commit
> 98c97994c5b90bdae02accb155eeceeb5224b8ef. Variable err_recognition is
> ignored while extradata is decoded and the whole decoding process is
> failed due to timeout.
> ---
>  libavcodec/h264_parse.c | 12 ++--
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
> index fee28d9..009d50c 100644
> --- a/libavcodec/h264_parse.c
> +++ b/libavcodec/h264_parse.c
> @@ -347,7 +347,7 @@ int ff_h264_init_poc(int pic_field_poc[2], int *pic_poc,
>  }
>
>  static int decode_extradata_ps(const uint8_t *data, int size, H264ParamSets 
> *ps,
> -   int is_avc, void *logctx)
> +   int is_avc, int err_recognition, void *logctx)
>  {
>  H2645Packet pkt = { 0 };
>  int i, ret = 0;
> @@ -363,13 +363,13 @@ static int decode_extradata_ps(const uint8_t *data, int 
> size, H264ParamSets *ps,
>  switch (nal->type) {
>  case H264_NAL_SPS:
>  ret = ff_h264_decode_seq_parameter_set(>gb, logctx, ps, 0);
> -if (ret < 0)
> +if (ret < 0 && (err_recognition & AV_EF_EXPLODE))
>  goto fail;
>  break;
>  case H264_NAL_PPS:
>  ret = ff_h264_decode_picture_parameter_set(>gb, logctx, ps,
> nal->size_bits);
> -if (ret < 0)
> +if (ret < 0 && (err_recognition & AV_EF_EXPLODE))
>  goto fail;
>  break;
>  default:
> @@ -393,7 +393,7 @@ static int decode_extradata_ps_mp4(const uint8_t *buf, 
> int buf_size, H264ParamSe
>  {
>  int ret;
>
> -ret = decode_extradata_ps(buf, buf_size, ps, 1, logctx);
> +ret = decode_extradata_ps(buf, buf_size, ps, 1, err_recognition, logctx);
>  if (ret < 0 && !(err_recognition & AV_EF_EXPLODE)) {
>  GetByteContext gbc;
>  PutByteContext pbc;
> @@ -425,7 +425,7 @@ static int decode_extradata_ps_mp4(const uint8_t *buf, 
> int buf_size, H264ParamSe
>  escaped_buf_size = bytestream2_tell_p();
>  AV_WB16(escaped_buf, escaped_buf_size - 2);
>
> -(void)decode_extradata_ps(escaped_buf, escaped_buf_size, ps, 1, 
> logctx);
> +(void)decode_extradata_ps(escaped_buf, escaped_buf_size, ps, 1, 
> err_recognition, logctx);
>  // lorex.mp4 decodes ok even with extradata decoding failing
>  av_freep(_buf);
>  }
> @@ -486,7 +486,7 @@ int ff_h264_decode_extradata(const uint8_t *data, int 
> size, H264ParamSets *ps,
>  *nal_length_size = (data[4] & 0x03) + 1;
>  } else {
>  *is_avc = 0;
> -ret = decode_extradata_ps(data, size, ps, 0, logctx);
> +ret = decode_extradata_ps(data, size, ps, 0, err_recognition, 
> logctx);
>  if (ret < 0)
>  return ret;
>  }
> --
> 2.6.4
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 6/8] Add suppoort for using libklvanc from within decklink capture module

2017-12-29 Thread Devin Heitmueller
Make use of libklvanc from within the decklink capture module,
initially for EIA-708 and AFD.  Support for other VANC types will
come in subsequent patches.

Incorporates feedback from Derek Buitenhuis 
and James Almer 

Signed-off-by: Devin Heitmueller 
---
 libavdevice/decklink_dec.cpp | 133 +++
 1 file changed, 133 insertions(+)

diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 8d4070eecd..86db6d8fbd 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -3,6 +3,7 @@
  * Copyright (c) 2013-2014 Luca Barbato, Deti Fliegl
  * Copyright (c) 2014 Rafaël Carré
  * Copyright (c) 2017 Akamai Technologies, Inc.
+ * Copyright (c) 2017 LTN Global Communications, Inc.
  *
  * This file is part of FFmpeg.
  *
@@ -671,10 +672,123 @@ error:
 return ret;
 }
 
+#if CONFIG_LIBKLVANC
+/* VANC Callbacks */
+struct vanc_cb_ctx {
+AVFormatContext *avctx;
+AVPacket *pkt;
+};
+static int cb_AFD(void *callback_context, struct klvanc_context_s *ctx,
+  struct klvanc_packet_afd_s *pkt)
+{
+struct vanc_cb_ctx *cb_ctx = (struct vanc_cb_ctx *)callback_context;
+uint8_t *afd;
+
+afd = av_packet_new_side_data(cb_ctx->pkt, AV_PKT_DATA_AFD, 1);
+if (afd == NULL) {
+return AVERROR(ENOMEM);
+}
+afd[0] = pkt->hdr.payload[0] >> 3;
+
+return 0;
+}
+
+static int cb_EIA_708B(void *callback_context, struct klvanc_context_s *ctx,
+   struct klvanc_packet_eia_708b_s *pkt)
+{
+struct vanc_cb_ctx *cb_ctx = (struct vanc_cb_ctx *)callback_context;
+decklink_cctx *cctx = (struct decklink_cctx *)cb_ctx->avctx->priv_data;
+struct decklink_ctx *decklink_ctx = (struct decklink_ctx *)cctx->ctx;
+uint16_t expected_cdp;
+uint8_t *cc;
+
+if (!pkt->checksum_valid)
+return 0;
+
+if (!pkt->header.ccdata_present)
+return 0;
+
+expected_cdp = decklink_ctx->cdp_sequence_num + 1;
+decklink_ctx->cdp_sequence_num = pkt->header.cdp_hdr_sequence_cntr;
+if (pkt->header.cdp_hdr_sequence_cntr != expected_cdp) {
+av_log(cb_ctx->avctx, AV_LOG_DEBUG,
+   "CDP counter inconsistent.  Received=0x%04x Expected=%04x\n",
+   pkt->header.cdp_hdr_sequence_cntr, expected_cdp);
+return 0;
+}
+
+cc = av_packet_new_side_data(cb_ctx->pkt, AV_PKT_DATA_A53_CC, 
pkt->ccdata.cc_count * 3);
+if (cc == NULL)
+return AVERROR(ENOMEM);
+
+for (int i = 0; i < pkt->ccdata.cc_count; i++) {
+cc[3*i] = 0xf8 | (pkt->ccdata.cc[i].cc_valid ? 0x04 : 0x00) |
+  (pkt->ccdata.cc[i].cc_type & 0x03);
+cc[3*i+1] = pkt->ccdata.cc[i].cc_data[0];
+cc[3*i+2] = pkt->ccdata.cc[i].cc_data[1];
+}
+
+return 0;
+}
+
+static struct klvanc_callbacks_s callbacks =
+{
+cb_AFD,
+cb_EIA_708B,
+NULL,
+NULL,
+NULL,
+NULL,
+};
+/* End: VANC Callbacks */
+
+/* Take one line of V210 from VANC, colorspace convert and feed it to the
+ * VANC parser. We'll expect our VANC message callbacks to happen on this
+ * same calling thread.
+ */
+static int klvanc_handle_line(AVFormatContext *avctx, struct klvanc_context_s 
*vanc_ctx,
+  unsigned char *buf, unsigned int uiWidth, 
unsigned int lineNr,
+  AVPacket *pkt)
+{
+/* Convert the vanc line from V210 to CrCB422, then vanc parse it */
+
+/* We need two kinds of type pointers into the source vbi buffer */
+/* TODO: What the hell is this, two ptrs? */
+const uint32_t *src = (const uint32_t *)buf;
+
+/* Convert Blackmagic pixel format to nv20.
+ * src pointer gets mangled during conversion, hence we need its own
+ * ptr instead of passing vbiBufferPtr.
+ * decoded_words should be atleast 2 * uiWidth.
+ */
+uint16_t decoded_words[16384];
+
+/* On output each pixel will be decomposed into three 16-bit words (one 
for Y, U, V) */
+memset(_words[0], 0, sizeof(decoded_words));
+uint16_t *p_anc = decoded_words;
+if (klvanc_v210_line_to_nv20_c(src, p_anc, sizeof(decoded_words), (uiWidth 
/ 6) * 6) < 0)
+return AVERROR(EINVAL);
+
+if (vanc_ctx) {
+struct vanc_cb_ctx cb_ctx = {
+.avctx = avctx,
+.pkt = pkt
+};
+vanc_ctx->callback_context = _ctx;
+int ret = klvanc_packet_parse(vanc_ctx, lineNr, decoded_words, 
sizeof(decoded_words) / (sizeof(uint16_t)));
+if (ret < 0) {
+return AVERROR(EINVAL);
+}
+}
+return 0;
+}
+#endif
+
 HRESULT decklink_input_callback::VideoInputFrameArrived(
 IDeckLinkVideoInputFrame *videoFrame, IDeckLinkAudioInputPacket 
*audioFrame)
 {
 decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
+struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
 void *frameBytes;
 void *audioFrameBytes;

[FFmpeg-devel] [PATCH 8/8] decklink: Add support for compressed AC-3 output over SDI

2017-12-29 Thread Devin Heitmueller
Extend the decklink output to include support for compressed AC-3,
encapsulated using the SMPTE ST 377:2015 standard.

This functionality can be exercised by using the "copy" codec when
the input audio stream is AC-3.  For example:

./ffmpeg -i ~/foo.ts -codec:a copy -f decklink 'UltraStudio Mini Monitor'

Note that the default behavior continues to be to do PCM output,
which means without specifying the copy codec a stream containing
AC-3 will be decoded and downmixed to stereo audio before output.

Signed-off-by: Devin Heitmueller 
---
 libavdevice/decklink_enc.cpp | 101 ---
 1 file changed, 86 insertions(+), 15 deletions(-)

diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp
index 59a4181e19..aca3c13861 100644
--- a/libavdevice/decklink_enc.cpp
+++ b/libavdevice/decklink_enc.cpp
@@ -224,19 +224,32 @@ static int decklink_setup_audio(AVFormatContext *avctx, 
AVStream *st)
 av_log(avctx, AV_LOG_ERROR, "Only one audio stream is supported!\n");
 return -1;
 }
-if (c->sample_rate != 48000) {
-av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate!"
-   " Only 48kHz is supported.\n");
-return -1;
-}
-if (c->channels != 2 && c->channels != 8 && c->channels != 16) {
-av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels!"
-   " Only 2, 8 or 16 channels are supported.\n");
+
+if (st->codecpar->codec_id == AV_CODEC_ID_AC3) {
+/* Regardless of the number of channels in the codec, we're only
+   using 2 SDI audio channels at 48000Hz */
+ctx->channels = 2;
+} else if (st->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE) {
+if (c->channels != 2 && c->channels != 8 && c->channels != 16) {
+av_log(avctx, AV_LOG_ERROR, "Unsupported number of channels!"
+   " Only 2, 8 or 16 channels are supported.\n");
+return -1;
+}
+if (c->sample_rate != bmdAudioSampleRate48kHz) {
+av_log(avctx, AV_LOG_ERROR, "Unsupported sample rate!"
+   " Only 48kHz is supported.\n");
+return -1;
+}
+ctx->channels = c->channels;
+} else {
+av_log(avctx, AV_LOG_ERROR, "Unsupported codec specified!"
+   " Only PCM_S16LE and AC-3 are supported.\n");
 return -1;
 }
+
 if (ctx->dlo->EnableAudioOutput(bmdAudioSampleRate48kHz,
 bmdAudioSampleType16bitInteger,
-c->channels,
+ctx->channels,
 bmdAudioOutputStreamTimestamped) != S_OK) {
 av_log(avctx, AV_LOG_ERROR, "Could not enable audio output!\n");
 return -1;
@@ -247,8 +260,7 @@ static int decklink_setup_audio(AVFormatContext *avctx, 
AVStream *st)
 }
 
 /* The device expects the sample rate to be fixed. */
-avpriv_set_pts_info(st, 64, 1, c->sample_rate);
-ctx->channels = c->channels;
+avpriv_set_pts_info(st, 64, 1, bmdAudioSampleRate48kHz);
 
 ctx->audio = 1;
 
@@ -536,25 +548,84 @@ static int decklink_write_video_packet(AVFormatContext 
*avctx, AVPacket *pkt)
 return 0;
 }
 
+static int create_s337_payload(AVPacket *pkt, enum AVCodecID codec_id, uint8_t 
**outbuf, int *outsize)
+{
+uint8_t *s337_payload;
+uint8_t *s337_payload_start;
+int i;
+
+/* Encapsulate AC3 syncframe into SMPTE 337 packet */
+*outsize = (pkt->size + 4) * sizeof(uint16_t);
+s337_payload = (uint8_t *) av_mallocz(*outsize);
+if (s337_payload == NULL)
+return AVERROR(ENOMEM);
+
+*outbuf = s337_payload;
+
+/* Construct SMPTE S337 Burst preamble */
+s337_payload[0] = 0x72; /* Sync Word 1 */
+s337_payload[1] = 0xf8; /* Sync Word 1 */
+s337_payload[2] = 0x1f; /* Sync Word 1 */
+s337_payload[3] = 0x4e; /* Sync Word 1 */
+
+if (codec_id == AV_CODEC_ID_AC3) {
+s337_payload[4] = 0x01;
+} else {
+return AVERROR(EINVAL);
+}
+
+s337_payload[5] = 0x00;
+uint16_t bitcount = pkt->size * 8;
+s337_payload[6] = bitcount & 0xff; /* Length code */
+s337_payload[7] = bitcount >> 8; /* Length code */
+s337_payload_start = _payload[8];
+for (i = 0; i < pkt->size; i += 2) {
+s337_payload_start[0] = pkt->data[i+1];
+s337_payload_start[1] = pkt->data[i];
+s337_payload_start += 2;
+}
+
+return 0;
+}
+
 static int decklink_write_audio_packet(AVFormatContext *avctx, AVPacket *pkt)
 {
 struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
 struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
-int sample_count = pkt->size / (ctx->channels << 1);
+AVStream *st = avctx->streams[pkt->stream_index];
+int sample_count;
 buffercount_type buffered;
+uint8_t *outbuf = NULL;
+int ret = 0;
 
 

[FFmpeg-devel] [PATCH 5/8] Support encoding of Active Format Description (AFD) in libx264

2017-12-29 Thread Devin Heitmueller
If AFD side data is present, include it in an H.264 SEI payload when
encoding with libx264.

This is done in the same manner that we currently handle A53 closed
captions (where the business logic for constructing the SEI is in
libavcodec/utils.c), so it should be portable to the other encoder
types (i.e. videotoolbox, etc).

Updated to reflect feedback from Derek Buitenhuis 

Signed-off-by: Devin Heitmueller 
---
 libavcodec/internal.h |  3 +++
 libavcodec/libx264.c  | 47 +++
 libavcodec/utils.c| 36 
 3 files changed, 82 insertions(+), 4 deletions(-)

diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index 6deaf1d204..4db33eb020 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -408,6 +408,9 @@ int ff_side_data_set_encoder_stats(AVPacket *pkt, int 
quality, int64_t *error, i
 int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len,
  void **data, size_t *sei_size);
 
+int ff_alloc_afd_sei(const AVFrame *frame, size_t prefix_len,
+ void **data, size_t *sei_size);
+
 /**
  * Get an estimated video bitrate based on frame size, frame rate and coded
  * bits per pixel.
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 9c67c91f33..9a9667079e 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -86,6 +86,7 @@ typedef struct X264Context {
 int forced_idr;
 int coder;
 int a53_cc;
+int afd;
 int b_frame_strategy;
 int chroma_offset;
 int scenechange_threshold;
@@ -275,6 +276,7 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, 
const AVFrame *frame,
 x264_nal_t *nal;
 int nnal, i, ret;
 x264_picture_t pic_out = {0};
+int num_payloads = 0;
 int pict_type;
 
 x264_picture_init( >pic );
@@ -323,10 +325,46 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, 
const AVFrame *frame,
 } else {
 x4->pic.extra_sei.sei_free = av_free;
 
-x4->pic.extra_sei.payloads[0].payload_size = sei_size;
-x4->pic.extra_sei.payloads[0].payload = sei_data;
-x4->pic.extra_sei.num_payloads = 1;
-x4->pic.extra_sei.payloads[0].payload_type = 4;
+x4->pic.extra_sei.payloads[num_payloads].payload_size = 
sei_size;
+x4->pic.extra_sei.payloads[num_payloads].payload = 
sei_data;
+x4->pic.extra_sei.payloads[num_payloads].payload_type = 4;
+x4->pic.extra_sei.num_payloads++;
+num_payloads++;
+}
+}
+}
+
+/* Active Format Description */
+if (x4->afd) {
+void *sei_data;
+size_t sei_size;
+
+ret = ff_alloc_afd_sei(frame, 0, _data, _size);
+if (ret < 0) {
+for (i = 0; i < num_payloads; i++)
+av_free(x4->pic.extra_sei.payloads[i].payload);
+av_free(x4->pic.extra_sei.payloads);
+return AVERROR(ENOMEM);
+} else if (sei_data) {
+x264_sei_payload_t *payloads;
+payloads = av_realloc(x4->pic.extra_sei.payloads,
+  sizeof(x4->pic.extra_sei.payloads[0]) * 
(num_payloads + 1));
+if (payloads == NULL) {
+av_log(ctx, AV_LOG_ERROR, "Not enough memory for AFD, 
skipping\n");
+for (i = 0; i < num_payloads; i++)
+av_free(x4->pic.extra_sei.payloads[i].payload);
+av_free(x4->pic.extra_sei.payloads);
+av_free(sei_data);
+return AVERROR(ENOMEM);
+} else {
+x4->pic.extra_sei.payloads = payloads;
+x4->pic.extra_sei.sei_free = av_free;
+
+x4->pic.extra_sei.payloads[num_payloads].payload_size = 
sei_size;
+x4->pic.extra_sei.payloads[num_payloads].payload = 
sei_data;
+x4->pic.extra_sei.payloads[num_payloads].payload_type = 4;
+x4->pic.extra_sei.num_payloads++;
+num_payloads++;
 }
 }
 }
@@ -892,6 +930,7 @@ static const AVOption options[] = {
 {"passlogfile", "Filename for 2 pass stats", OFFSET(stats), 
AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE},
 {"wpredp", "Weighted prediction for P-frames", OFFSET(wpredp), 
AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE},
 {"a53cc",  "Use A53 Closed Captions (if available)",  
OFFSET(a53_cc),AV_OPT_TYPE_BOOL,   {.i64 = 1}, 0, 1, VE},
+{"afd","Use Active Format Description (AFD) (if 
available)",OFFSET(afd),AV_OPT_TYPE_BOOL,   {.i64 = 1}, 0, 1, VE},
 {"x264opts", "x264 options", OFFSET(x264opts), 

[FFmpeg-devel] [PATCH 7/8] decklink: Add support for SCTE-104 to decklink capture

2017-12-29 Thread Devin Heitmueller
Make use of libklvanc to parse SCTE-104 packets and announce them
as a new stream.  Right now we just pass the payload straight
through, but once this is hoooked into libklscte35 we'll be able
to generate SCTE-35 messages in the MPEG TS stream.

Note that this feature needs to be explicitly enabled by the user
through the "-enable_scte_104" option, since we cannot autodetect
the presence of SCTE-104 (because unlike with 708/AFD messages are
not set except when trigger occurs, thus the stream wouldn't get
created during the read_header phase).

Updated to reflect feedback from Derek Buitenhuis 

Signed-off-by: Devin Heitmueller 
---
 libavcodec/avcodec.h|  1 +
 libavcodec/codec_desc.c |  6 
 libavdevice/decklink_common.h   |  6 
 libavdevice/decklink_common_c.h |  1 +
 libavdevice/decklink_dec.cpp| 61 -
 libavdevice/decklink_dec_c.c|  1 +
 libavdevice/version.h   |  2 +-
 7 files changed, 76 insertions(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 4f7b6df09d..2b4a0bd669 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -668,6 +668,7 @@ enum AVCodecID {
 AV_CODEC_ID_TTF = 0x18000,
 
 AV_CODEC_ID_SCTE_35, ///< Contain timestamp estimated through PCR of 
program stream.
+AV_CODEC_ID_SCTE_104,
 AV_CODEC_ID_BINTEXT= 0x18800,
 AV_CODEC_ID_XBIN,
 AV_CODEC_ID_IDF,
diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c
index c3688de1d6..e198985bb4 100644
--- a/libavcodec/codec_desc.c
+++ b/libavcodec/codec_desc.c
@@ -3103,6 +3103,12 @@ static const AVCodecDescriptor codec_descriptors[] = {
 .name  = "scte_35",
 .long_name = NULL_IF_CONFIG_SMALL("SCTE 35 Message Queue"),
 },
+{
+.id= AV_CODEC_ID_SCTE_104,
+.type  = AVMEDIA_TYPE_DATA,
+.name  = "scte_104",
+.long_name = NULL_IF_CONFIG_SMALL("SCTE 104 Digital Program 
Insertion"),
+},
 
 /* deprecated codec ids */
 };
diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h
index 06b241029e..4d2052ea79 100644
--- a/libavdevice/decklink_common.h
+++ b/libavdevice/decklink_common.h
@@ -41,6 +41,10 @@
Actual number for any particular model of card may be lower */
 #define DECKLINK_MAX_AUDIO_CHANNELS 32
 
+/* This isn't actually tied to the Blackmagic hardware - it's an arbitrary
+   number used to size the array of streams */
+#define DECKLINK_MAX_DATA_STREAMS 16
+
 class decklink_output_callback;
 class decklink_input_callback;
 
@@ -92,6 +96,8 @@ struct decklink_ctx {
 unsigned int dropped;
 AVStream *audio_st[DECKLINK_MAX_AUDIO_CHANNELS];
 int num_audio_streams;
+AVStream *data_st[DECKLINK_MAX_DATA_STREAMS];
+int num_data_streams;
 AVStream *video_st;
 AVStream *teletext_st;
 uint16_t cdp_sequence_num;
diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h
index 02011ed53b..cb73ec990b 100644
--- a/libavdevice/decklink_common_c.h
+++ b/libavdevice/decklink_common_c.h
@@ -58,6 +58,7 @@ struct decklink_cctx {
 char *format_code;
 int raw_format;
 int64_t queue_size;
+int enable_scte_104;
 };
 
 #endif /* AVDEVICE_DECKLINK_COMMON_C_H */
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 86db6d8fbd..f3f0d989bf 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -672,6 +672,30 @@ error:
 return ret;
 }
 
+static int setup_data(AVFormatContext *avctx)
+{
+struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
+struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
+AVStream *st;
+
+if (cctx->enable_scte_104) {
+st = avformat_new_stream(avctx, NULL);
+if (!st) {
+av_log(avctx, AV_LOG_ERROR, "Cannot add data stream\n");
+return AVERROR(ENOMEM);
+}
+st->codecpar->codec_type  = AVMEDIA_TYPE_DATA;
+st->time_base.den = ctx->bmd_tb_den;
+st->time_base.num = ctx->bmd_tb_num;
+st->codecpar->codec_id= AV_CODEC_ID_SCTE_104;
+avpriv_set_pts_info(st, 64, 1, 100);  /* 64 bits pts in us */
+ctx->data_st[ctx->num_data_streams] = st;
+ctx->num_data_streams++;
+}
+
+return 0;
+}
+
 #if CONFIG_LIBKLVANC
 /* VANC Callbacks */
 struct vanc_cb_ctx {
@@ -731,12 +755,44 @@ static int cb_EIA_708B(void *callback_context, struct 
klvanc_context_s *ctx,
 return 0;
 }
 
+static int cb_SCTE_104(void *callback_context, struct klvanc_context_s *ctx,
+   struct klvanc_packet_scte_104_s *pkt)
+{
+struct vanc_cb_ctx *cb_ctx = (struct vanc_cb_ctx *)callback_context;
+decklink_cctx *decklink_cctx = (struct decklink_cctx 
*)cb_ctx->avctx->priv_data;
+struct decklink_ctx *decklink_ctx = (struct decklink_ctx 
*)decklink_cctx->ctx;
+AVPacket avpkt;

[FFmpeg-devel] [PATCH 4/8] Preserve AFD side data when going from AVPacket to AVFrame

2017-12-29 Thread Devin Heitmueller
This is needed to ensure that AFD data continues to work when
capturing V210 video with the Decklink libavdevice input.

Signed-off-by: Devin Heitmueller 
---
 libavcodec/decode.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/decode.c b/libavcodec/decode.c
index 3f5b086f7e..f9064369bf 100644
--- a/libavcodec/decode.c
+++ b/libavcodec/decode.c
@@ -1662,6 +1662,7 @@ int ff_init_buffer_info(AVCodecContext *avctx, AVFrame 
*frame)
 { AV_PKT_DATA_MASTERING_DISPLAY_METADATA, 
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA },
 { AV_PKT_DATA_CONTENT_LIGHT_LEVEL,
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL },
 { AV_PKT_DATA_A53_CC, AV_FRAME_DATA_A53_CC },
+{ AV_PKT_DATA_AFD,AV_FRAME_DATA_AFD },
 };
 
 if (pkt) {
-- 
2.13.2

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


[FFmpeg-devel] [PATCH 3/8] decklink: Introduce support for capture of multiple audio streams

2017-12-29 Thread Devin Heitmueller
Add support for the ability to capture all audio pairs available
to the capture hardware.  Each pair is exposed as a different audio
stream, which matches up with the most common use cases for the
broadcast space (i.e. where there is one stereo pair per audio
language).

To support the existing use case where multi-channel audio can be
captured (i.e. 7.1), we introduced a new configuration option, which
defaults to the existing behavior.
---
 libavdevice/decklink_common.cpp |   9 +++
 libavdevice/decklink_common.h   |   8 ++-
 libavdevice/decklink_common_c.h |   6 ++
 libavdevice/decklink_dec.cpp| 134 +++-
 libavdevice/decklink_dec_c.c|   3 +
 5 files changed, 130 insertions(+), 30 deletions(-)

diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index ba091dadea..91a626221d 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -480,5 +480,14 @@ int ff_decklink_init_device(AVFormatContext *avctx, const 
char* name)
 return AVERROR_EXTERNAL;
 }
 
+if (ctx->attr->GetInt(BMDDeckLinkMaximumAudioChannels, 
>max_audio_channels) != S_OK) {
+av_log(avctx, AV_LOG_WARNING, "Could not determine number of audio 
channels\n");
+ctx->max_audio_channels = 0;
+}
+if (ctx->max_audio_channels > DECKLINK_MAX_AUDIO_CHANNELS) {
+av_log(avctx, AV_LOG_WARNING, "Decklink card reported support for more 
channels than ffmpeg supports\n");
+ctx->max_audio_channels = DECKLINK_MAX_AUDIO_CHANNELS;
+}
+
 return 0;
 }
diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h
index 143bbb951a..06b241029e 100644
--- a/libavdevice/decklink_common.h
+++ b/libavdevice/decklink_common.h
@@ -37,6 +37,10 @@
 #define DECKLINK_BOOL bool
 #endif
 
+/* Maximum number of channels possible across variants of Blackmagic cards.
+   Actual number for any particular model of card may be lower */
+#define DECKLINK_MAX_AUDIO_CHANNELS 32
+
 class decklink_output_callback;
 class decklink_input_callback;
 
@@ -71,6 +75,7 @@ struct decklink_ctx {
 int bmd_height;
 int bmd_field_dominance;
 int supports_vanc;
+int64_t max_audio_channels;
 
 /* Capture buffer queue */
 AVPacketQueue queue;
@@ -85,7 +90,8 @@ struct decklink_ctx {
 int64_t last_pts;
 unsigned long frameCount;
 unsigned int dropped;
-AVStream *audio_st;
+AVStream *audio_st[DECKLINK_MAX_AUDIO_CHANNELS];
+int num_audio_streams;
 AVStream *video_st;
 AVStream *teletext_st;
 uint16_t cdp_sequence_num;
diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h
index 368ac259e4..02011ed53b 100644
--- a/libavdevice/decklink_common_c.h
+++ b/libavdevice/decklink_common_c.h
@@ -30,6 +30,11 @@ typedef enum DecklinkPtsSource {
 PTS_SRC_WALLCLOCK = 4,
 } DecklinkPtsSource;
 
+typedef enum DecklinkAudioMode {
+AUDIO_MODE_DISCRETE = 0,
+AUDIO_MODE_PAIRS = 1,
+} DecklinkAudioMode;
+
 struct decklink_cctx {
 const AVClass *cclass;
 
@@ -42,6 +47,7 @@ struct decklink_cctx {
 double preroll;
 int v210;
 int audio_channels;
+int audio_mode;
 int audio_depth;
 int duplex_mode;
 DecklinkPtsSource audio_pts_source;
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 94dae26003..8d4070eecd 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -627,9 +627,54 @@ static int64_t get_pkt_pts(IDeckLinkVideoInputFrame 
*videoFrame,
 return pts;
 }
 
+static int setup_audio(AVFormatContext *avctx)
+{
+struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
+struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
+AVStream *st;
+int ret = 0;
+
+if (cctx->audio_mode == AUDIO_MODE_DISCRETE) {
+st = avformat_new_stream(avctx, NULL);
+if (!st) {
+av_log(avctx, AV_LOG_ERROR, "Cannot add stream\n");
+ret = AVERROR(ENOMEM);
+goto error;
+}
+st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
+st->codecpar->codec_id= ctx->audio_depth == 32 ? 
AV_CODEC_ID_PCM_S32LE : AV_CODEC_ID_PCM_S16LE;
+st->codecpar->sample_rate = bmdAudioSampleRate48kHz;
+st->codecpar->channels= cctx->audio_channels;
+avpriv_set_pts_info(st, 64, 1, 100);  /* 64 bits pts in us */
+ctx->audio_st[0] = st;
+ctx->num_audio_streams++;
+} else {
+for (int i = 0; i < ctx->max_audio_channels / 2; i++) {
+st = avformat_new_stream(avctx, NULL);
+if (!st) {
+av_log(avctx, AV_LOG_ERROR, "Cannot add stream %d\n", i);
+ret = AVERROR(ENOMEM);
+goto error;
+}
+st->codecpar->codec_type  = AVMEDIA_TYPE_AUDIO;
+st->codecpar->codec_id= ctx->audio_depth == 32 ? 
AV_CODEC_ID_PCM_S32LE : AV_CODEC_ID_PCM_S16LE;
+st->codecpar->sample_rate 

[FFmpeg-devel] [PATCH 2/8] decklink: Add support for output of Active Format Description (AFD)

2017-12-29 Thread Devin Heitmueller
Implement support for including AFD in decklink output.  This
includes making sure the AFD data is preserved when going from
an AVFrame to a V210 packet (needed for 10-bit support).

Updated to reflect feedback from Marton Balint 

Signed-off-by: Devin Heitmueller 
---
 libavcodec/avcodec.h |  6 ++
 libavcodec/v210enc.c |  9 +
 libavdevice/decklink_enc.cpp | 45 ++--
 3 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 0972df0bde..4f7b6df09d 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1328,6 +1328,12 @@ enum AVPacketSideDataType {
 AV_PKT_DATA_A53_CC,
 
 /**
+ * Active Format Description data consisting of a single byte as specified
+ * in ETSI TS 101 154 using AVActiveFormatDescription enum.
+ */
+AV_PKT_DATA_AFD,
+
+/**
  * The number of side data types.
  * This is not part of the public API/ABI in the sense that it may
  * change when new side data types are added.
diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index 51804e3bac..26a08a1ec9 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -243,6 +243,15 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 return AVERROR(ENOMEM);
 }
 
+side_data = av_frame_get_side_data(pic, AV_FRAME_DATA_AFD);
+if (side_data && side_data->size) {
+uint8_t *buf = av_packet_new_side_data(pkt, AV_PKT_DATA_AFD, 
side_data->size);
+if (buf)
+memcpy(buf, side_data->data, side_data->size);
+else
+return AVERROR(ENOMEM);
+}
+
 pkt->flags |= AV_PKT_FLAG_KEY;
 *got_packet = 1;
 return 0;
diff --git a/libavdevice/decklink_enc.cpp b/libavdevice/decklink_enc.cpp
index ded47108d6..59a4181e19 100644
--- a/libavdevice/decklink_enc.cpp
+++ b/libavdevice/decklink_enc.cpp
@@ -284,7 +284,8 @@ av_cold int ff_decklink_write_trailer(AVFormatContext 
*avctx)
 
 #if CONFIG_LIBKLVANC
 static int decklink_construct_vanc(AVFormatContext *avctx, struct decklink_ctx 
*ctx,
-   AVPacket *pkt, decklink_frame *frame)
+   AVPacket *pkt, decklink_frame *frame,
+   AVStream *st)
 {
 struct klvanc_line_set_s vanc_lines = { 0 };
 int ret, size;
@@ -342,6 +343,46 @@ static int decklink_construct_vanc(AVFormatContext *avctx, 
struct decklink_ctx *
 }
 }
 
+data = av_packet_get_side_data(pkt, AV_PKT_DATA_AFD, );
+if (data) {
+struct klvanc_packet_afd_s *pkt;
+uint16_t *afd;
+uint16_t len;
+
+ret = klvanc_create_AFD();
+if (ret != 0)
+return AVERROR(ENOMEM);
+
+ret = klvanc_set_AFD_val(pkt, data[0]);
+if (ret != 0) {
+av_log(avctx, AV_LOG_ERROR, "Invalid AFD value specified: %d\n",
+   data[0]);
+klvanc_destroy_AFD(pkt);
+return AVERROR(EINVAL);
+}
+
+/* FIXME: Should really rely on the coded_width but seems like that
+   is not accessible to libavdevice outputs */
+if ((st->codecpar->width == 1280 && st->codecpar->height == 720) ||
+(st->codecpar->width == 1920 && st->codecpar->height == 1080))
+pkt->aspectRatio = ASPECT_16x9;
+else
+pkt->aspectRatio = ASPECT_4x3;
+
+ret = klvanc_convert_AFD_to_words(pkt, , );
+if (ret != 0) {
+av_log(avctx, AV_LOG_ERROR, "Failed converting 708 packet to 
words\n");
+return AVERROR(ENOMEM);
+}
+klvanc_destroy_AFD(pkt);
+
+ret = klvanc_line_insert(ctx->vanc_ctx, _lines, afd, len, 12, 0);
+if (ret != 0) {
+av_log(avctx, AV_LOG_ERROR, "VANC line insertion failed\n");
+return AVERROR(ENOMEM);
+}
+}
+
 IDeckLinkVideoFrameAncillary *vanc;
 int result = ctx->dlo->CreateAncillaryData(bmdFormat10BitYUV, );
 if (result != S_OK) {
@@ -437,7 +478,7 @@ static int decklink_write_video_packet(AVFormatContext 
*avctx, AVPacket *pkt)
 frame = new decklink_frame(ctx, avpacket, st->codecpar->codec_id, 
ctx->bmd_height, ctx->bmd_width);
 
 #if CONFIG_LIBKLVANC
-ret = decklink_construct_vanc(avctx, ctx, pkt, frame);
+ret = decklink_construct_vanc(avctx, ctx, pkt, frame, st);
 if (ret != 0) {
 av_log(avctx, AV_LOG_ERROR, "Failed to construct VANC\n");
 }
-- 
2.13.2

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


[FFmpeg-devel] [PATCH 1/8] libavdevice/decklink: Add support for EIA-708 output over SDI

2017-12-29 Thread Devin Heitmueller
Hook in libklvanc and use it for output of EIA-708 captions over
SDI.  The bulk of this patch is just general support for ancillary
data for the Decklink SDI module - the real work for construction
of the EIA-708 CDP and VANC line construction is done by libklvanc.

Libklvanc can be found at: https://github.com/stoth68000/libklvanc

Updated to reflect feedback from Marton Balint 

Signed-off-by: Devin Heitmueller 
---
 configure   |   4 ++
 libavcodec/v210enc.c|  10 +++
 libavdevice/decklink_common.cpp |  17 +++--
 libavdevice/decklink_common.h   |  10 +++
 libavdevice/decklink_enc.cpp| 154 ++--
 5 files changed, 185 insertions(+), 10 deletions(-)

diff --git a/configure b/configure
index 6748ef8bc9..19fd04bb6f 100755
--- a/configure
+++ b/configure
@@ -238,6 +238,7 @@ External library support:
   --enable-libiec61883 enable iec61883 via libiec61883 [no]
   --enable-libilbc enable iLBC de/encoding via libilbc [no]
   --enable-libjack enable JACK audio sound server [no]
+  --enable-libklvanc   enable Kernel Labs VANC processing [no]
   --enable-libkvazaar  enable HEVC encoding via libkvazaar [no]
   --enable-libmodplug  enable ModPlug via libmodplug [no]
   --enable-libmp3lame  enable MP3 encoding via libmp3lame [no]
@@ -1602,6 +1603,7 @@ EXTERNAL_LIBRARY_LIST="
 libiec61883
 libilbc
 libjack
+libklvanc
 libkvazaar
 libmodplug
 libmp3lame
@@ -3074,6 +3076,7 @@ decklink_deps_any="libdl LoadLibrary"
 decklink_indev_deps="decklink threads"
 decklink_indev_extralibs="-lstdc++"
 decklink_outdev_deps="decklink threads"
+decklink_outdev_suggest="libklvanc"
 decklink_outdev_extralibs="-lstdc++"
 libndi_newtek_indev_deps="libndi_newtek"
 libndi_newtek_indev_extralibs="-lndi"
@@ -5835,6 +5838,7 @@ enabled libgsm&& { for gsm_hdr in "gsm.h" 
"gsm/gsm.h"; do
check_lib libgsm "${gsm_hdr}" gsm_create 
-lgsm && break;
done || die "ERROR: libgsm not found"; }
 enabled libilbc   && require libilbc ilbc.h WebRtcIlbcfix_InitDecode 
-lilbc $pthreads_extralibs
+enabled libklvanc && require libklvanc libklvanc/vanc.h 
klvanc_context_create -lklvanc
 enabled libkvazaar&& require_pkg_config libkvazaar "kvazaar >= 0.8.1" 
kvazaar.h kvz_api_get
 # While it may appear that require is being used as a pkg-config
 # fallback for libmfx, it is actually being used to detect a different
diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c
index a6afbbfc41..51804e3bac 100644
--- a/libavcodec/v210enc.c
+++ b/libavcodec/v210enc.c
@@ -123,6 +123,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 int aligned_width = ((avctx->width + 47) / 48) * 48;
 int stride = aligned_width * 8 / 3;
 int line_padding = stride - ((avctx->width * 8 + 11) / 12) * 4;
+AVFrameSideData *side_data;
 int h, w, ret;
 uint8_t *dst;
 
@@ -233,6 +234,15 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 }
 }
 
+side_data = av_frame_get_side_data(pic, AV_FRAME_DATA_A53_CC);
+if (side_data && side_data->size) {
+uint8_t *buf = av_packet_new_side_data(pkt, AV_PKT_DATA_A53_CC, 
side_data->size);
+if (buf)
+memcpy(buf, side_data->data, side_data->size);
+else
+return AVERROR(ENOMEM);
+}
+
 pkt->flags |= AV_PKT_FLAG_KEY;
 *got_packet = 1;
 return 0;
diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index 6ef2c529f4..ba091dadea 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -254,10 +254,19 @@ int ff_decklink_set_format(AVFormatContext *avctx,
, NULL) != S_OK)
 return -1;
 } else {
-if (ctx->dlo->DoesSupportVideoMode(ctx->bmd_mode, bmdFormat8BitYUV,
-   bmdVideoOutputFlagDefault,
-   , NULL) != S_OK)
-return -1;
+ctx->supports_vanc = 1;
+if (ctx->dlo->DoesSupportVideoMode(ctx->bmd_mode, ctx->raw_format,
+   bmdVideoOutputVANC,
+   , NULL) != S_OK) {
+/* Try again, but without VANC enabled */
+if (ctx->dlo->DoesSupportVideoMode(ctx->bmd_mode, ctx->raw_format,
+   bmdVideoOutputFlagDefault,
+   , NULL) != S_OK) {
+return -1;
+}
+ctx->supports_vanc = 0;
+}
+
 }
 if (support == bmdDisplayModeSupported)
 return 0;
diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h
index 57ee7d1d68..143bbb951a 100644
--- a/libavdevice/decklink_common.h
+++ 

[FFmpeg-devel] [PATCHv3 0/8] Decklink updates

2017-12-29 Thread Devin Heitmueller
This patch series provides a number of enhancements for both capture
and output using the decklink module, including addressing comments from
Marton Balint, Derek Buitenhuis, and James Almer.

Devin Heitmueller (8):
  libavdevice/decklink: Add support for EIA-708 output over SDI
  decklink: Add support for output of Active Format Description (AFD)
  decklink: Introduce support for capture of multiple audio streams
  Preserve AFD side data when going from AVPacket to AVFrame
  Support encoding of Active Format Description (AFD) in libx264
  Add suppoort for using libklvanc from within decklink capture module
  decklink: Add support for SCTE-104 to decklink capture
  decklink: Add support for compressed AC-3 output over SDI

 configure   |   4 +
 libavcodec/avcodec.h|   7 +
 libavcodec/codec_desc.c |   6 +
 libavcodec/decode.c |   1 +
 libavcodec/internal.h   |   3 +
 libavcodec/libx264.c|  47 +-
 libavcodec/utils.c  |  36 +
 libavcodec/v210enc.c|  19 +++
 libavdevice/decklink_common.cpp |  26 +++-
 libavdevice/decklink_common.h   |  24 ++-
 libavdevice/decklink_common_c.h |   7 +
 libavdevice/decklink_dec.cpp| 326 
 libavdevice/decklink_dec_c.c|   4 +
 libavdevice/decklink_enc.cpp| 296 +---
 libavdevice/version.h   |   2 +-
 15 files changed, 748 insertions(+), 60 deletions(-)

-- 
2.13.2

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


[FFmpeg-devel] h264: fix RTSP stream decoding

2017-12-29 Thread ser...@gavrushkin.com
Hello,

FFmpeg stop working with the latest model of camera that I work now. I've 
investigated it and found that "bad" commit is 
98c97994c5b90bdae02accb155eeceeb5224b8ef. There was additional check for ret 
value and err_recognition, that was ignored while refactoring to h264_parse.c 
function.

Test RTSP streams are available here:

rtsp://admin:123456@69.42.237.230:1569/mpeg4cif 

rtsp://admin:123456@69.42.237.230:1568/mpeg4cif

P.S. It is my first patch so please write any notes what I should provide for 
accepting. 

Thank you,
Sergey


-



From e90ef7b56d4147ff6555468f0154321b55596846 Mon Sep 17 00:00:00 2001
From: Sergey Gavrushkin 
Date: Fri, 29 Dec 2017 20:03:50 +0300
Subject: [PATCH] h264: fix RTSP stream decoding

It is a regression fix for an issue that was introduced in commit
98c97994c5b90bdae02accb155eeceeb5224b8ef. Variable err_recognition is
ignored while extradata is decoded and the whole decoding process is
failed due to timeout.
---
 libavcodec/h264_parse.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
index fee28d9..009d50c 100644
--- a/libavcodec/h264_parse.c
+++ b/libavcodec/h264_parse.c
@@ -347,7 +347,7 @@ int ff_h264_init_poc(int pic_field_poc[2], int *pic_poc,
 }
 
 static int decode_extradata_ps(const uint8_t *data, int size, H264ParamSets 
*ps,
-   int is_avc, void *logctx)
+   int is_avc, int err_recognition, void *logctx)
 {
 H2645Packet pkt = { 0 };
 int i, ret = 0;
@@ -363,13 +363,13 @@ static int decode_extradata_ps(const uint8_t *data, int 
size, H264ParamSets *ps,
 switch (nal->type) {
 case H264_NAL_SPS:
 ret = ff_h264_decode_seq_parameter_set(>gb, logctx, ps, 0);
-if (ret < 0)
+if (ret < 0 && (err_recognition & AV_EF_EXPLODE))
 goto fail;
 break;
 case H264_NAL_PPS:
 ret = ff_h264_decode_picture_parameter_set(>gb, logctx, ps,
nal->size_bits);
-if (ret < 0)
+if (ret < 0 && (err_recognition & AV_EF_EXPLODE))
 goto fail;
 break;
 default:
@@ -393,7 +393,7 @@ static int decode_extradata_ps_mp4(const uint8_t *buf, int 
buf_size, H264ParamSe
 {
 int ret;
 
-ret = decode_extradata_ps(buf, buf_size, ps, 1, logctx);
+ret = decode_extradata_ps(buf, buf_size, ps, 1, err_recognition, logctx);
 if (ret < 0 && !(err_recognition & AV_EF_EXPLODE)) {
 GetByteContext gbc;
 PutByteContext pbc;
@@ -425,7 +425,7 @@ static int decode_extradata_ps_mp4(const uint8_t *buf, int 
buf_size, H264ParamSe
 escaped_buf_size = bytestream2_tell_p();
 AV_WB16(escaped_buf, escaped_buf_size - 2);
 
-(void)decode_extradata_ps(escaped_buf, escaped_buf_size, ps, 1, 
logctx);
+(void)decode_extradata_ps(escaped_buf, escaped_buf_size, ps, 1, 
err_recognition, logctx);
 // lorex.mp4 decodes ok even with extradata decoding failing
 av_freep(_buf);
 }
@@ -486,7 +486,7 @@ int ff_h264_decode_extradata(const uint8_t *data, int size, 
H264ParamSets *ps,
 *nal_length_size = (data[4] & 0x03) + 1;
 } else {
 *is_avc = 0;
-ret = decode_extradata_ps(data, size, ps, 0, logctx);
+ret = decode_extradata_ps(data, size, ps, 0, err_recognition, logctx);
 if (ret < 0)
 return ret;
 }
-- 
2.6.4

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


Re: [FFmpeg-devel] [PATCH, V2] avformat/concat: Fix wrong wrapped timestamp

2017-12-29 Thread Nicolas George
Wu Zhiqiang (2017-12-30):
> But how to  decide wrap margin that  concat see?
> Though monotonic timestamp is always ok,
> I do not want that sub-demuxer see unwrapped  timestamp but concat see
> wrapped one .
> Or sub-demuxer disable wrap correction but concat enable it.

I am sorry, I do not understand what you are saying at all.

Maybe it would help if you were to give a fully detailed of the simplest
use case you are trying to fix: the files you are trying to concat, with
their format, their timestamps at the beginning, at the end and at
discontinuities, the positions where the application jumps, the
timestamps that are returned by lavf at both levels.

The reason I am insisting on all this is that I fear the problem lies
elsewhere, another bug in timestamps unwrapping. This patch would bury
it deeper instead of fixing it.

Regards,

-- 
  Nicolas George


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH, V2] avformat/concat: Fix wrong wrapped timestamp

2017-12-29 Thread Wu Zhiqiang
2017年12月30日 上午12:30,"Nicolas George" 写道:

Wu Zhiqiang (2017-12-30):
> Normally pts_wrap_reference is based on the first packet when calling
> ff_read_packet,
> which will call  function update_wrap_reference , in libavformat/utils
line
> 734:
>
> if (ref == AV_NOPTS_VALUE)
> ref = pkt->pts;
> if (st->pts_wrap_reference != AV_NOPTS_VALUE || st->pts_wrap_bits >=
63
> || ref == AV_NOPTS_VALUE || !s->correct_ts_overflow)
> return 0;
> ref &= (1LL << st->pts_wrap_bits)-1;
>
> // reference time stamp should be 60 s before first time stamp
> pts_wrap_reference = ref - av_rescale(60, st->time_base.den,
> st->time_base.num);
>
> Because  concat_read_header  and concat_seek do not call ff_read_packet
and
> open_file does not copy pts_wrap_reference,
> it is constant value during playing.
>
> If  demuxing packets like avformat_open_input => avformat_seek_file =>
> av_read_frame and seek time is larger than 60s,
> the constant reference time will be positive value and not  indicate the
> normal wrap margin.
>
> Then seeking to time before pts_wrap_reference may generate huge
timestamp,
> which  not expected.

Thanks for explaining, but it still does not address my concern. I
probably explained it badly. Let me try to rephrase.

When an application is reading directly from a file, if I understand
correctly, here is what happens:

1. file contains wrapped timestamps;
2. demuxer sets wrapping_bits to enable timestamps correction;
3. demuxer outputs packets with non-monotonic timestamps;
4. lavf sees non-monotonic timestamps;
5. lavf detects wrapping reference;
6. lavf fixes non-monotonic timestamps;
7. lavf returns packets with monotonic timestamps;
8. application sees packets with monotonic timestamps;
9. application has nothing to do at all about wrapping.

Is it right?

The concat demuxer behaves like any application. Therefore, I can
copy-paste and rename:

1. file contains wrapped timestamps;
2. slave demuxer sets wrapping_bits to enable timestamps correction;
3. slave demuxer outputs packets with non-monotonic timestamps;
4. lavf for slave demuxer sees non-monotonic timestamps;
5. lavf for slave demuxer detects wrapping reference;
6. lavf for slave demuxer fixes non-monotonic timestamps;
7. lavf for slave demuxer returns packets with monotonic timestamps;
8. concat sees packets with monotonic timestamps;
9. concat has nothing to do at all about wrapping.

And it should still be right. Note the conclusion: concat has nothing to
do at all about wrapping.

I will try to rephrase yet another way:

Wrapped timestamps should be de-wrapped even before concat sees them,
and thus no de-wrapping should be necessary after concat.

Regards,

--
  Nicolas George

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

But how to  decide wrap margin that  concat see?
Though monotonic timestamp is always ok,
I do not want that sub-demuxer see unwrapped  timestamp but concat see
wrapped one .
Or sub-demuxer disable wrap correction but concat enable it.

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


Re: [FFmpeg-devel] [PATCH, V2] avformat/concat: Fix wrong wrapped timestamp

2017-12-29 Thread Nicolas George
Wu Zhiqiang (2017-12-30):
> Normally pts_wrap_reference is based on the first packet when calling
> ff_read_packet,
> which will call  function update_wrap_reference , in libavformat/utils line
> 734:
> 
> if (ref == AV_NOPTS_VALUE)
> ref = pkt->pts;
> if (st->pts_wrap_reference != AV_NOPTS_VALUE || st->pts_wrap_bits >= 63
> || ref == AV_NOPTS_VALUE || !s->correct_ts_overflow)
> return 0;
> ref &= (1LL << st->pts_wrap_bits)-1;
> 
> // reference time stamp should be 60 s before first time stamp
> pts_wrap_reference = ref - av_rescale(60, st->time_base.den,
> st->time_base.num);
> 
> Because  concat_read_header  and concat_seek do not call ff_read_packet and
> open_file does not copy pts_wrap_reference,
> it is constant value during playing.
> 
> If  demuxing packets like avformat_open_input => avformat_seek_file =>
> av_read_frame and seek time is larger than 60s,
> the constant reference time will be positive value and not  indicate the
> normal wrap margin.
> 
> Then seeking to time before pts_wrap_reference may generate huge timestamp,
> which  not expected.

Thanks for explaining, but it still does not address my concern. I
probably explained it badly. Let me try to rephrase.

When an application is reading directly from a file, if I understand
correctly, here is what happens:

1. file contains wrapped timestamps;
2. demuxer sets wrapping_bits to enable timestamps correction;
3. demuxer outputs packets with non-monotonic timestamps;
4. lavf sees non-monotonic timestamps;
5. lavf detects wrapping reference;
6. lavf fixes non-monotonic timestamps;
7. lavf returns packets with monotonic timestamps;
8. application sees packets with monotonic timestamps;
9. application has nothing to do at all about wrapping.

Is it right?

The concat demuxer behaves like any application. Therefore, I can
copy-paste and rename:

1. file contains wrapped timestamps;
2. slave demuxer sets wrapping_bits to enable timestamps correction;
3. slave demuxer outputs packets with non-monotonic timestamps;
4. lavf for slave demuxer sees non-monotonic timestamps;
5. lavf for slave demuxer detects wrapping reference;
6. lavf for slave demuxer fixes non-monotonic timestamps;
7. lavf for slave demuxer returns packets with monotonic timestamps;
8. concat sees packets with monotonic timestamps;
9. concat has nothing to do at all about wrapping.

And it should still be right. Note the conclusion: concat has nothing to
do at all about wrapping.

I will try to rephrase yet another way:

Wrapped timestamps should be de-wrapped even before concat sees them,
and thus no de-wrapping should be necessary after concat.

Regards,

-- 
  Nicolas George


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [MSVC toolchain] Patch to allow building FFmpeg with Linux bash on Windows (WSL)

2017-12-29 Thread Josh de Kock
On Fri, 29 Dec 2017 12:41:07 +0100
"Cyber Sinh"  wrote:

> Hi Aaron,
> 
> - I were not aware of the Gilles Khouzam patch when I make the patch (I read 
> its useful blog post). But feel free to give credits to anyone you want. 
> Adding ".exe" to the end of Windows executables is not rocket science, as you 
> said.
> [...]

I've been working on a patch to do this and fixup testing FATE with mingw cross 
compilation within WSL. I was planning on submitting it within the next few 
days. 

-- 
Josh de Kock 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH, V2] avformat/concat: Fix wrong wrapped timestamp

2017-12-29 Thread Wu Zhiqiang
On Fri, Dec 29, 2017 at 8:00 PM, Nicolas George  wrote:

> Hi. Sorry for having missed your reply earlier.
>
> 吴志强 (2017-12-18):
> > I see wrap timestamp control is enable by pts_wrap_bits(default 33),
> > but mp4 demuxer  will later set this to 64 (means disabled).
> > Now pts_wrap_bits are always tied to 33 without copy it, which seems
> > strange.
>
> I understand the logic of this patch less and less. Why are you speaking
> about the MP4 demuxer?
>
> If I understand correctly how unwrapping timestamp works, concat should
> never have to do it.
>
> > 2017-12-17 22:55 GMT+08:00 Nicolas George :
>
> Please remember that top-posting on this list is forbidden. If you do
> not know what it means, look it up.
>
> Regards,
>
> --
>   Nicolas George
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
Sorry for top-posting.

Normally pts_wrap_reference is based on the first packet when calling
ff_read_packet,
which will call  function update_wrap_reference , in libavformat/utils line
734:

if (ref == AV_NOPTS_VALUE)
ref = pkt->pts;
if (st->pts_wrap_reference != AV_NOPTS_VALUE || st->pts_wrap_bits >= 63
|| ref == AV_NOPTS_VALUE || !s->correct_ts_overflow)
return 0;
ref &= (1LL << st->pts_wrap_bits)-1;

// reference time stamp should be 60 s before first time stamp
pts_wrap_reference = ref - av_rescale(60, st->time_base.den,
st->time_base.num);

Because  concat_read_header  and concat_seek do not call ff_read_packet and
open_file does not copy pts_wrap_reference,
it is constant value during playing.

If  demuxing packets like avformat_open_input => avformat_seek_file =>
av_read_frame and seek time is larger than 60s,
the constant reference time will be positive value and not  indicate the
normal wrap margin.

Then seeking to time before pts_wrap_reference may generate huge timestamp,
which  not expected.

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


[FFmpeg-devel] [PATCH] mpeg4video: Add support for MPEG-4 Simple Studio Profile.

2017-12-29 Thread Kieran Kunhya
$subj

I'm not to happy about the s->block2 stuff, there are many ways of trying
to resolve this (e.g union), so review welcome.

I will add DPCM support in a later (currently unfinished) patch.

Kieran


0001-mpeg4video-Add-support-for-MPEG-4-Simple-Studio-Prof.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [MSVC toolchain] Patch to allow building FFmpeg with Linux bash on Windows (WSL)

2017-12-29 Thread Cyber Sinh
Sorry for the diff instead of regular git patch. Here is the patch.


-Message d'origine-
De : ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] De la part de wm4
Envoyé : vendredi 29 décembre 2017 12:54
À : ffmpeg-devel@ffmpeg.org
Objet : Re: [FFmpeg-devel] [MSVC toolchain] Patch to allow building FFmpeg with 
Linux bash on Windows (WSL)

On Fri, 29 Dec 2017 10:44:21 +0100
Hendrik Leppkes  wrote:

> On Fri, Dec 29, 2017 at 3:43 AM, Cyber Sinh  wrote:
> > The attached patch changes the configure script for FFmpeg (and 
> > associated shell scripts) to call MSVC tools including their 
> > extensions (cl.exe instead of cl for example). This is necessary, 
> > because WSL can automatically launch Windows processes from the 
> > Linux side but only if the process is in the path and includes the 
> > full name. Linux doesn't automatically append .exe and such to invoke a 
> > file.
> >
> >  
> 
> The attached file is corrupted. Please ensure its in git format-patch 
> format. As it is, I can't even read it at all.

It's in UTF-16, and just a diff. Yeah, nobody can comfortably read it.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


0001-Allow-MSVC-building-under-WSL-Linux-bash-on-Windows-.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/1] avformat/hlsenc: closed caption tags in the master playlist

2017-12-29 Thread Steven Liu
2017-12-29 19:58 GMT+08:00 Dixit, Vishwanath :
>
>
> On 12/29/17 5:11 PM, Steven Liu wrote:
>> 2017-12-29 18:44 GMT+08:00  :
>>> From: Vishwanath Dixit 
>>>
>>> ---
>>>  doc/muxers.texi   |  4 
>>>  libavformat/dashenc.c |  2 +-
>>>  libavformat/hlsenc.c  | 14 +-
>>>  libavformat/hlsplaylist.c |  5 -
>>>  libavformat/hlsplaylist.h |  3 ++-
>>>  5 files changed, 24 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/doc/muxers.texi b/doc/muxers.texi
>>> index 93db549..8229202 100644
>>> --- a/doc/muxers.texi
>>> +++ b/doc/muxers.texi
>>> @@ -872,6 +872,10 @@ publishing it repeatedly every after 30 segments i.e. 
>>> every after 60s.
>>>  @item http_persistent
>>>  Use persistent HTTP connections. Applicable only for HTTP output.
>>>
>>> +@item cc_instream_id
>>> +Add @code{#EXT-X-MEDIA} tag in the master playlist with the specified 
>>> instream ID. It
>>> +accepts the values in the range 1-4.
>>> +
>>>  @end table
>>>
>>>  @anchor{ico}
>>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
>>> index 478a384..8797959 100644
>>> --- a/libavformat/dashenc.c
>>> +++ b/libavformat/dashenc.c
>>> @@ -760,7 +760,7 @@ static int write_manifest(AVFormatContext *s, int final)
>>>  AVStream *st = s->streams[i];
>>>  get_hls_playlist_name(playlist_file, sizeof(playlist_file), 
>>> NULL, i);
>>>  ff_hls_write_stream_info(st, out, st->codecpar->bit_rate,
>>> -playlist_file, NULL);
>>> +playlist_file, NULL, NULL);
>>>  }
>>>  avio_close(out);
>>>  if (use_rename)
>>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>>> index 74f66ce..e5176a8 100644
>>> --- a/libavformat/hlsenc.c
>>> +++ b/libavformat/hlsenc.c
>>> @@ -206,6 +206,7 @@ typedef struct HLSContext {
>>>  int http_persistent;
>>>  AVIOContext *m3u8_out;
>>>  AVIOContext *sub_m3u8_out;
>>> +int cc_instream_id; /* closed captions INSTREAM-ID */
>>>  } HLSContext;
>>>
>>>  static int mkdir_p(const char *path) {
>>> @@ -1122,6 +1123,7 @@ static int create_master_playlist(AVFormatContext *s,
>>>  unsigned int i, j;
>>>  int m3u8_name_size, ret, bandwidth;
>>>  char *m3u8_rel_name;
>>> +char cc_group[16] = {0};
>>>
>>>  input_vs->m3u8_created = 1;
>>>  if (!hls->master_m3u8_created) {
>>> @@ -1148,6 +1150,14 @@ static int create_master_playlist(AVFormatContext *s,
>>>
>>>  ff_hls_write_playlist_version(hls->m3u8_out, hls->version);
>>>
>>> +if (hls->cc_instream_id) {
>>> +av_strlcpy(cc_group, "group_cc", sizeof(cc_group));
>>
>> Why do you write "group_cc" ?  maybe this can make an option be set by
>> user, and set a default string, if it can be set by user, need
>> attention with the printf, about that security.
>>
> Unlike audio rendition streams, in common usage scenarios, there will be only 
> one cc rendition stream and all the video rendition streams refer to the same 
> cc rendition stream. The following example shows a common use case where both 
> video rendition streams (media_0.m3u8 and media_2.m3u8) are referring to the 
> same closed caption rendition with group id “group_cc”.
> #EXTM3U
> #EXT-X-VERSION:3
> 
> #EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS,GROUP-ID="group_cc",NAME="captions",INSTREAM-ID="CC1"
> 
> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_aud1",NAME="audio_0",DEFAULT=YES,URI="media_1.m3u8"
> 
> #EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_aud2",NAME="audio_0",DEFAULT=YES,URI="media_3.m3u8"
> 
> #EXT-X-STREAM-INF:BANDWIDTH=140800,RESOLUTION=1280x720,AUDIO="group_aud1",CLOSED-CAPTIONS="group_cc"
> media_0.m3u8
>
> #EXT-X-STREAM-INF:BANDWIDTH=140800,AUDIO="group_aud1"
> media_1.m3u8
>
> 
> #EXT-X-STREAM-INF:BANDWIDTH=140800,RESOLUTION=1280x720,AUDIO="group_aud2",CLOSED-CAPTIONS="group_cc"
> media_2.m3u8
>
> #EXT-X-STREAM-INF:BANDWIDTH=140800,AUDIO="group_aud2"
> media_3.m3u8
>
> So, currently the group id name is fixed to “group_cc”. However, this 
> functionality can be further extended in the future for different CC groups 
> when there are different closed caption sources are present in the input. 
> Please let me know your further thoughts/suggestions on this.

I think "group_cc" should be a variable, it can be set by the user,
not write to a constant by hlsenc. for example:

  #EXTM3U
   #EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="low",NAME="Main", \
  DEFAULT=YES,URI="low/main/audio-video.m3u8"
   #EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="low",NAME="Centerfield", \
  DEFAULT=NO,URI="low/centerfield/audio-video.m3u8"
   #EXT-X-MEDIA:TYPE=VIDEO,GROUP-ID="low",NAME="Dugout", \
  DEFAULT=NO,URI="low/dugout/audio-video.m3u8"

   #EXT-X-STREAM-INF:BANDWIDTH=128,CODECS="...",VIDEO="low"
   low/main/audio-video.m3u8

   

Re: [FFmpeg-devel] [PATCH, V3] avformat/concat: Fix wrong wrapped timestamp

2017-12-29 Thread 吴志强
I already answered:

http://ffmpeg.org/pipermail/ffmpeg-devel/2017-December/222605.html


I just refine coding style following your advice and re-submit it.

Thanks.

On Fri, Dec 29, 2017 at 7:33 PM, Nicolas George  wrote:

> mymoey...@gmail.com (2017-12-29):
> > From: Wu Zhiqiang 
> >
> > When using concat protocol, start from middle of file will generate
> non-zero wrap reference.
> > If seek to time before the wrap reference, wrap control will generate
> wrong wrapped timestamp.
> > Copy wrap related stream properties when reading header can fix this
> problem.
> >
> > Signed-off-by: Wu Zhiqiang 
>
> You did not answer to this mail:
>
> https://ffmpeg.org/pipermail/ffmpeg-devel/2017-December/222549.html
>
> Regards,
>
> --
>   Nicolas George
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH, V2] avformat/concat: Fix wrong wrapped timestamp

2017-12-29 Thread Nicolas George
Hi. Sorry for having missed your reply earlier.

吴志强 (2017-12-18):
> I see wrap timestamp control is enable by pts_wrap_bits(default 33),
> but mp4 demuxer  will later set this to 64 (means disabled).
> Now pts_wrap_bits are always tied to 33 without copy it, which seems
> strange.

I understand the logic of this patch less and less. Why are you speaking
about the MP4 demuxer?

If I understand correctly how unwrapping timestamp works, concat should
never have to do it.

> 2017-12-17 22:55 GMT+08:00 Nicolas George :

Please remember that top-posting on this list is forbidden. If you do
not know what it means, look it up.

Regards,

-- 
  Nicolas George


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] PR new filter gltransition

2017-12-29 Thread Rostislav Pehlivanov
On 29 December 2017 at 08:24, Paul B Mahol  wrote:

> On 12/29/17, Rostislav Pehlivanov  wrote:
> > On 27 December 2017 at 23:13, Travis Fischer 
> wrote:
> >
> >> Hello,
> >>
> >> This is my first time contributing to ffmpeg, so please go easy on me :)
> >>
> >> I have a git diff here
> >>  which
> add a
> >> new filter to apply a GLSL transition between two video streams.  The
> >> github repo for this patch includes all of the relevant documentation
> and
> >> usage examples.
> >>
> >> (sorry, I'm not sure how to formally define the patch, as I'm used to
> just
> >> submitting PRs on github)
> >>
> >> I created this filter because of my frustration with how difficult and
> >> limited the *transition* possibilities were with current concat filter
> >> chains. Anything aside from basic video cross-fades isn't really
> possible.
> >>
> >> After releasing the filter as a standalone extension and seeing some
> other
> >> devs adopt it, I received a lot of feedback that this functionality
> should
> >> be merged info ffmpeg, so I wanted to get the ball rolling and see what
> >> everyone thinks on this list.
> >>
> >> Thanks!
> >> -- Travis Fischer 
> >> ___
> >> ffmpeg-devel mailing list
> >> ffmpeg-devel@ffmpeg.org
> >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >>
> >
> > I don't see the point of such a filter. Redundant. We already have a
> > properly implemented OpenCL filter support (and there's a patch to make
> it
> > accept generic kernels). This is a quick hack which requires 2 copies and
> > that's slow and inefficient.
> > Instead, how about a tutorial on how to convert glsl to opencl kernels?
>
> Current OpenCL filters are neither generic nor use framesync.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Which is exactly why I mentioned that in my email. There's a patch which
just needs to be applied.
As for framesync support, the opencl infrastructure is done properly and
init is abstracted enough to be simpler than to use opengl and writing a
filter from scratch.
Not to mention having opengl support in any capacity in lavfi could mess up
any clients using opengl.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/1] avformat/hlsenc: closed caption tags in the master playlist

2017-12-29 Thread Dixit, Vishwanath


On 12/29/17 5:11 PM, Steven Liu wrote:
> 2017-12-29 18:44 GMT+08:00  :
>> From: Vishwanath Dixit 
>>
>> ---
>>  doc/muxers.texi   |  4 
>>  libavformat/dashenc.c |  2 +-
>>  libavformat/hlsenc.c  | 14 +-
>>  libavformat/hlsplaylist.c |  5 -
>>  libavformat/hlsplaylist.h |  3 ++-
>>  5 files changed, 24 insertions(+), 4 deletions(-)
>>
>> diff --git a/doc/muxers.texi b/doc/muxers.texi
>> index 93db549..8229202 100644
>> --- a/doc/muxers.texi
>> +++ b/doc/muxers.texi
>> @@ -872,6 +872,10 @@ publishing it repeatedly every after 30 segments i.e. 
>> every after 60s.
>>  @item http_persistent
>>  Use persistent HTTP connections. Applicable only for HTTP output.
>>
>> +@item cc_instream_id
>> +Add @code{#EXT-X-MEDIA} tag in the master playlist with the specified 
>> instream ID. It
>> +accepts the values in the range 1-4.
>> +
>>  @end table
>>
>>  @anchor{ico}
>> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
>> index 478a384..8797959 100644
>> --- a/libavformat/dashenc.c
>> +++ b/libavformat/dashenc.c
>> @@ -760,7 +760,7 @@ static int write_manifest(AVFormatContext *s, int final)
>>  AVStream *st = s->streams[i];
>>  get_hls_playlist_name(playlist_file, sizeof(playlist_file), 
>> NULL, i);
>>  ff_hls_write_stream_info(st, out, st->codecpar->bit_rate,
>> -playlist_file, NULL);
>> +playlist_file, NULL, NULL);
>>  }
>>  avio_close(out);
>>  if (use_rename)
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index 74f66ce..e5176a8 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -206,6 +206,7 @@ typedef struct HLSContext {
>>  int http_persistent;
>>  AVIOContext *m3u8_out;
>>  AVIOContext *sub_m3u8_out;
>> +int cc_instream_id; /* closed captions INSTREAM-ID */
>>  } HLSContext;
>>
>>  static int mkdir_p(const char *path) {
>> @@ -1122,6 +1123,7 @@ static int create_master_playlist(AVFormatContext *s,
>>  unsigned int i, j;
>>  int m3u8_name_size, ret, bandwidth;
>>  char *m3u8_rel_name;
>> +char cc_group[16] = {0};
>>
>>  input_vs->m3u8_created = 1;
>>  if (!hls->master_m3u8_created) {
>> @@ -1148,6 +1150,14 @@ static int create_master_playlist(AVFormatContext *s,
>>
>>  ff_hls_write_playlist_version(hls->m3u8_out, hls->version);
>>
>> +if (hls->cc_instream_id) {
>> +av_strlcpy(cc_group, "group_cc", sizeof(cc_group));
>
> Why do you write "group_cc" ?  maybe this can make an option be set by
> user, and set a default string, if it can be set by user, need
> attention with the printf, about that security.
>
Unlike audio rendition streams, in common usage scenarios, there will be only 
one cc rendition stream and all the video rendition streams refer to the same 
cc rendition stream. The following example shows a common use case where both 
video rendition streams (media_0.m3u8 and media_2.m3u8) are referring to the 
same closed caption rendition with group id “group_cc”. 
#EXTM3U
#EXT-X-VERSION:3

#EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS,GROUP-ID="group_cc",NAME="captions",INSTREAM-ID="CC1"

#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_aud1",NAME="audio_0",DEFAULT=YES,URI="media_1.m3u8"

#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="group_aud2",NAME="audio_0",DEFAULT=YES,URI="media_3.m3u8"

#EXT-X-STREAM-INF:BANDWIDTH=140800,RESOLUTION=1280x720,AUDIO="group_aud1",CLOSED-CAPTIONS="group_cc"
media_0.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=140800,AUDIO="group_aud1"
media_1.m3u8


#EXT-X-STREAM-INF:BANDWIDTH=140800,RESOLUTION=1280x720,AUDIO="group_aud2",CLOSED-CAPTIONS="group_cc"
media_2.m3u8

#EXT-X-STREAM-INF:BANDWIDTH=140800,AUDIO="group_aud2"
media_3.m3u8

So, currently the group id name is fixed to “group_cc”. However, this 
functionality can be further extended in the future for different CC groups 
when there are different closed caption sources are present in the input. 
Please let me know your further thoughts/suggestions on this.


>> +avio_printf(hls->m3u8_out, 
>> "#EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS,GROUP-ID=\"%s\"",
>> +cc_group);
>> +avio_printf(hls->m3u8_out, 
>> ",NAME=\"captions\",INSTREAM-ID=\"CC%d\"\n",
>> +hls->cc_instream_id);
>> +}
>> +
>>  /* For audio only variant streams add #EXT-X-MEDIA tag with attributes*/
>>  for (i = 0; i < hls->nb_varstreams; i++) {
>>  vs = &(hls->var_streams[i]);
>> @@ -1235,7 +1245,8 @@ static int create_master_playlist(AVFormatContext *s,
>>  bandwidth += bandwidth / 10;
>>
>>  ff_hls_write_stream_info(vid_st, hls->m3u8_out, bandwidth, 
>> m3u8_rel_name,
>> -aud_st ? vs->agroup : NULL);
>> + aud_st ? vs->agroup : NULL,
>> +  

Re: [FFmpeg-devel] [MSVC toolchain] Patch to allow building FFmpeg with Linux bash on Windows (WSL)

2017-12-29 Thread wm4
On Fri, 29 Dec 2017 10:44:21 +0100
Hendrik Leppkes  wrote:

> On Fri, Dec 29, 2017 at 3:43 AM, Cyber Sinh  wrote:
> > The attached patch changes the configure script for FFmpeg (and associated
> > shell scripts) to call MSVC tools including their extensions (cl.exe instead
> > of cl for example). This is necessary, because WSL can automatically launch
> > Windows processes from the Linux side but only if the process is in the path
> > and includes the full name. Linux doesn't automatically append .exe and such
> > to invoke a file.
> >
> >  
> 
> The attached file is corrupted. Please ensure its in git format-patch
> format. As it is, I can't even read it at all.

It's in UTF-16, and just a diff. Yeah, nobody can comfortably read it.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [MSVC toolchain] Patch to allow building FFmpeg with Linux bash on Windows (WSL)

2017-12-29 Thread Cyber Sinh
Hi Aaron,

- I were not aware of the Gilles Khouzam patch when I make the patch (I read 
its useful blog post). But feel free to give credits to anyone you want. Adding 
".exe" to the end of Windows executables is not rocket science, as you said.
- My patch is sufficient to build FFmpeg on bash on Windows. At least on my 
machine with the current master. The Gilles patch was used for compiling the 
FFmpegInterop project and was post for one year.
- Performance is not the sole benefit of using bash on Windows. We don't have 
to install/use msys2 which is a pain for Windows user. 

Sylvain Rougeaux

-Message d'origine-
De : ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] De la part de Aaron 
Levinson
Envoyé : vendredi 29 décembre 2017 04:12
À : FFmpeg development discussions and patches 
Objet : Re: [FFmpeg-devel] [MSVC toolchain] Patch to allow building FFmpeg with 
Linux bash on Windows (WSL)

On 12/28/2017 6:43 PM, Cyber Sinh wrote:
> The attached patch changes the configure script for FFmpeg (and 
> associated shell scripts) to call MSVC tools including their 
> extensions (cl.exe instead of cl for example). This is necessary, 
> because WSL can automatically launch Windows processes from the Linux 
> side but only if the process is in the path and includes the full 
> name. Linux doesn't automatically append .exe and such to invoke a file.

I haven't confirmed yet that this works in the msys2 environment on Windows, 
although according to 
https://blogs.msdn.microsoft.com/gillesk/2016/12/02/building-ffmpeg-using-wsl/
, it supposedly shouldn't cause any issues with building under msys2 or WSL.

It appears all of the contents of this patch have been taken from another 
patch, available at 
https://github.com/Microsoft/FFmpegInterop/blob/gillesk/wsl/0001-Updating-scripts-to-run-under-WSL.patch
, although its reasonable that the author of this patch would have come up with 
it on their own since it is so simple.  It would be reasonable to give credit 
to Gilles Khouzam in the patch description, if the author of this patch (Cyber 
Sinh) and Gilles Khouzam are not the same individual.

Also, Gilles's patch does more to get FFmpeg to build properly under WSL, so 
just adding the file extension may not be sufficient to get FFmpeg to build 
under WSL.

On a separate note, building under WSL, as opposed to msys2, seems promising if 
only from a build performance perspective.  According to the blog post, it 
builds at least twice as fast under WSL than it does with msys2.

Aaron Levinson
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH 1/1] avformat/hlsenc: closed caption tags in the master playlist

2017-12-29 Thread Steven Liu
2017-12-29 18:44 GMT+08:00  :
> From: Vishwanath Dixit 
>
> ---
>  doc/muxers.texi   |  4 
>  libavformat/dashenc.c |  2 +-
>  libavformat/hlsenc.c  | 14 +-
>  libavformat/hlsplaylist.c |  5 -
>  libavformat/hlsplaylist.h |  3 ++-
>  5 files changed, 24 insertions(+), 4 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 93db549..8229202 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -872,6 +872,10 @@ publishing it repeatedly every after 30 segments i.e. 
> every after 60s.
>  @item http_persistent
>  Use persistent HTTP connections. Applicable only for HTTP output.
>
> +@item cc_instream_id
> +Add @code{#EXT-X-MEDIA} tag in the master playlist with the specified 
> instream ID. It
> +accepts the values in the range 1-4.
> +
>  @end table
>
>  @anchor{ico}
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 478a384..8797959 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -760,7 +760,7 @@ static int write_manifest(AVFormatContext *s, int final)
>  AVStream *st = s->streams[i];
>  get_hls_playlist_name(playlist_file, sizeof(playlist_file), 
> NULL, i);
>  ff_hls_write_stream_info(st, out, st->codecpar->bit_rate,
> -playlist_file, NULL);
> +playlist_file, NULL, NULL);
>  }
>  avio_close(out);
>  if (use_rename)
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 74f66ce..e5176a8 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -206,6 +206,7 @@ typedef struct HLSContext {
>  int http_persistent;
>  AVIOContext *m3u8_out;
>  AVIOContext *sub_m3u8_out;
> +int cc_instream_id; /* closed captions INSTREAM-ID */
>  } HLSContext;
>
>  static int mkdir_p(const char *path) {
> @@ -1122,6 +1123,7 @@ static int create_master_playlist(AVFormatContext *s,
>  unsigned int i, j;
>  int m3u8_name_size, ret, bandwidth;
>  char *m3u8_rel_name;
> +char cc_group[16] = {0};
>
>  input_vs->m3u8_created = 1;
>  if (!hls->master_m3u8_created) {
> @@ -1148,6 +1150,14 @@ static int create_master_playlist(AVFormatContext *s,
>
>  ff_hls_write_playlist_version(hls->m3u8_out, hls->version);
>
> +if (hls->cc_instream_id) {
> +av_strlcpy(cc_group, "group_cc", sizeof(cc_group));

Why do you write "group_cc" ?  maybe this can make an option be set by
user, and set a default string, if it can be set by user, need
attention with the printf, about that security.

> +avio_printf(hls->m3u8_out, 
> "#EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS,GROUP-ID=\"%s\"",
> +cc_group);
> +avio_printf(hls->m3u8_out, 
> ",NAME=\"captions\",INSTREAM-ID=\"CC%d\"\n",
> +hls->cc_instream_id);
> +}
> +
>  /* For audio only variant streams add #EXT-X-MEDIA tag with attributes*/
>  for (i = 0; i < hls->nb_varstreams; i++) {
>  vs = &(hls->var_streams[i]);
> @@ -1235,7 +1245,8 @@ static int create_master_playlist(AVFormatContext *s,
>  bandwidth += bandwidth / 10;
>
>  ff_hls_write_stream_info(vid_st, hls->m3u8_out, bandwidth, 
> m3u8_rel_name,
> -aud_st ? vs->agroup : NULL);
> + aud_st ? vs->agroup : NULL,
> + vid_st ? cc_group : NULL);
>
>  av_freep(_rel_name);
>  }
> @@ -2444,6 +2455,7 @@ static const AVOption options[] = {
>  {"master_pl_name", "Create HLS master playlist with this name", 
> OFFSET(master_pl_name), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,E},
>  {"master_pl_publish_rate", "Publish master play list every after this 
> many segment intervals", OFFSET(master_publish_rate), AV_OPT_TYPE_INT, {.i64 
> = 0}, 0, UINT_MAX, E},
>  {"http_persistent", "Use persistent HTTP connections", 
> OFFSET(http_persistent), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
> +{"cc_instream_id", "Closed captions INSTREAM-ID", 
> OFFSET(cc_instream_id), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, E},
>  { NULL },
>  };
>
> diff --git a/libavformat/hlsplaylist.c b/libavformat/hlsplaylist.c
> index 42f059a..8619436 100644
> --- a/libavformat/hlsplaylist.c
> +++ b/libavformat/hlsplaylist.c
> @@ -36,7 +36,8 @@ void ff_hls_write_playlist_version(AVIOContext *out, int 
> version) {
>  }
>
>  void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
> -  int bandwidth, char *filename, char *agroup) {
> +  int bandwidth, char *filename, char *agroup,
> +  char *cc_group) {
>  if (!out || !filename)
>  return;
>
> @@ -52,6 +53,8 @@ void ff_hls_write_stream_info(AVStream *st, AVIOContext 
> *out,
>  st->codecpar->height);
>  if (agroup && strlen(agroup) > 0)
>  avio_printf(out, ",AUDIO=\"group_%s\"", agroup);
> +if (cc_group && 

Re: [FFmpeg-devel] [WARNING! RECEIVED FROM EXTERNAL SENDER] [PATCH v2 1/1] avformat/hlsenc: closed caption tags in the master playlist

2017-12-29 Thread Vishwanath Dixit



On 12/29/17 5:02 PM, vdi...@akamai.com wrote:

From: Vishwanath Dixit 

---
  doc/muxers.texi   |  4 
  libavformat/dashenc.c |  2 +-
  libavformat/hlsenc.c  | 14 +-
  libavformat/hlsplaylist.c |  5 -
  libavformat/hlsplaylist.h |  3 ++-
  5 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 8ce964b..01f7fe4 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -874,6 +874,10 @@ publishing it repeatedly every after 30 segments i.e. 
every after 60s.
  @item http_persistent
  Use persistent HTTP connections. Applicable only for HTTP output.
  
+@item cc_instream_id

+Add @code{#EXT-X-MEDIA} tag in the master playlist with the specified instream 
ID. It
+accepts the values in the range 1-4.
+
  @end table
  
  @anchor{ico}

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 3345b89..39d0afe 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -820,7 +820,7 @@ static int write_manifest(AVFormatContext *s, int final)
  stream_bitrate += max_audio_bitrate;
  }
  get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, 
i);
-ff_hls_write_stream_info(st, out, stream_bitrate, playlist_file, 
agroup);
+ff_hls_write_stream_info(st, out, stream_bitrate, playlist_file, 
agroup, NULL);
  }
  avio_close(out);
  if (use_rename)
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index e6f3241..bff3e6e 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -206,6 +206,7 @@ typedef struct HLSContext {
  int http_persistent;
  AVIOContext *m3u8_out;
  AVIOContext *sub_m3u8_out;
+int cc_instream_id; /* closed captions INSTREAM-ID */
  } HLSContext;
  
  static int mkdir_p(const char *path) {

@@ -1116,6 +1117,7 @@ static int create_master_playlist(AVFormatContext *s,
  unsigned int i, j;
  int m3u8_name_size, ret, bandwidth;
  char *m3u8_rel_name;
+char cc_group[16] = {0};
  
  input_vs->m3u8_created = 1;

  if (!hls->master_m3u8_created) {
@@ -1142,6 +1144,14 @@ static int create_master_playlist(AVFormatContext *s,
  
  ff_hls_write_playlist_version(hls->m3u8_out, hls->version);
  
+if (hls->cc_instream_id) {

+av_strlcpy(cc_group, "group_cc", sizeof(cc_group));
+avio_printf(hls->m3u8_out, 
"#EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS,GROUP-ID=\"%s\"",
+cc_group);
+avio_printf(hls->m3u8_out, ",NAME=\"captions\",INSTREAM-ID=\"CC%d\"\n",
+hls->cc_instream_id);
+}
+
  /* For audio only variant streams add #EXT-X-MEDIA tag with attributes*/
  for (i = 0; i < hls->nb_varstreams; i++) {
  vs = &(hls->var_streams[i]);
@@ -1227,7 +1237,8 @@ static int create_master_playlist(AVFormatContext *s,
  bandwidth += bandwidth / 10;
  
  ff_hls_write_stream_info(vid_st, hls->m3u8_out, bandwidth, m3u8_rel_name,

-aud_st ? vs->agroup : NULL);
+ aud_st ? vs->agroup : NULL,
+ vid_st ? cc_group : NULL);
  
  av_freep(_rel_name);

  }
@@ -2436,6 +2447,7 @@ static const AVOption options[] = {
  {"master_pl_name", "Create HLS master playlist with this name", 
OFFSET(master_pl_name), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,E},
  {"master_pl_publish_rate", "Publish master play list every after this many 
segment intervals", OFFSET(master_publish_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, UINT_MAX, E},
  {"http_persistent", "Use persistent HTTP connections", 
OFFSET(http_persistent), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
+{"cc_instream_id", "Closed captions INSTREAM-ID", OFFSET(cc_instream_id), 
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, E},
  { NULL },
  };
  
diff --git a/libavformat/hlsplaylist.c b/libavformat/hlsplaylist.c

index 098dc89..1bfcce9 100644
--- a/libavformat/hlsplaylist.c
+++ b/libavformat/hlsplaylist.c
@@ -46,7 +46,8 @@ void ff_hls_write_audio_rendition(AVIOContext *out, char 
*agroup,
  }
  
  void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,

-  int bandwidth, char *filename, char *agroup) {
+  int bandwidth, char *filename, char *agroup,
+  char *cc_group) {
  if (!out || !filename)
  return;
  
@@ -62,6 +63,8 @@ void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,

  st->codecpar->height);
  if (agroup && strlen(agroup) > 0)
  avio_printf(out, ",AUDIO=\"group_%s\"", agroup);
+if (cc_group && strlen(cc_group) > 0)
+avio_printf(out, ",CLOSED-CAPTIONS=\"%s\"", cc_group);
  avio_printf(out, "\n%s\n\n", filename);
  }
  
diff --git a/libavformat/hlsplaylist.h b/libavformat/hlsplaylist.h

index 9969315..0ff99f1 100644
--- a/libavformat/hlsplaylist.h
+++ b/libavformat/hlsplaylist.h
@@ -40,7 

Re: [FFmpeg-devel] [PATCH, V3] avformat/concat: Fix wrong wrapped timestamp

2017-12-29 Thread Nicolas George
mymoey...@gmail.com (2017-12-29):
> From: Wu Zhiqiang 
> 
> When using concat protocol, start from middle of file will generate non-zero 
> wrap reference.
> If seek to time before the wrap reference, wrap control will generate wrong 
> wrapped timestamp.
> Copy wrap related stream properties when reading header can fix this problem.
> 
> Signed-off-by: Wu Zhiqiang 

You did not answer to this mail:

https://ffmpeg.org/pipermail/ffmpeg-devel/2017-December/222549.html

Regards,

-- 
  Nicolas George


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 1/1] avformat/hlsenc: closed caption tags in the master playlist

2017-12-29 Thread vdixit
From: Vishwanath Dixit 

---
 doc/muxers.texi   |  4 
 libavformat/dashenc.c |  2 +-
 libavformat/hlsenc.c  | 14 +-
 libavformat/hlsplaylist.c |  5 -
 libavformat/hlsplaylist.h |  3 ++-
 5 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 8ce964b..01f7fe4 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -874,6 +874,10 @@ publishing it repeatedly every after 30 segments i.e. 
every after 60s.
 @item http_persistent
 Use persistent HTTP connections. Applicable only for HTTP output.
 
+@item cc_instream_id
+Add @code{#EXT-X-MEDIA} tag in the master playlist with the specified instream 
ID. It
+accepts the values in the range 1-4.
+
 @end table
 
 @anchor{ico}
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 3345b89..39d0afe 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -820,7 +820,7 @@ static int write_manifest(AVFormatContext *s, int final)
 stream_bitrate += max_audio_bitrate;
 }
 get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, 
i);
-ff_hls_write_stream_info(st, out, stream_bitrate, playlist_file, 
agroup);
+ff_hls_write_stream_info(st, out, stream_bitrate, playlist_file, 
agroup, NULL);
 }
 avio_close(out);
 if (use_rename)
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index e6f3241..bff3e6e 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -206,6 +206,7 @@ typedef struct HLSContext {
 int http_persistent;
 AVIOContext *m3u8_out;
 AVIOContext *sub_m3u8_out;
+int cc_instream_id; /* closed captions INSTREAM-ID */
 } HLSContext;
 
 static int mkdir_p(const char *path) {
@@ -1116,6 +1117,7 @@ static int create_master_playlist(AVFormatContext *s,
 unsigned int i, j;
 int m3u8_name_size, ret, bandwidth;
 char *m3u8_rel_name;
+char cc_group[16] = {0};
 
 input_vs->m3u8_created = 1;
 if (!hls->master_m3u8_created) {
@@ -1142,6 +1144,14 @@ static int create_master_playlist(AVFormatContext *s,
 
 ff_hls_write_playlist_version(hls->m3u8_out, hls->version);
 
+if (hls->cc_instream_id) {
+av_strlcpy(cc_group, "group_cc", sizeof(cc_group));
+avio_printf(hls->m3u8_out, 
"#EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS,GROUP-ID=\"%s\"",
+cc_group);
+avio_printf(hls->m3u8_out, ",NAME=\"captions\",INSTREAM-ID=\"CC%d\"\n",
+hls->cc_instream_id);
+}
+
 /* For audio only variant streams add #EXT-X-MEDIA tag with attributes*/
 for (i = 0; i < hls->nb_varstreams; i++) {
 vs = &(hls->var_streams[i]);
@@ -1227,7 +1237,8 @@ static int create_master_playlist(AVFormatContext *s,
 bandwidth += bandwidth / 10;
 
 ff_hls_write_stream_info(vid_st, hls->m3u8_out, bandwidth, 
m3u8_rel_name,
-aud_st ? vs->agroup : NULL);
+ aud_st ? vs->agroup : NULL,
+ vid_st ? cc_group : NULL);
 
 av_freep(_rel_name);
 }
@@ -2436,6 +2447,7 @@ static const AVOption options[] = {
 {"master_pl_name", "Create HLS master playlist with this name", 
OFFSET(master_pl_name), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,E},
 {"master_pl_publish_rate", "Publish master play list every after this many 
segment intervals", OFFSET(master_publish_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 
0, UINT_MAX, E},
 {"http_persistent", "Use persistent HTTP connections", 
OFFSET(http_persistent), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
+{"cc_instream_id", "Closed captions INSTREAM-ID", OFFSET(cc_instream_id), 
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, E},
 { NULL },
 };
 
diff --git a/libavformat/hlsplaylist.c b/libavformat/hlsplaylist.c
index 098dc89..1bfcce9 100644
--- a/libavformat/hlsplaylist.c
+++ b/libavformat/hlsplaylist.c
@@ -46,7 +46,8 @@ void ff_hls_write_audio_rendition(AVIOContext *out, char 
*agroup,
 }
 
 void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
-  int bandwidth, char *filename, char *agroup) {
+  int bandwidth, char *filename, char *agroup,
+  char *cc_group) {
 if (!out || !filename)
 return;
 
@@ -62,6 +63,8 @@ void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
 st->codecpar->height);
 if (agroup && strlen(agroup) > 0)
 avio_printf(out, ",AUDIO=\"group_%s\"", agroup);
+if (cc_group && strlen(cc_group) > 0)
+avio_printf(out, ",CLOSED-CAPTIONS=\"%s\"", cc_group);
 avio_printf(out, "\n%s\n\n", filename);
 }
 
diff --git a/libavformat/hlsplaylist.h b/libavformat/hlsplaylist.h
index 9969315..0ff99f1 100644
--- a/libavformat/hlsplaylist.h
+++ b/libavformat/hlsplaylist.h
@@ -40,7 +40,8 @@ void ff_hls_write_playlist_version(AVIOContext *out, int 
version);
 void 

[FFmpeg-devel] [PATCH, V3] avformat/concat: Fix wrong wrapped timestamp

2017-12-29 Thread mymoeyard
From: Wu Zhiqiang 

When using concat protocol, start from middle of file will generate non-zero 
wrap reference.
If seek to time before the wrap reference, wrap control will generate wrong 
wrapped timestamp.
Copy wrap related stream properties when reading header can fix this problem.

Signed-off-by: Wu Zhiqiang 
---
 libavformat/concatdec.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index 0e189012ad..8ea9c2b02d 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -188,6 +188,12 @@ static int copy_stream_props(AVStream *st, AVStream 
*source_st)
 st->time_base   = source_st->time_base;
 st->sample_aspect_ratio = source_st->sample_aspect_ratio;
 
+/* Fix wrap control problem */
+avpriv_set_pts_info(st, source_st->pts_wrap_bits, source_st->time_base.num,
+source_st->time_base.den);
+st->pts_wrap_behavior   = source_st->pts_wrap_behavior;
+st->pts_wrap_reference  = source_st->pts_wrap_reference;
+
 av_dict_copy(>metadata, source_st->metadata, 0);
 return 0;
 }
-- 
2.15.0

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


[FFmpeg-devel] [PATCH 1/1] fate: add atrac3p conversion test

2017-12-29 Thread misty
From: Misty De Meo 

---
 tests/fate/atrac.mak | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/fate/atrac.mak b/tests/fate/atrac.mak
index acf79a539c..1707373890 100644
--- a/tests/fate/atrac.mak
+++ b/tests/fate/atrac.mak
@@ -31,6 +31,10 @@ FATE_ATRAC3P += fate-atrac3p-2
 fate-atrac3p-2: CMD = pcm -i $(TARGET_SAMPLES)/atrac3p/sonateno14op27-2-cut.aa3
 fate-atrac3p-2: REF = $(SAMPLES)/atrac3p/sonateno14op27-2-cut.pcm
 
+FATE_ATRAC3P += fate-atrac3p-3
+fate-atrac3p-3: CMD = pcm -i $(TARGET_SAMPLES)/atrac3p/bgm01.at3
+fate-atrac3p-3: REF = $(SAMPLES)/atrac3p/bgm01.s16
+
 FATE_ATRAC3P-$(call DEMDEC, OMA, ATRAC3P) += $(FATE_ATRAC3P)
 
 FATE_ATRAC_ALL = $(FATE_ATRAC1-yes) $(FATE_ATRAC3-yes) $(FATE_ATRAC3P-yes)
-- 
2.15.1

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


[FFmpeg-devel] [PATCH 0/1] mpeg: add experimental support for PSMF audio.

2017-12-29 Thread misty
From: Misty De Meo 

Thanks for pointing this out. I hadn't had a separate .at3 file to test
with, and didn't realize that this broke regular ATRAC3P files.
I've added a new fate test which detects this regression; it passes on
master and fails in the MPEG-ATRAC3 branch.
I'll keep working on my branch, but meanwhile I've included the test with
this message - I figured it'd be useful regardless.

The files used in this test can be downloaded here:
https://public.drac.at/bgm01.at3
https://public.drac.at/bgm01.s16

Misty De Meo (1):
  fate: add atrac3p conversion test

 tests/fate/atrac.mak | 4 
 1 file changed, 4 insertions(+)

-- 
2.15.1

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


[FFmpeg-devel] [PATCH 1/1] avformat/hlsenc: closed caption tags in the master playlist

2017-12-29 Thread vdixit
From: Vishwanath Dixit 

---
 doc/muxers.texi   |  4 
 libavformat/dashenc.c |  2 +-
 libavformat/hlsenc.c  | 14 +-
 libavformat/hlsplaylist.c |  5 -
 libavformat/hlsplaylist.h |  3 ++-
 5 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 93db549..8229202 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -872,6 +872,10 @@ publishing it repeatedly every after 30 segments i.e. 
every after 60s.
 @item http_persistent
 Use persistent HTTP connections. Applicable only for HTTP output.
 
+@item cc_instream_id
+Add @code{#EXT-X-MEDIA} tag in the master playlist with the specified instream 
ID. It
+accepts the values in the range 1-4.
+
 @end table
 
 @anchor{ico}
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 478a384..8797959 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -760,7 +760,7 @@ static int write_manifest(AVFormatContext *s, int final)
 AVStream *st = s->streams[i];
 get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, 
i);
 ff_hls_write_stream_info(st, out, st->codecpar->bit_rate,
-playlist_file, NULL);
+playlist_file, NULL, NULL);
 }
 avio_close(out);
 if (use_rename)
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 74f66ce..e5176a8 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -206,6 +206,7 @@ typedef struct HLSContext {
 int http_persistent;
 AVIOContext *m3u8_out;
 AVIOContext *sub_m3u8_out;
+int cc_instream_id; /* closed captions INSTREAM-ID */
 } HLSContext;
 
 static int mkdir_p(const char *path) {
@@ -1122,6 +1123,7 @@ static int create_master_playlist(AVFormatContext *s,
 unsigned int i, j;
 int m3u8_name_size, ret, bandwidth;
 char *m3u8_rel_name;
+char cc_group[16] = {0};
 
 input_vs->m3u8_created = 1;
 if (!hls->master_m3u8_created) {
@@ -1148,6 +1150,14 @@ static int create_master_playlist(AVFormatContext *s,
 
 ff_hls_write_playlist_version(hls->m3u8_out, hls->version);
 
+if (hls->cc_instream_id) {
+av_strlcpy(cc_group, "group_cc", sizeof(cc_group));
+avio_printf(hls->m3u8_out, 
"#EXT-X-MEDIA:TYPE=CLOSED-CAPTIONS,GROUP-ID=\"%s\"",
+cc_group);
+avio_printf(hls->m3u8_out, ",NAME=\"captions\",INSTREAM-ID=\"CC%d\"\n",
+hls->cc_instream_id);
+}
+
 /* For audio only variant streams add #EXT-X-MEDIA tag with attributes*/
 for (i = 0; i < hls->nb_varstreams; i++) {
 vs = &(hls->var_streams[i]);
@@ -1235,7 +1245,8 @@ static int create_master_playlist(AVFormatContext *s,
 bandwidth += bandwidth / 10;
 
 ff_hls_write_stream_info(vid_st, hls->m3u8_out, bandwidth, 
m3u8_rel_name,
-aud_st ? vs->agroup : NULL);
+ aud_st ? vs->agroup : NULL,
+ vid_st ? cc_group : NULL);
 
 av_freep(_rel_name);
 }
@@ -2444,6 +2455,7 @@ static const AVOption options[] = {
 {"master_pl_name", "Create HLS master playlist with this name", 
OFFSET(master_pl_name), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,E},
 {"master_pl_publish_rate", "Publish master play list every after this many 
segment intervals", OFFSET(master_publish_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 
0, UINT_MAX, E},
 {"http_persistent", "Use persistent HTTP connections", 
OFFSET(http_persistent), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
+{"cc_instream_id", "Closed captions INSTREAM-ID", OFFSET(cc_instream_id), 
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, E},
 { NULL },
 };
 
diff --git a/libavformat/hlsplaylist.c b/libavformat/hlsplaylist.c
index 42f059a..8619436 100644
--- a/libavformat/hlsplaylist.c
+++ b/libavformat/hlsplaylist.c
@@ -36,7 +36,8 @@ void ff_hls_write_playlist_version(AVIOContext *out, int 
version) {
 }
 
 void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
-  int bandwidth, char *filename, char *agroup) {
+  int bandwidth, char *filename, char *agroup,
+  char *cc_group) {
 if (!out || !filename)
 return;
 
@@ -52,6 +53,8 @@ void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
 st->codecpar->height);
 if (agroup && strlen(agroup) > 0)
 avio_printf(out, ",AUDIO=\"group_%s\"", agroup);
+if (cc_group && strlen(cc_group) > 0)
+avio_printf(out, ",CLOSED-CAPTIONS=\"%s\"", cc_group);
 avio_printf(out, "\n%s\n\n", filename);
 }
 
diff --git a/libavformat/hlsplaylist.h b/libavformat/hlsplaylist.h
index ac03550..71ccee7 100644
--- a/libavformat/hlsplaylist.h
+++ b/libavformat/hlsplaylist.h
@@ -38,7 +38,8 @@ typedef enum {
 
 void ff_hls_write_playlist_version(AVIOContext *out, int version);
 void ff_hls_write_stream_info(AVStream *st, AVIOContext *out,
-   

Re: [FFmpeg-devel] [PATCH v3 3/3] avformat/hlsenc: creation of variant streams in subdirectories

2017-12-29 Thread Steven Liu
2017-12-26 19:17 GMT+08:00  :
> From: Vishwanath Dixit 
>
> ---
>  doc/muxers.texi  | 33 -
>  libavformat/hlsenc.c | 68 
> +---
>  2 files changed, 92 insertions(+), 9 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 6af970d..2951262 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -587,6 +587,20 @@ This example will produce the playlists segment file 
> sets:
>  @file{file_0_000.ts}, @file{file_0_001.ts}, @file{file_0_002.ts}, etc. and
>  @file{file_1_000.ts}, @file{file_1_001.ts}, @file{file_1_002.ts}, etc.
>
> +The string "%v" may be present in the filename or in the last directory name
> +containing the file. If the string is present in the directory name, then
> +sub-directories are created after expanding the directory name pattern. This
> +enables creation of segments corresponding to different variant streams in
> +subdirectories.
> +@example
> +ffmpeg -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
> +  -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0 
> v:1,a:1" \
> +  -hls_segment_filename 'vs%v/file_%03d.ts' vs%v/out.m3u8
> +@end example
> +This example will produce the playlists segment file sets:
> +@file{vs0/file_000.ts}, @file{vs0/file_001.ts}, @file{vs0/file_002.ts}, etc. 
> and
> +@file{vs1/file_000.ts}, @file{vs1/file_001.ts}, @file{vs1/file_002.ts}, etc.
> +
>  @item use_localtime
>  Use strftime() on @var{filename} to expand the segment filename with 
> localtime.
>  The segment number is also available in this mode, but to use it, you need 
> to specify second_level_segment_index
> @@ -715,6 +729,11 @@ set filename to the fragment files header file, default 
> filename is @file{init.m
>  When @code{var_stream_map} is set with two or more variant streams, the
>  @var{filename} pattern must contain the string "%v", this string specifies
>  the position of variant stream index in the generated init file names.
> +The string "%v" may be present in the filename or in the last directory name
> +containing the file. If the string is present in the directory name, then
> +sub-directories are created after expanding the directory name pattern. This
> +enables creation of init files corresponding to different variant streams in
> +subdirectories.
>
>  @item hls_flags @var{flags}
>  Possible values:
> @@ -831,7 +850,11 @@ Allowed values are 0 to 9 (limited just based on 
> practical usage).
>
>  When there are two or more variant streams, the output filename pattern must
>  contain the string "%v", this string specifies the position of variant stream
> -index in the output media playlist filenames.
> +index in the output media playlist filenames. The string "%v" may be present 
> in
> +the filename or in the last directory name containing the file. If the 
> string is
> +present in the directory name, then sub-directories are created after 
> expanding
> +the directory name pattern. This enables creation of variant streams in
> +subdirectories.
>
>  @example
>  ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
> @@ -854,6 +877,14 @@ be an audio only stream with bitrate 64k and the third 
> variant stream will be a
>  video only stream with bitrate 256k. Here, three media playlist with file 
> names
>  out_0.m3u8, out_1.m3u8 and out_2.m3u8 will be created.
>  @example
> +ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
> +  -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0 
> v:1,a:1" \
> +  http://example.com/live/vs_%v/out.m3u8
> +@end example
> +This example creates the variant streams in subdirectories. Here, the first
> +media playlist is created at @file{http://example.com/live/vs_0/out.m3u8} and
> +the second one at @file{http://example.com/live/vs_1/out.m3u8}.
> +@example
>  ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 1000k -b:v:1 3000k  \
>-map 0:a -map 0:a -map 0:v -map 0:v -f hls \
>-var_stream_map "a:0,agroup:aud_low a:1,agroup:aud_high v:0,agroup:aud_low 
> v:1,agroup:aud_high" \
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 198c9d3..b25bfc9 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1557,7 +1557,8 @@ static int append_postfix(char *name, int name_buf_len, 
> int i)
>
>  static int validate_name(int nb_vs, const char *fn)
>  {
> -const char *filename;
> +const char *filename, *subdir_name;
> +char *fn_dup = NULL;
>  int ret = 0;
>
>  if (!fn) {
> @@ -1565,22 +1566,38 @@ static int validate_name(int nb_vs, const char *fn)
>  goto fail;
>  }
>
> +fn_dup = av_strdup(fn);
> +if (!fn_dup) {
> +ret = AVERROR(ENOMEM);
> +goto fail;
> +}
> +
>  filename = av_basename(fn);
> +subdir_name = av_dirname(fn_dup);
>
> -if (nb_vs > 1 && !av_stristr(filename, "%v")) {
> +if (nb_vs > 1 && !av_stristr(filename, "%v") && 

Re: [FFmpeg-devel] [PATCH v2 1/2] avformat/hlsenc, utils: Moved is_http_proto from hlsenc to utils for re-use

2017-12-29 Thread Steven Liu
2017-12-27 15:25 GMT+08:00 Steven Liu :
> 2017-12-27 6:22 GMT+08:00 Aman Gupta :
>> On Sat, Dec 16, 2017 at 11:03 AM Karthick J  wrote:
>>
>>> From: Karthick Jeyapal 
>>>
>>> ---
>>>  libavformat/hlsenc.c   | 12 +++-
>>>  libavformat/internal.h |  8 
>>>  libavformat/utils.c|  5 +
>>>  3 files changed, 16 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>>> index e3442c3..03d54c7 100644
>>> --- a/libavformat/hlsenc.c
>>> +++ b/libavformat/hlsenc.c
>>> @@ -240,15 +240,10 @@ static int mkdir_p(const char *path) {
>>>  return ret;
>>>  }
>>>
>>> -static int is_http_proto(char *filename) {
>>> -const char *proto = avio_find_protocol_name(filename);
>>> -return proto ? (!av_strcasecmp(proto, "http") ||
>>> !av_strcasecmp(proto, "https")) : 0;
>>> -}
>>> -
>>>  static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, char
>>> *filename,
>>>AVDictionary **options) {
>>>  HLSContext *hls = s->priv_data;
>>> -int http_base_proto = filename ? is_http_proto(filename) : 0;
>>> +int http_base_proto = filename ? ff_is_http_proto(filename) : 0;
>>>  int err = AVERROR_MUXER_NOT_FOUND;
>>>  if (!*pb || !http_base_proto || !hls->http_persistent) {
>>>  err = s->io_open(s, pb, filename, AVIO_FLAG_WRITE, options);
>>> @@ -264,8 +259,7 @@ static int hlsenc_io_open(AVFormatContext *s,
>>> AVIOContext **pb, char *filename,
>>>
>>>  static void hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char
>>> *filename) {
>>>  HLSContext *hls = s->priv_data;
>>> -int http_base_proto = filename ? is_http_proto(filename) : 0;
>>> -
>>> +int http_base_proto = filename ? ff_is_http_proto(filename) : 0;
>>>  if (!http_base_proto || !hls->http_persistent || hls->key_info_file
>>> || hls->encrypt) {
>>>  ff_format_io_close(s, pb);
>>>  } else {
>>> @@ -275,7 +269,7 @@ static void hlsenc_io_close(AVFormatContext *s,
>>> AVIOContext **pb, char *filename
>>>
>>>  static void set_http_options(AVFormatContext *s, AVDictionary **options,
>>> HLSContext *c)
>>>  {
>>> -int http_base_proto = is_http_proto(s->filename);
>>> +int http_base_proto = ff_is_http_proto(s->filename);
>>>
>>>  if (c->method) {
>>>  av_dict_set(options, "method", c->method, 0);
>>> diff --git a/libavformat/internal.h b/libavformat/internal.h
>>> index 36a5721..8f168c9 100644
>>> --- a/libavformat/internal.h
>>> +++ b/libavformat/internal.h
>>> @@ -619,6 +619,14 @@ int ff_format_output_open(AVFormatContext *s, const
>>> char *url, AVDictionary **op
>>>  void ff_format_io_close(AVFormatContext *s, AVIOContext **pb);
>>>
>>>  /**
>>> + * Utility function to check if the file uses http or https protocol
>>> + *
>>> + * @param s AVFormatContext
>>> + * @param filename URL or file name to open for writing
>>> + */
>>> +int ff_is_http_proto(char *filename);
>>
>>
>>
>> +1 from me. This would be useful for some of the changes I'm making to the
>> hls demuxer as well.
>>
>> Any objections?
>>
>> Aman
>>
>>
>>> +
>>> +/**
>>>   * Parse creation_time in AVFormatContext metadata if exists and warn if
>>> the
>>>   * parsing fails.
>>>   *
>>> diff --git a/libavformat/utils.c b/libavformat/utils.c
>>> index 84e4920..f18a7c8 100644
>>> --- a/libavformat/utils.c
>>> +++ b/libavformat/utils.c
>>> @@ -5459,6 +5459,11 @@ void ff_format_io_close(AVFormatContext *s,
>>> AVIOContext **pb)
>>>  *pb = NULL;
>>>  }
>>>
>>> +int ff_is_http_proto(char *filename) {
>>> +const char *proto = avio_find_protocol_name(filename);
>>> +return proto ? (!av_strcasecmp(proto, "http") ||
>>> !av_strcasecmp(proto, "https")) : 0;
>>> +}
>>> +
>>>  int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t
>>> *timestamp, int return_seconds)
>>>  {
>>>  AVDictionaryEntry *entry;
>>> --
>>> 1.9.1
>>>
>
> LGTM
>
>
Patchset pushed


Thanks

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


Re: [FFmpeg-devel] [MSVC toolchain] Patch to allow building FFmpeg with Linux bash on Windows (WSL)

2017-12-29 Thread Hendrik Leppkes
On Fri, Dec 29, 2017 at 3:43 AM, Cyber Sinh  wrote:
> The attached patch changes the configure script for FFmpeg (and associated
> shell scripts) to call MSVC tools including their extensions (cl.exe instead
> of cl for example). This is necessary, because WSL can automatically launch
> Windows processes from the Linux side but only if the process is in the path
> and includes the full name. Linux doesn't automatically append .exe and such
> to invoke a file.
>
>

The attached file is corrupted. Please ensure its in git format-patch
format. As it is, I can't even read it at all.

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


Re: [FFmpeg-devel] PR new filter gltransition

2017-12-29 Thread Paul B Mahol
On 12/29/17, Rostislav Pehlivanov  wrote:
> On 27 December 2017 at 23:13, Travis Fischer  wrote:
>
>> Hello,
>>
>> This is my first time contributing to ffmpeg, so please go easy on me :)
>>
>> I have a git diff here
>>  which add a
>> new filter to apply a GLSL transition between two video streams.  The
>> github repo for this patch includes all of the relevant documentation and
>> usage examples.
>>
>> (sorry, I'm not sure how to formally define the patch, as I'm used to just
>> submitting PRs on github)
>>
>> I created this filter because of my frustration with how difficult and
>> limited the *transition* possibilities were with current concat filter
>> chains. Anything aside from basic video cross-fades isn't really possible.
>>
>> After releasing the filter as a standalone extension and seeing some other
>> devs adopt it, I received a lot of feedback that this functionality should
>> be merged info ffmpeg, so I wanted to get the ball rolling and see what
>> everyone thinks on this list.
>>
>> Thanks!
>> -- Travis Fischer 
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>
> I don't see the point of such a filter. Redundant. We already have a
> properly implemented OpenCL filter support (and there's a patch to make it
> accept generic kernels). This is a quick hack which requires 2 copies and
> that's slow and inefficient.
> Instead, how about a tutorial on how to convert glsl to opencl kernels?

Current OpenCL filters are neither generic nor use framesync.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavc/qsvdec: hw device should be set

2017-12-29 Thread wm4
On Fri, 29 Dec 2017 15:06:09 +0800
Zhong Li  wrote:

> Add the flag "AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX" to indicate
> AVCodecContext.hw_device_ctx should be set before calling
> avcodec_open2() for qsv decoding.
> It is consistent with examples/qsvdec.c.
> 
> It also can make function "hw_device_match_by_codec()" can find qsv
> device successfully.
> 
> Signed-off-by: Zhong Li 
> ---
>  libavcodec/qsvdec.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
> index 55fe59b..ff1dcf1 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -45,7 +45,8 @@ const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {
>  &(const AVCodecHWConfigInternal) {
>  .public = {
>  .pix_fmt = AV_PIX_FMT_QSV,
> -.methods = AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
> +.methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |
> +   AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
> AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
>  .device_type = AV_HWDEVICE_TYPE_QSV,
>  },

I guess that's correct. It also looks like it supports the INTERNAL
method? (Not sure.)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel