Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode: give a debug message if attrs unsupported.

2017-12-18 Thread Jun Zhao


On 2017/12/19 14:29, 刘歧 wrote:
>> On 19 Dec 2017, at 14:25, Jun Zhao  wrote:
>>
>> <0001-lavc-vaapi_encode-give-a-debug-message-if-attrs-unsu.patch>
> I saw you using AV_LOG_DEBUG, What about use AV_LOG_WARNING? Because that 
> message is tell user attrs unsupported.
>
> Thanks

I don't ensure user like the message as "Attribute 35 is not supported"
this style. And I guess Mark just want to become silent in this case in
original code.

>
>
>
> ___
> 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 3/4] avformat/hlsenc: use hlsenc_io_* APIs

2017-12-18 Thread Karthick Jeyapal



On 12/19/17 11:32 AM, 刘歧 wrote:



On 19 Dec 2017, at 12:11, Karthick Jeyapal  wrote:



On 12/19/17 9:29 AM, 刘歧 wrote:

On 19 Dec 2017, at 11:55, Karthick Jeyapal  wrote:



On 12/18/17 2:17 PM, Steven Liu wrote:

Signed-off-by: Steven Liu 
---
  libavformat/hlsenc.c | 23 ---
  1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 0eebcb4462..0cb75ff198 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -440,7 +440,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
  av_dict_set(, "method", "DELETE", 0);
  if ((ret = vs->avf->io_open(vs->avf, , path, AVIO_FLAG_WRITE, 
)) < 0)
  goto fail;
-ff_format_io_close(vs->avf, );
+hlsenc_io_close(vs->avf, , path);

Will not actually close, when http_persistent is 1. I think it is better to 
leave this as ff_format_io_close

  } else if (unlink(path) < 0) {
  av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
   path, strerror(errno));
@@ -463,7 +463,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
  av_free(sub_path);
  goto fail;
  }
-ff_format_io_close(vs->avf, );
+hlsenc_io_close(vs->avf, , sub_path);

Will not actually close, when http_persistent is 1.

  } else if (unlink(sub_path) < 0) {
  av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: 
%s\n",
   sub_path, strerror(errno));
@@ -556,8 +556,10 @@ static int do_encrypt(AVFormatContext *s, VariantStream 
*vs)
  }
ff_data_to_hex(hls->key_string, key, sizeof(key), 0);
-if ((ret = s->io_open(s, , hls->key_file, AVIO_FLAG_WRITE, NULL)) < 
0)
-return ret;
+ret = hlsenc_io_open(s, , hls->key_file, NULL);

We needn't call hlsenc_io_open if we are not planning to use a persistent 
connection for it. In this case pb is uninitialized and hlsenc_io_open will most 
probably cause a crash or undefined behavior. You can get around that issue by 
initializing pb to NULL. But I think that is unnecessary and are better placed 
with s->io_open().

+if (ret < 0) {
+return ret;;

Extra semicolon

+}
  avio_seek(pb, 0, SEEK_CUR);
  avio_write(pb, key, KEYSIZE);
  avio_close(pb);
@@ -588,7 +590,7 @@ static int hls_encryption_start(AVFormatContext *s)
  ff_get_line(pb, hls->iv_string, sizeof(hls->iv_string));
  hls->iv_string[strcspn(hls->iv_string, "\r\n")] = '\0';
  -ff_format_io_close(s, );
+hlsenc_io_close(s, , hls->key_info_file);
if (!*hls->key_uri) {
  av_log(hls, AV_LOG_ERROR, "no key URI specified in key info file\n");
@@ -606,7 +608,7 @@ static int hls_encryption_start(AVFormatContext *s)
  }
ret = avio_read(pb, key, sizeof(key));
-ff_format_io_close(s, );
+hlsenc_io_close(s, , hls->key_file);

Will not actually close, when http_persistent is 1.

  if (ret != sizeof(key)) {
  av_log(hls, AV_LOG_ERROR, "error reading key file %s\n", 
hls->key_file);
  if (ret >= 0 || ret == AVERROR_EOF)
@@ -1812,7 +1814,6 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
  vs->init_range_length = range_length;
  avio_open_dyn_buf(>pb);
  vs->packets_written = 0;
-ff_format_io_close(s, >out);
  hlsenc_io_close(s, >out, vs->base_output_dirname);
  }
  } else {
@@ -1845,7 +1846,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
  if (ret < 0) {
  return ret;
  }
-ff_format_io_close(s, >out);
+hlsenc_io_close(s, >out, vs->avf->filename);
  }
  ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, 
vs->size);
  vs->start_pos = new_start_pos;
@@ -1925,14 +1926,14 @@ static int hls_write_trailer(struct AVFormatContext *s)
  if (ret < 0) {
  return ret;
  }
-ff_format_io_close(s, >out);
+hlsenc_io_close(s, >out, vs->avf->filename);

Will not actually close, when http_persistent is 1. hls_write_trailer should 
always call ff_format_io_close()

  }
av_write_trailer(oc);
  if (oc->pb) {
  vs->size = avio_tell(vs->avf->pb) - vs->start_pos;
  if (hls->segment_type != SEGMENT_TYPE_FMP4)
-ff_format_io_close(s, >pb);
+hlsenc_io_close(s, >pb, oc->filename);

Will not actually close, when http_persistent is 1. hls_write_trailer should 
always call ff_format_io_close()

if ((hls->flags & HLS_TEMP_FILE) && 

[FFmpeg-devel] [PATCH] avformat/hlsenc: Fix a memory leak when http_persistent is 1

2017-12-18 Thread Karthick J
From: Karthick Jeyapal 

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

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index e3442c3..5ee28ea 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1918,6 +1918,8 @@ static int hls_write_trailer(struct AVFormatContext *s)
 av_freep(>baseurl);
 }
 
+ff_format_io_close(s, >m3u8_out);
+ff_format_io_close(s, >sub_m3u8_out);
 av_freep(>key_basename);
 av_freep(>var_streams);
 av_freep(>master_m3u8_url);
-- 
1.9.1

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


Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode: give a debug message if attrs unsupported.

2017-12-18 Thread 刘歧

> On 19 Dec 2017, at 14:25, Jun Zhao  wrote:
> 
> <0001-lavc-vaapi_encode-give-a-debug-message-if-attrs-unsu.patch>

I saw you using AV_LOG_DEBUG, What about use AV_LOG_WARNING? Because that 
message is tell user attrs unsupported.

Thanks



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


[FFmpeg-devel] [PATCH] lavc/vaapi_encode: give a debug message if attrs unsupported.

2017-12-18 Thread Jun Zhao

From 8400fa85b7af47c3cff6abd87fdc392ac7891e35 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Tue, 19 Dec 2017 14:13:58 +0800
Subject: [PATCH] lavc/vaapi_encode: give a debug message if attrs unsupported.

Give a debug message when query attribute get VA_ATTRIB_NOT_SUPPORTED,
it's will help to trace and debug some issue.

Signed-off-by: Jun Zhao 
---
 libavcodec/vaapi_encode.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index 1d3cb4db83..9bc9c89d3b 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1048,6 +1048,8 @@ static av_cold int 
vaapi_encode_config_attributes(AVCodecContext *avctx)
 // Unfortunately we have to treat this as "don't know" and hope
 // for the best, because the Intel MJPEG encoder returns this
 // for all the interesting attributes.
+av_log(avctx, AV_LOG_DEBUG, "Attribute (%d) is not supported.\n",
+   attr[i].type);
 continue;
 }
 switch (attr[i].type) {
-- 
2.14.1

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


Re: [FFmpeg-devel] [PATCH v8 1/3] avformat/hlsenc:addition of #EXT-X-MEDIA tag and AUDIO attribute

2017-12-18 Thread 刘歧
On 19 Dec 2017, at 14:09, vdi...@akamai.com wrote:
> 
> From: Vishwanath Dixit 
> 
> ---
> doc/muxers.texi   | 12 +
> libavformat/dashenc.c |  3 ++-
> libavformat/hlsenc.c  | 64 ---
> libavformat/hlsplaylist.c |  4 ++-
> libavformat/hlsplaylist.h |  2 +-
> 5 files changed, 79 insertions(+), 6 deletions(-)
> 
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 3d0c7bf..93db549 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -834,6 +834,18 @@ be a video only stream with video bitrate 1000k, the 
> second variant stream will
> 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_1.m3u8, out_2.m3u8 and out_3.m3u8 will be created.
> +@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" \
> +  -master_pl_name master.m3u8 \
> +  http://example.com/live/out.m3u8
> +@end example
> +This example creates two audio only and two video only variant streams. In
> +addition to the #EXT-X-STREAM-INF tag for each variant stream in the master
> +playlist, #EXT-X-MEDIA tag is also added for the two audio only variant 
> streams
> +and they are mapped to the two video only variant streams with audio group 
> names
> +'aud_low' and 'aud_high'.
> 
> By default, a single hls variant containing all the encoded streams is 
> created.
> 
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 5687530..f363418 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -759,7 +759,8 @@ static int write_manifest(AVFormatContext *s, int final)
>char playlist_file[64];
>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);
> +ff_hls_write_stream_info(st, out, st->codecpar->bit_rate,
> +playlist_file, NULL);
>}
>avio_close(out);
>if (use_rename)
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index e3442c3..53dc835 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -144,6 +144,7 @@ typedef struct VariantStream {
>AVStream **streams;
>unsigned int nb_streams;
>int m3u8_created; /* status of media play-list creation */
> +char *agroup; /* audio group name */
>char *baseurl;
> } VariantStream;
> 
> @@ -1085,7 +1086,7 @@ static int create_master_playlist(AVFormatContext *s,
>  VariantStream * const input_vs)
> {
>HLSContext *hls = s->priv_data;
> -VariantStream *vs;
> +VariantStream *vs, *temp_vs;
>AVStream *vid_st, *aud_st;
>AVDictionary *options = NULL;
>unsigned int i, j;
> @@ -1117,6 +1118,34 @@ static int create_master_playlist(AVFormatContext *s,
> 
>ff_hls_write_playlist_version(hls->m3u8_out, hls->version);
> 
> +/* 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]);
> +
> +if (vs->has_video || vs->has_subtitle || !vs->agroup)
> +continue;
> +
> +m3u8_name_size = strlen(vs->m3u8_name) + 1;
> +m3u8_rel_name = av_malloc(m3u8_name_size);
> +if (!m3u8_rel_name) {
> +ret = AVERROR(ENOMEM);
> +goto fail;
> +}
> +av_strlcpy(m3u8_rel_name, vs->m3u8_name, m3u8_name_size);
> +ret = get_relative_url(hls->master_m3u8_url, vs->m3u8_name,
> +   m3u8_rel_name, m3u8_name_size);
> +if (ret < 0) {
> +av_log(s, AV_LOG_ERROR, "Unable to find relative URL\n");
> +goto fail;
> +}
> +
> +avio_printf(hls->m3u8_out, 
> "#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"group_%s\"",
> +vs->agroup);
> +avio_printf(hls->m3u8_out, 
> ",NAME=\"audio_0\",DEFAULT=YES,URI=\"%s\"\n",
> +m3u8_rel_name);
> +av_freep(_rel_name);
> +}
> +
>/* For variant streams with video add #EXT-X-STREAM-INF tag with 
> attributes*/
>for (i = 0; i < hls->nb_varstreams; i++) {
>vs = &(hls->var_streams[i]);
> @@ -1149,6 +1178,25 @@ static int create_master_playlist(AVFormatContext *s,
>continue;
>}
> 
> +/**
> + * Traverse through the list of audio only rendition streams and find
> + * the rendition which has highest bitrate in the same audio group
> + */
> +if (vs->agroup) {
> +for (j = 0; j < hls->nb_varstreams; j++) {
> +temp_vs = &(hls->var_streams[j]);
> +if (!temp_vs->has_video && 

[FFmpeg-devel] [PATCH v8 2/3] avcodec/libx264:setting profile and level in avcodec context

2017-12-18 Thread vdixit
From: Vishwanath Dixit 

---
 libavcodec/libx264.c | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index e2455e1..0285213 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -19,11 +19,13 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/avassert.h"
 #include "libavutil/eval.h"
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/mem.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/reverse.h"
 #include "libavutil/stereo3d.h"
 #include "libavutil/intreadwrite.h"
 #include "avcodec.h"
@@ -454,6 +456,9 @@ static av_cold int X264_init(AVCodecContext *avctx)
 X264Context *x4 = avctx->priv_data;
 AVCPBProperties *cpb_props;
 int sw,sh;
+x264_nal_t *nal;
+uint8_t *p;
+int nnal, s, i;
 
 if (avctx->global_quality > 0)
 av_log(avctx, AV_LOG_WARNING, "-qscale is ignored, -crf is 
recommended.\n");
@@ -799,12 +804,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (!x4->enc)
 return AVERROR_EXTERNAL;
 
-if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
-x264_nal_t *nal;
-uint8_t *p;
-int nnal, s, i;
+s = x264_encoder_headers(x4->enc, , );
+// Assert for NAL start code and SPS unit type
+av_assert0((nal->p_payload[0] | nal->p_payload[1] | nal->p_payload[2]) == 
0 && nal->p_payload[3] == 1);
+av_assert0((nal->p_payload[4] & 0x1F) == 7);
+// bits 0-7 LSB for profile. bits 8-11 for constrained set flags.
+if (avctx->profile == FF_PROFILE_UNKNOWN)
+avctx->profile = ((uint32_t)nal->p_payload[5]) | 
((uint32_t)ff_reverse[nal->p_payload[6]] << 8);
+if (avctx->level == FF_LEVEL_UNKNOWN)
+avctx->level = nal->p_payload[7];
 
-s = x264_encoder_headers(x4->enc, , );
+if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
 avctx->extradata = p = av_mallocz(s + AV_INPUT_BUFFER_PADDING_SIZE);
 if (!p)
 return AVERROR(ENOMEM);
-- 
1.9.1

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


[FFmpeg-devel] [PATCH v8 3/3] avformat/hlsenc:addition of CODECS attribute in the master playlist

2017-12-18 Thread vdixit
From: Vishwanath Dixit 

---
 libavformat/Makefile  |  2 +-
 libavformat/dashenc.c |  2 +-
 libavformat/hlsenc.c  | 65 +--
 libavformat/hlsplaylist.c |  5 +++-
 libavformat/hlsplaylist.h |  3 ++-
 libavformat/reverse.c |  1 +
 tests/ref/fate/source |  1 +
 7 files changed, 73 insertions(+), 6 deletions(-)
 create mode 100644 libavformat/reverse.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index cb70eac..1072ff9 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -61,7 +61,7 @@ OBJS-$(CONFIG_RTPDEC)+= rdt.o 
  \
 rtpdec_vp9.o\
 rtpdec_xiph.o
 OBJS-$(CONFIG_RTPENC_CHAIN)  += rtpenc_chain.o rtp.o
-OBJS-$(CONFIG_SHARED)+= log2_tab.o golomb_tab.o
+OBJS-$(CONFIG_SHARED)+= log2_tab.o golomb_tab.o reverse.o
 OBJS-$(CONFIG_SRTP)  += srtp.o
 
 # muxers/demuxers
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index f363418..016ada3 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 53dc835..d66b88b 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -39,6 +39,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/random_seed.h"
+#include "libavutil/reverse.h"
 #include "libavutil/opt.h"
 #include "libavutil/log.h"
 #include "libavutil/time_internal.h"
@@ -1082,6 +1083,63 @@ static int get_relative_url(const char *master_url, 
const char *media_url,
 return 0;
 }
 
+static char *get_codec_str(AVStream *vid_st, AVStream *aud_st) {
+size_t codec_str_size = 64;
+char *codec_str = av_malloc(codec_str_size);
+int video_str_len = 0;
+
+if (!codec_str)
+return NULL;
+
+if (!vid_st && !aud_st) {
+goto fail;
+}
+
+if (vid_st) {
+if (vid_st->codecpar->profile != FF_PROFILE_UNKNOWN &&
+vid_st->codecpar->level != FF_LEVEL_UNKNOWN &&
+vid_st->codecpar->codec_id == AV_CODEC_ID_H264) {
+snprintf(codec_str, codec_str_size, "avc1.%02x%02x%02x",
+ vid_st->codecpar->profile & 0xFF,
+ ff_reverse[(vid_st->codecpar->profile >> 8) & 0xFF],
+ vid_st->codecpar->level);
+} else {
+goto fail;
+}
+video_str_len = strlen(codec_str);
+}
+
+if (aud_st) {
+char *audio_str = codec_str;
+if (video_str_len) {
+codec_str[video_str_len] = ',';
+video_str_len += 1;
+audio_str += video_str_len;
+codec_str_size -= video_str_len;
+}
+if (aud_st->codecpar->codec_id == AV_CODEC_ID_MP2) {
+snprintf(audio_str, codec_str_size, "mp4a.40.33");
+} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_MP3) {
+snprintf(audio_str, codec_str_size, "mp4a.40.34");
+} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_AAC) {
+/* TODO : For HE-AAC, HE-AACv2, the last digit needs to be set to 
5 and 29 respectively */
+snprintf(audio_str, codec_str_size, "mp4a.40.2");
+} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_AC3) {
+snprintf(audio_str, codec_str_size, "mp4a.A5");
+} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_EAC3) {
+snprintf(audio_str, codec_str_size, "mp4a.A6");
+} else {
+goto fail;
+}
+}
+
+return codec_str;
+
+fail:
+av_free(codec_str);
+return NULL;
+}
+
 static int create_master_playlist(AVFormatContext *s,
   VariantStream * const input_vs)
 {
@@ -1091,7 +1149,7 @@ static int create_master_playlist(AVFormatContext *s,
 AVDictionary *options = NULL;
 unsigned int i, j;
 int m3u8_name_size, ret, bandwidth;
-char *m3u8_rel_name;
+char *m3u8_rel_name, *codec_str;
 
 input_vs->m3u8_created = 1;
 if (!hls->master_m3u8_created) {
@@ -1204,9 +1262,12 @@ static int create_master_playlist(AVFormatContext *s,
 bandwidth += aud_st->codecpar->bit_rate;
 bandwidth += bandwidth / 10;
 
+codec_str = get_codec_str(vid_st, aud_st);
+
 ff_hls_write_stream_info(vid_st, hls->m3u8_out, bandwidth, 
m3u8_rel_name,
-aud_st ? vs->agroup : NULL);
+

[FFmpeg-devel] [PATCH v8 1/3] avformat/hlsenc:addition of #EXT-X-MEDIA tag and AUDIO attribute

2017-12-18 Thread vdixit
From: Vishwanath Dixit 

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

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 3d0c7bf..93db549 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -834,6 +834,18 @@ be a video only stream with video bitrate 1000k, the 
second variant stream will
 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_1.m3u8, out_2.m3u8 and out_3.m3u8 will be created.
+@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" \
+  -master_pl_name master.m3u8 \
+  http://example.com/live/out.m3u8
+@end example
+This example creates two audio only and two video only variant streams. In
+addition to the #EXT-X-STREAM-INF tag for each variant stream in the master
+playlist, #EXT-X-MEDIA tag is also added for the two audio only variant streams
+and they are mapped to the two video only variant streams with audio group 
names
+'aud_low' and 'aud_high'.
 
 By default, a single hls variant containing all the encoded streams is created.
 
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 5687530..f363418 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -759,7 +759,8 @@ static int write_manifest(AVFormatContext *s, int final)
 char playlist_file[64];
 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);
+ff_hls_write_stream_info(st, out, st->codecpar->bit_rate,
+playlist_file, NULL);
 }
 avio_close(out);
 if (use_rename)
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index e3442c3..53dc835 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -144,6 +144,7 @@ typedef struct VariantStream {
 AVStream **streams;
 unsigned int nb_streams;
 int m3u8_created; /* status of media play-list creation */
+char *agroup; /* audio group name */
 char *baseurl;
 } VariantStream;
 
@@ -1085,7 +1086,7 @@ static int create_master_playlist(AVFormatContext *s,
   VariantStream * const input_vs)
 {
 HLSContext *hls = s->priv_data;
-VariantStream *vs;
+VariantStream *vs, *temp_vs;
 AVStream *vid_st, *aud_st;
 AVDictionary *options = NULL;
 unsigned int i, j;
@@ -1117,6 +1118,34 @@ static int create_master_playlist(AVFormatContext *s,
 
 ff_hls_write_playlist_version(hls->m3u8_out, hls->version);
 
+/* 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]);
+
+if (vs->has_video || vs->has_subtitle || !vs->agroup)
+continue;
+
+m3u8_name_size = strlen(vs->m3u8_name) + 1;
+m3u8_rel_name = av_malloc(m3u8_name_size);
+if (!m3u8_rel_name) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
+av_strlcpy(m3u8_rel_name, vs->m3u8_name, m3u8_name_size);
+ret = get_relative_url(hls->master_m3u8_url, vs->m3u8_name,
+   m3u8_rel_name, m3u8_name_size);
+if (ret < 0) {
+av_log(s, AV_LOG_ERROR, "Unable to find relative URL\n");
+goto fail;
+}
+
+avio_printf(hls->m3u8_out, 
"#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"group_%s\"",
+vs->agroup);
+avio_printf(hls->m3u8_out, 
",NAME=\"audio_0\",DEFAULT=YES,URI=\"%s\"\n",
+m3u8_rel_name);
+av_freep(_rel_name);
+}
+
 /* For variant streams with video add #EXT-X-STREAM-INF tag with 
attributes*/
 for (i = 0; i < hls->nb_varstreams; i++) {
 vs = &(hls->var_streams[i]);
@@ -1149,6 +1178,25 @@ static int create_master_playlist(AVFormatContext *s,
 continue;
 }
 
+/**
+ * Traverse through the list of audio only rendition streams and find
+ * the rendition which has highest bitrate in the same audio group
+ */
+if (vs->agroup) {
+for (j = 0; j < hls->nb_varstreams; j++) {
+temp_vs = &(hls->var_streams[j]);
+if (!temp_vs->has_video && !temp_vs->has_subtitle &&
+temp_vs->agroup &&
+!av_strcasecmp(temp_vs->agroup, vs->agroup)) {
+if (!aud_st)
+aud_st = temp_vs->streams[0];
+if 

Re: [FFmpeg-devel] [PATCH 3/4] avformat/hlsenc: use hlsenc_io_* APIs

2017-12-18 Thread 刘歧


> On 19 Dec 2017, at 12:11, Karthick Jeyapal  wrote:
> 
> 
> 
> On 12/19/17 9:29 AM, 刘歧 wrote:
>> 
>>> On 19 Dec 2017, at 11:55, Karthick Jeyapal  wrote:
>>> 
>>> 
>>> 
>>> On 12/18/17 2:17 PM, Steven Liu wrote:
 Signed-off-by: Steven Liu 
 ---
  libavformat/hlsenc.c | 23 ---
  1 file changed, 12 insertions(+), 11 deletions(-)
 
 diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
 index 0eebcb4462..0cb75ff198 100644
 --- a/libavformat/hlsenc.c
 +++ b/libavformat/hlsenc.c
 @@ -440,7 +440,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
 HLSContext *hls,
  av_dict_set(, "method", "DELETE", 0);
  if ((ret = vs->avf->io_open(vs->avf, , path, 
 AVIO_FLAG_WRITE, )) < 0)
  goto fail;
 -ff_format_io_close(vs->avf, );
 +hlsenc_io_close(vs->avf, , path);
>>> Will not actually close, when http_persistent is 1. I think it is better to 
>>> leave this as ff_format_io_close
  } else if (unlink(path) < 0) {
  av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: 
 %s\n",
   path, strerror(errno));
 @@ -463,7 +463,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
 HLSContext *hls,
  av_free(sub_path);
  goto fail;
  }
 -ff_format_io_close(vs->avf, );
 +hlsenc_io_close(vs->avf, , sub_path);
>>> Will not actually close, when http_persistent is 1.
  } else if (unlink(sub_path) < 0) {
  av_log(hls, AV_LOG_ERROR, "failed to delete old segment 
 %s: %s\n",
   sub_path, strerror(errno));
 @@ -556,8 +556,10 @@ static int do_encrypt(AVFormatContext *s, 
 VariantStream *vs)
  }
ff_data_to_hex(hls->key_string, key, sizeof(key), 0);
 -if ((ret = s->io_open(s, , hls->key_file, AVIO_FLAG_WRITE, 
 NULL)) < 0)
 -return ret;
 +ret = hlsenc_io_open(s, , hls->key_file, NULL);
>>> We needn't call hlsenc_io_open if we are not planning to use a persistent 
>>> connection for it. In this case pb is uninitialized and hlsenc_io_open will 
>>> most probably cause a crash or undefined behavior. You can get around that 
>>> issue by initializing pb to NULL. But I think that is unnecessary and are 
>>> better placed with s->io_open().
 +if (ret < 0) {
 +return ret;;
>>> Extra semicolon
 +}
  avio_seek(pb, 0, SEEK_CUR);
  avio_write(pb, key, KEYSIZE);
  avio_close(pb);
 @@ -588,7 +590,7 @@ static int hls_encryption_start(AVFormatContext *s)
  ff_get_line(pb, hls->iv_string, sizeof(hls->iv_string));
  hls->iv_string[strcspn(hls->iv_string, "\r\n")] = '\0';
  -ff_format_io_close(s, );
 +hlsenc_io_close(s, , hls->key_info_file);
if (!*hls->key_uri) {
  av_log(hls, AV_LOG_ERROR, "no key URI specified in key info 
 file\n");
 @@ -606,7 +608,7 @@ static int hls_encryption_start(AVFormatContext *s)
  }
ret = avio_read(pb, key, sizeof(key));
 -ff_format_io_close(s, );
 +hlsenc_io_close(s, , hls->key_file);
>>> Will not actually close, when http_persistent is 1.
  if (ret != sizeof(key)) {
  av_log(hls, AV_LOG_ERROR, "error reading key file %s\n", 
 hls->key_file);
  if (ret >= 0 || ret == AVERROR_EOF)
 @@ -1812,7 +1814,6 @@ static int hls_write_packet(AVFormatContext *s, 
 AVPacket *pkt)
  vs->init_range_length = range_length;
  avio_open_dyn_buf(>pb);
  vs->packets_written = 0;
 -ff_format_io_close(s, >out);
  hlsenc_io_close(s, >out, vs->base_output_dirname);
  }
  } else {
 @@ -1845,7 +1846,7 @@ static int hls_write_packet(AVFormatContext *s, 
 AVPacket *pkt)
  if (ret < 0) {
  return ret;
  }
 -ff_format_io_close(s, >out);
 +hlsenc_io_close(s, >out, vs->avf->filename);
  }
  ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, 
 vs->size);
  vs->start_pos = new_start_pos;
 @@ -1925,14 +1926,14 @@ static int hls_write_trailer(struct 
 AVFormatContext *s)
  if (ret < 0) {
  return ret;
  }
 -ff_format_io_close(s, >out);
 +hlsenc_io_close(s, >out, vs->avf->filename);
>>> Will not actually close, when http_persistent is 1. hls_write_trailer 
>>> should always call 

Re: [FFmpeg-devel] [PATCH] libvmaf: exit gracefully if the library fails.

2017-12-18 Thread James Almer
On 12/8/2017 10:35 PM, Ronald S. Bultje wrote:
> Fixes trac issue #6884 and Netflix/vmaf issue #124.
> ---
>  libavfilter/vf_libvmaf.c | 28 ++--
>  1 file changed, 22 insertions(+), 6 deletions(-)
> 
> diff --git a/libavfilter/vf_libvmaf.c b/libavfilter/vf_libvmaf.c
> index 7670c51..d628b95 100644
> --- a/libavfilter/vf_libvmaf.c
> +++ b/libavfilter/vf_libvmaf.c
> @@ -61,6 +61,7 @@ typedef struct LIBVMAFContext {
>  int ssim;
>  int ms_ssim;
>  char *pool;
> +int error;
>  } LIBVMAFContext;
>  
>  #define OFFSET(x) offsetof(LIBVMAFContext, x)
> @@ -158,17 +159,24 @@ static void compute_vmaf_score(LIBVMAFContext *s)
>  
>  format = (char *) s->desc->name;
>  
> -s->vmaf_score = compute_vmaf(format, s->width, s->height, read_frame, s,
> - s->model_path, s->log_path, s->log_fmt, 0, 
> 0,
> - s->enable_transform, s->phone_model, 
> s->psnr,
> - s->ssim, s->ms_ssim, s->pool);
> +s->error = compute_vmaf(>vmaf_score, format, s->width, s->height,

This is an awful API break. It broke compilation for everyone using the
latest stable release of libvmaf. See ticket #6921.
How hard was for them to add a new function instead?
compute_vmaf_score() or whatever. You can't just go and change a public
function signature like this...

This can still implement this properly before a new release is tagged,
for that matter. Could you suggest that to them?

> +read_frame, s, s->model_path, s->log_path,
> +s->log_fmt, 0, 0, s->enable_transform,
> +s->phone_model, s->psnr, s->ssim,
> +s->ms_ssim, s->pool);
>  }
>  
>  static void *call_vmaf(void *ctx)
>  {
>  LIBVMAFContext *s = (LIBVMAFContext *) ctx;
>  compute_vmaf_score(s);
> -av_log(ctx, AV_LOG_INFO, "VMAF score: %f\n",s->vmaf_score);
> +if (!s->error) {
> +av_log(ctx, AV_LOG_INFO, "VMAF score: %f\n",s->vmaf_score);
> +} else {
> +pthread_mutex_lock(>lock);
> +pthread_cond_signal(>cond);
> +pthread_mutex_unlock(>lock);
> +}
>  pthread_exit(NULL);
>  }
>  
> @@ -187,10 +195,17 @@ static int do_vmaf(FFFrameSync *fs)
>  
>  pthread_mutex_lock(>lock);
>  
> -while (s->frame_set != 0) {
> +while (s->frame_set && !s->error) {
>  pthread_cond_wait(>cond, >lock);
>  }
>  
> +if (s->error) {
> +av_log(ctx, AV_LOG_ERROR,
> +   "libvmaf encountered an error, check log for details\n");
> +pthread_mutex_unlock(>lock);
> +return AVERROR(EINVAL);
> +}
> +
>  av_frame_ref(s->gref, ref);
>  av_frame_ref(s->gmain, main);
>  
> @@ -208,6 +223,7 @@ static av_cold int init(AVFilterContext *ctx)
>  
>  s->gref = av_frame_alloc();
>  s->gmain = av_frame_alloc();
> +s->error = 0;
>  
>  pthread_mutex_init(>lock, NULL);
>  pthread_cond_init (>cond, NULL);
> 

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


Re: [FFmpeg-devel] [PATCH 3/4] avformat/hlsenc: use hlsenc_io_* APIs

2017-12-18 Thread Karthick Jeyapal



On 12/19/17 9:29 AM, 刘歧 wrote:



On 19 Dec 2017, at 11:55, Karthick Jeyapal  wrote:



On 12/18/17 2:17 PM, Steven Liu wrote:

Signed-off-by: Steven Liu 
---
  libavformat/hlsenc.c | 23 ---
  1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 0eebcb4462..0cb75ff198 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -440,7 +440,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
  av_dict_set(, "method", "DELETE", 0);
  if ((ret = vs->avf->io_open(vs->avf, , path, AVIO_FLAG_WRITE, 
)) < 0)
  goto fail;
-ff_format_io_close(vs->avf, );
+hlsenc_io_close(vs->avf, , path);

Will not actually close, when http_persistent is 1. I think it is better to 
leave this as ff_format_io_close

  } else if (unlink(path) < 0) {
  av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
   path, strerror(errno));
@@ -463,7 +463,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
  av_free(sub_path);
  goto fail;
  }
-ff_format_io_close(vs->avf, );
+hlsenc_io_close(vs->avf, , sub_path);

Will not actually close, when http_persistent is 1.

  } else if (unlink(sub_path) < 0) {
  av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: 
%s\n",
   sub_path, strerror(errno));
@@ -556,8 +556,10 @@ static int do_encrypt(AVFormatContext *s, VariantStream 
*vs)
  }
ff_data_to_hex(hls->key_string, key, sizeof(key), 0);
-if ((ret = s->io_open(s, , hls->key_file, AVIO_FLAG_WRITE, NULL)) < 
0)
-return ret;
+ret = hlsenc_io_open(s, , hls->key_file, NULL);

We needn't call hlsenc_io_open if we are not planning to use a persistent 
connection for it. In this case pb is uninitialized and hlsenc_io_open will most 
probably cause a crash or undefined behavior. You can get around that issue by 
initializing pb to NULL. But I think that is unnecessary and are better placed 
with s->io_open().

+if (ret < 0) {
+return ret;;

Extra semicolon

+}
  avio_seek(pb, 0, SEEK_CUR);
  avio_write(pb, key, KEYSIZE);
  avio_close(pb);
@@ -588,7 +590,7 @@ static int hls_encryption_start(AVFormatContext *s)
  ff_get_line(pb, hls->iv_string, sizeof(hls->iv_string));
  hls->iv_string[strcspn(hls->iv_string, "\r\n")] = '\0';
  -ff_format_io_close(s, );
+hlsenc_io_close(s, , hls->key_info_file);
if (!*hls->key_uri) {
  av_log(hls, AV_LOG_ERROR, "no key URI specified in key info file\n");
@@ -606,7 +608,7 @@ static int hls_encryption_start(AVFormatContext *s)
  }
ret = avio_read(pb, key, sizeof(key));
-ff_format_io_close(s, );
+hlsenc_io_close(s, , hls->key_file);

Will not actually close, when http_persistent is 1.

  if (ret != sizeof(key)) {
  av_log(hls, AV_LOG_ERROR, "error reading key file %s\n", 
hls->key_file);
  if (ret >= 0 || ret == AVERROR_EOF)
@@ -1812,7 +1814,6 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
  vs->init_range_length = range_length;
  avio_open_dyn_buf(>pb);
  vs->packets_written = 0;
-ff_format_io_close(s, >out);
  hlsenc_io_close(s, >out, vs->base_output_dirname);
  }
  } else {
@@ -1845,7 +1846,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
  if (ret < 0) {
  return ret;
  }
-ff_format_io_close(s, >out);
+hlsenc_io_close(s, >out, vs->avf->filename);
  }
  ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, 
vs->size);
  vs->start_pos = new_start_pos;
@@ -1925,14 +1926,14 @@ static int hls_write_trailer(struct AVFormatContext *s)
  if (ret < 0) {
  return ret;
  }
-ff_format_io_close(s, >out);
+hlsenc_io_close(s, >out, vs->avf->filename);

Will not actually close, when http_persistent is 1. hls_write_trailer should 
always call ff_format_io_close()

  }
av_write_trailer(oc);
  if (oc->pb) {
  vs->size = avio_tell(vs->avf->pb) - vs->start_pos;
  if (hls->segment_type != SEGMENT_TYPE_FMP4)
-ff_format_io_close(s, >pb);
+hlsenc_io_close(s, >pb, oc->filename);

Will not actually close, when http_persistent is 1. hls_write_trailer should 
always call ff_format_io_close()

if ((hls->flags & HLS_TEMP_FILE) && oc->filename[0]) {
  hls_rename_temp_file(s, oc);
@@ -1948,7 +1949,7 @@ static int 

[FFmpeg-devel] Fwd: Re: [PATCH 4/4] avformat/hlsenc: add http options to m3u8 hlsenc

2017-12-18 Thread Karthick Jeyapal


On 12/18/17 2:17 PM, Steven Liu wrote:

Signed-off-by: Steven Liu 
---
  libavformat/hlsenc.c | 8 ++--
  1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 0cb75ff198..636b7db183 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1723,6 +1723,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
  int stream_index = 0;
  int range_length = 0;
  uint8_t *buffer = NULL;
+AVDictionary *options = NULL;
  VariantStream *vs = NULL;
  
  for (i = 0; i < hls->nb_varstreams; i++) {

@@ -1835,7 +1836,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
  }
  
  if (hls->segment_type == SEGMENT_TYPE_FMP4) {

-ret = hlsenc_io_open(s, >out, vs->avf->filename, NULL);
+set_http_options(s, , hls);
+ret = hlsenc_io_open(s, >out, vs->avf->filename, );

av_dict_free() call for options needs to be added here

  if (ret < 0) {
  av_log(NULL, AV_LOG_ERROR, "Failed to open file '%s'\n",
  vs->avf->filename);
@@ -1899,6 +1901,7 @@ static int hls_write_trailer(struct AVFormatContext *s)
  HLSContext *hls = s->priv_data;
  AVFormatContext *oc = NULL;
  AVFormatContext *vtt_oc = NULL;
+AVDictionary *options = NULL;
  char *old_filename = NULL;
  int i;
  int ret = 0;
@@ -1916,7 +1919,8 @@ static int hls_write_trailer(struct AVFormatContext *s)
  }
  if ( hls->segment_type == SEGMENT_TYPE_FMP4) {
  int range_length = 0;
-ret = hlsenc_io_open(s, >out, vs->avf->filename, NULL);
+set_http_options(s, , hls);
+ret = hlsenc_io_open(s, >out, vs->avf->filename, );

av_dict_free() call for options needs to be added here

  if (ret < 0) {
  av_log(NULL, AV_LOG_ERROR, "Failed to open file '%s'\n", 
vs->avf->filename);
  return AVERROR(ENOENT);


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


Re: [FFmpeg-devel] [PATCH 3/4] avformat/hlsenc: use hlsenc_io_* APIs

2017-12-18 Thread 刘歧


> On 19 Dec 2017, at 11:55, Karthick Jeyapal  wrote:
> 
> 
> 
> On 12/18/17 2:17 PM, Steven Liu wrote:
>> Signed-off-by: Steven Liu 
>> ---
>>  libavformat/hlsenc.c | 23 ---
>>  1 file changed, 12 insertions(+), 11 deletions(-)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index 0eebcb4462..0cb75ff198 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -440,7 +440,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
>> HLSContext *hls,
>>  av_dict_set(, "method", "DELETE", 0);
>>  if ((ret = vs->avf->io_open(vs->avf, , path, 
>> AVIO_FLAG_WRITE, )) < 0)
>>  goto fail;
>> -ff_format_io_close(vs->avf, );
>> +hlsenc_io_close(vs->avf, , path);
> Will not actually close, when http_persistent is 1. I think it is better to 
> leave this as ff_format_io_close
>>  } else if (unlink(path) < 0) {
>>  av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: 
>> %s\n",
>>   path, strerror(errno));
>> @@ -463,7 +463,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
>> HLSContext *hls,
>>  av_free(sub_path);
>>  goto fail;
>>  }
>> -ff_format_io_close(vs->avf, );
>> +hlsenc_io_close(vs->avf, , sub_path);
> Will not actually close, when http_persistent is 1.
>>  } else if (unlink(sub_path) < 0) {
>>  av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: 
>> %s\n",
>>   sub_path, strerror(errno));
>> @@ -556,8 +556,10 @@ static int do_encrypt(AVFormatContext *s, VariantStream 
>> *vs)
>>  }
>>ff_data_to_hex(hls->key_string, key, sizeof(key), 0);
>> -if ((ret = s->io_open(s, , hls->key_file, AVIO_FLAG_WRITE, 
>> NULL)) < 0)
>> -return ret;
>> +ret = hlsenc_io_open(s, , hls->key_file, NULL);
> We needn't call hlsenc_io_open if we are not planning to use a persistent 
> connection for it. In this case pb is uninitialized and hlsenc_io_open will 
> most probably cause a crash or undefined behavior. You can get around that 
> issue by initializing pb to NULL. But I think that is unnecessary and are 
> better placed with s->io_open().
>> +if (ret < 0) {
>> +return ret;;
> Extra semicolon
>> +}
>>  avio_seek(pb, 0, SEEK_CUR);
>>  avio_write(pb, key, KEYSIZE);
>>  avio_close(pb);
>> @@ -588,7 +590,7 @@ static int hls_encryption_start(AVFormatContext *s)
>>  ff_get_line(pb, hls->iv_string, sizeof(hls->iv_string));
>>  hls->iv_string[strcspn(hls->iv_string, "\r\n")] = '\0';
>>  -ff_format_io_close(s, );
>> +hlsenc_io_close(s, , hls->key_info_file);
>>if (!*hls->key_uri) {
>>  av_log(hls, AV_LOG_ERROR, "no key URI specified in key info 
>> file\n");
>> @@ -606,7 +608,7 @@ static int hls_encryption_start(AVFormatContext *s)
>>  }
>>ret = avio_read(pb, key, sizeof(key));
>> -ff_format_io_close(s, );
>> +hlsenc_io_close(s, , hls->key_file);
> Will not actually close, when http_persistent is 1.
>>  if (ret != sizeof(key)) {
>>  av_log(hls, AV_LOG_ERROR, "error reading key file %s\n", 
>> hls->key_file);
>>  if (ret >= 0 || ret == AVERROR_EOF)
>> @@ -1812,7 +1814,6 @@ static int hls_write_packet(AVFormatContext *s, 
>> AVPacket *pkt)
>>  vs->init_range_length = range_length;
>>  avio_open_dyn_buf(>pb);
>>  vs->packets_written = 0;
>> -ff_format_io_close(s, >out);
>>  hlsenc_io_close(s, >out, vs->base_output_dirname);
>>  }
>>  } else {
>> @@ -1845,7 +1846,7 @@ static int hls_write_packet(AVFormatContext *s, 
>> AVPacket *pkt)
>>  if (ret < 0) {
>>  return ret;
>>  }
>> -ff_format_io_close(s, >out);
>> +hlsenc_io_close(s, >out, vs->avf->filename);
>>  }
>>  ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, 
>> vs->size);
>>  vs->start_pos = new_start_pos;
>> @@ -1925,14 +1926,14 @@ static int hls_write_trailer(struct AVFormatContext 
>> *s)
>>  if (ret < 0) {
>>  return ret;
>>  }
>> -ff_format_io_close(s, >out);
>> +hlsenc_io_close(s, >out, vs->avf->filename);
> Will not actually close, when http_persistent is 1. hls_write_trailer should 
> always call ff_format_io_close()
>>  }
>>av_write_trailer(oc);
>>  if (oc->pb) {
>>  vs->size = avio_tell(vs->avf->pb) - vs->start_pos;
>>  if (hls->segment_type != SEGMENT_TYPE_FMP4)
>> -ff_format_io_close(s, >pb);
>> +hlsenc_io_close(s, >pb, oc->filename);
> Will not actually close, when 

Re: [FFmpeg-devel] [PATCH 3/4] avformat/hlsenc: use hlsenc_io_* APIs

2017-12-18 Thread Karthick Jeyapal



On 12/18/17 2:17 PM, Steven Liu wrote:

Signed-off-by: Steven Liu 
---
  libavformat/hlsenc.c | 23 ---
  1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 0eebcb4462..0cb75ff198 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -440,7 +440,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
  av_dict_set(, "method", "DELETE", 0);
  if ((ret = vs->avf->io_open(vs->avf, , path, AVIO_FLAG_WRITE, 
)) < 0)
  goto fail;
-ff_format_io_close(vs->avf, );
+hlsenc_io_close(vs->avf, , path);
Will not actually close, when http_persistent is 1. I think it is better 
to leave this as ff_format_io_close

  } else if (unlink(path) < 0) {
  av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
   path, strerror(errno));
@@ -463,7 +463,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
  av_free(sub_path);
  goto fail;
  }
-ff_format_io_close(vs->avf, );
+hlsenc_io_close(vs->avf, , sub_path);

Will not actually close, when http_persistent is 1.

  } else if (unlink(sub_path) < 0) {
  av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: 
%s\n",
   sub_path, strerror(errno));
@@ -556,8 +556,10 @@ static int do_encrypt(AVFormatContext *s, VariantStream 
*vs)
  }
  
  ff_data_to_hex(hls->key_string, key, sizeof(key), 0);

-if ((ret = s->io_open(s, , hls->key_file, AVIO_FLAG_WRITE, NULL)) < 
0)
-return ret;
+ret = hlsenc_io_open(s, , hls->key_file, NULL);
We needn't call hlsenc_io_open if we are not planning to use a 
persistent connection for it. In this case pb is uninitialized and 
hlsenc_io_open will most probably cause a crash or undefined behavior. 
You can get around that issue by initializing pb to NULL. But I think 
that is unnecessary and are better placed with s->io_open().

+if (ret < 0) {
+return ret;;

Extra semicolon

+}
  avio_seek(pb, 0, SEEK_CUR);
  avio_write(pb, key, KEYSIZE);
  avio_close(pb);
@@ -588,7 +590,7 @@ static int hls_encryption_start(AVFormatContext *s)
  ff_get_line(pb, hls->iv_string, sizeof(hls->iv_string));
  hls->iv_string[strcspn(hls->iv_string, "\r\n")] = '\0';
  
-ff_format_io_close(s, );

+hlsenc_io_close(s, , hls->key_info_file);
  
  if (!*hls->key_uri) {

  av_log(hls, AV_LOG_ERROR, "no key URI specified in key info file\n");
@@ -606,7 +608,7 @@ static int hls_encryption_start(AVFormatContext *s)
  }
  
  ret = avio_read(pb, key, sizeof(key));

-ff_format_io_close(s, );
+hlsenc_io_close(s, , hls->key_file);

Will not actually close, when http_persistent is 1.

  if (ret != sizeof(key)) {
  av_log(hls, AV_LOG_ERROR, "error reading key file %s\n", 
hls->key_file);
  if (ret >= 0 || ret == AVERROR_EOF)
@@ -1812,7 +1814,6 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
  vs->init_range_length = range_length;
  avio_open_dyn_buf(>pb);
  vs->packets_written = 0;
-ff_format_io_close(s, >out);
  hlsenc_io_close(s, >out, vs->base_output_dirname);
  }
  } else {
@@ -1845,7 +1846,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
  if (ret < 0) {
  return ret;
  }
-ff_format_io_close(s, >out);
+hlsenc_io_close(s, >out, vs->avf->filename);
  }
  ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, 
vs->size);
  vs->start_pos = new_start_pos;
@@ -1925,14 +1926,14 @@ static int hls_write_trailer(struct AVFormatContext *s)
  if (ret < 0) {
  return ret;
  }
-ff_format_io_close(s, >out);
+hlsenc_io_close(s, >out, vs->avf->filename);
Will not actually close, when http_persistent is 1. hls_write_trailer 
should always call ff_format_io_close()

  }
  
  av_write_trailer(oc);

  if (oc->pb) {
  vs->size = avio_tell(vs->avf->pb) - vs->start_pos;
  if (hls->segment_type != SEGMENT_TYPE_FMP4)
-ff_format_io_close(s, >pb);
+hlsenc_io_close(s, >pb, oc->filename);
Will not actually close, when http_persistent is 1. hls_write_trailer 
should always call ff_format_io_close()
  
  if ((hls->flags & HLS_TEMP_FILE) && oc->filename[0]) {

  hls_rename_temp_file(s, oc);
@@ -1948,7 +1949,7 @@ static int hls_write_trailer(struct AVFormatContext *s)
  if (vtt_oc->pb)
  av_write_trailer(vtt_oc);
  

Re: [FFmpeg-devel] [PATCH v7 1/3] avformat/hlsenc:addition of #EXT-X-MEDIA tag and AUDIO attribute

2017-12-18 Thread 刘歧

> On 18 Dec 2017, at 20:52, vdi...@akamai.com wrote:
> 
> From: Vishwanath Dixit 
> 
> ---
> doc/muxers.texi   | 12 +
> libavformat/dashenc.c |  3 ++-
> libavformat/hlsenc.c  | 62 ---
> libavformat/hlsplaylist.c |  4 ++-
> libavformat/hlsplaylist.h |  2 +-
> 5 files changed, 77 insertions(+), 6 deletions(-)
> 
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 3d0c7bf..93db549 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -834,6 +834,18 @@ be a video only stream with video bitrate 1000k, the 
> second variant stream will
> 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_1.m3u8, out_2.m3u8 and out_3.m3u8 will be created.
> +@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" \
> +  -master_pl_name master.m3u8 \
> +  http://example.com/live/out.m3u8
> +@end example
> +This example creates two audio only and two video only variant streams. In
> +addition to the #EXT-X-STREAM-INF tag for each variant stream in the master
> +playlist, #EXT-X-MEDIA tag is also added for the two audio only variant 
> streams
> +and they are mapped to the two video only variant streams with audio group 
> names
> +'aud_low' and 'aud_high'.
> 
> By default, a single hls variant containing all the encoded streams is 
> created.
> 
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 5687530..f363418 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -759,7 +759,8 @@ static int write_manifest(AVFormatContext *s, int final)
> char playlist_file[64];
> 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);
> +ff_hls_write_stream_info(st, out, st->codecpar->bit_rate,
> +playlist_file, NULL);
> }
> avio_close(out);
> if (use_rename)
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index e3442c3..2903e4e 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -144,6 +144,7 @@ typedef struct VariantStream {
> AVStream **streams;
> unsigned int nb_streams;
> int m3u8_created; /* status of media play-list creation */
> +char *agroup; /* audio group name */
> char *baseurl;
> } VariantStream;
> 
> @@ -1085,7 +1086,7 @@ static int create_master_playlist(AVFormatContext *s,
>   VariantStream * const input_vs)
> {
> HLSContext *hls = s->priv_data;
> -VariantStream *vs;
> +VariantStream *vs, *temp_vs;
> AVStream *vid_st, *aud_st;
> AVDictionary *options = NULL;
> unsigned int i, j;
> @@ -1117,6 +1118,34 @@ static int create_master_playlist(AVFormatContext *s,
> 
> ff_hls_write_playlist_version(hls->m3u8_out, hls->version);
> 
> +/* 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]);
> +
> +if (vs->has_video || vs->has_subtitle || !vs->agroup)
> +continue;
> +
> +m3u8_name_size = strlen(vs->m3u8_name) + 1;
> +m3u8_rel_name = av_malloc(m3u8_name_size);
> +if (!m3u8_rel_name) {
> +ret = AVERROR(ENOMEM);
> +goto fail;
> +}
> +av_strlcpy(m3u8_rel_name, vs->m3u8_name, m3u8_name_size);
> +ret = get_relative_url(hls->master_m3u8_url, vs->m3u8_name,
> +   m3u8_rel_name, m3u8_name_size);
> +if (ret < 0) {
> +av_log(s, AV_LOG_ERROR, "Unable to find relative URL\n");
> +goto fail;
> +}
> +
> +avio_printf(hls->m3u8_out, 
> "#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"group_%s\"",
> +vs->agroup);
> +avio_printf(hls->m3u8_out, 
> ",NAME=\"audio_0\",DEFAULT=YES,URI=\"%s\"\n",
> +m3u8_rel_name);
> +av_freep(_rel_name);
> +}
> +
> /* For variant streams with video add #EXT-X-STREAM-INF tag with 
> attributes*/
> for (i = 0; i < hls->nb_varstreams; i++) {
> vs = &(hls->var_streams[i]);
> @@ -1149,6 +1178,25 @@ static int create_master_playlist(AVFormatContext *s,
> continue;
> }
> 
> +/**
> + * Traverse through the list of audio only rendition streams and find
> + * the rendition which has highest bitrate in the same audio group
> + */
> +if (vs->agroup) {
> +for (j = 0; j < hls->nb_varstreams; j++) {
> +temp_vs = &(hls->var_streams[j]);
> +if 

Re: [FFmpeg-devel] [PATCH 1/4] avformat/hlsenc: fix first fragment mp4 do not split bug

2017-12-18 Thread 刘歧


> On 19 Dec 2017, at 11:42, Karthick Jeyapal  wrote:
> 
> 
> 
> On 12/18/17 2:17 PM, Steven Liu wrote:
>> fix ticket id: 6888
>> 
>> Signed-off-by: Steven Liu 
>> ---
>>  libavformat/hlsenc.c | 72 
>> 
>>  1 file changed, 62 insertions(+), 10 deletions(-)
>> 
>> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
>> index e3442c368f..f51fec1030 100644
>> --- a/libavformat/hlsenc.c
>> +++ b/libavformat/hlsenc.c
>> @@ -352,6 +352,29 @@ static void write_styp(AVIOContext *pb)
>>  ffio_wfourcc(pb, "msix");
>>  }
>>  +static int flush_dynbuf(VariantStream *vs, int *range_length)
>> +{
>> +AVFormatContext *ctx = vs->avf;
>> +uint8_t *buffer;
>> +
>> +if (!ctx->pb) {
>> +return AVERROR(EINVAL);
>> +}
>> +
>> +// flush
>> +av_write_frame(ctx, NULL);
>> +avio_flush(ctx->pb);
>> +
>> +// write out to file
>> +*range_length = avio_close_dyn_buf(ctx->pb, );
>> +ctx->pb = NULL;
>> +avio_write(vs->out, buffer, *range_length);
>> +av_free(buffer);
>> +
>> +// re-open buffer
>> +return avio_open_dyn_buf(>pb);
>> +}
>> +
>>  static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
>> VariantStream *vs) {
>>  @@ -677,7 +700,9 @@ static int hls_mux_init(AVFormatContext *s, 
>> VariantStream *vs)
>>  if ((ret = avio_open_dyn_buf(>pb)) < 0)
>>  return ret;
>>  -if ((ret = s->io_open(s, >out, vs->base_output_dirname, 
>> AVIO_FLAG_WRITE, )) < 0) {
>> +ret = hlsenc_io_open(s, >out, vs->base_output_dirname, 
>> );
>> +av_dict_free();
>> +if (ret < 0) {
>>  av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", 
>> vs->fmp4_init_filename);
>>  return ret;
>>  }
>> @@ -1404,9 +1429,10 @@ static int hls_start(AVFormatContext *s, 
>> VariantStream *vs)
>>  av_dict_free();
>>  if (err < 0)
>>  return err;
>> -} else
>> +} else if (c->segment_type != SEGMENT_TYPE_FMP4) {
>>  if ((err = hlsenc_io_open(s, >pb, oc->filename, )) < 0)
>>  goto fail;
>> +}
>>  if (vs->vtt_basename) {
>>  set_http_options(s, , c);
>>  if ((err = hlsenc_io_open(s, _oc->pb, vtt_oc->filename, 
>> )) < 0)
>> @@ -1414,9 +1440,7 @@ static int hls_start(AVFormatContext *s, VariantStream 
>> *vs)
>>  }
>>  av_dict_free();
>>  -if (c->segment_type == SEGMENT_TYPE_FMP4 && !(c->flags & 
>> HLS_SINGLE_FILE)) {
>> -write_styp(oc->pb);
>> -} else {
>> +if (c->segment_type != SEGMENT_TYPE_FMP4) {
>>  /* We only require one PAT/PMT per segment. */
>>  if (oc->oformat->priv_class && oc->priv_data) {
>>  char period[21];
>> @@ -1780,7 +1804,8 @@ static int hls_write_packet(AVFormatContext *s, 
>> AVPacket *pkt)
>>  vs->size = new_start_pos - vs->start_pos;
>>if (!byterange_mode) {
>> -if (hls->segment_type == SEGMENT_TYPE_FMP4 && 
>> !vs->init_range_length) {
>> +if (hls->segment_type == SEGMENT_TYPE_FMP4) {
>> +if (!vs->init_range_length) {
>>  avio_flush(oc->pb);
>>  range_length = avio_close_dyn_buf(oc->pb, );
>>  avio_write(vs->out, buffer, range_length);
>> @@ -1789,6 +1814,7 @@ static int hls_write_packet(AVFormatContext *s, 
>> AVPacket *pkt)
>>  vs->packets_written = 0;
>>  ff_format_io_close(s, >out);
>>  hlsenc_io_close(s, >out, vs->base_output_dirname);
>> +}
>>  } else {
>>  hlsenc_io_close(s, >pb, oc->filename);
>>  }
>> @@ -1807,7 +1833,20 @@ static int hls_write_packet(AVFormatContext *s, 
>> AVPacket *pkt)
>>  vs->number--;
>>  }
>>  -if (!vs->fmp4_init_mode || byterange_mode)
>> +if (hls->segment_type == SEGMENT_TYPE_FMP4) {
>> +ret = hlsenc_io_open(s, >out, vs->avf->filename, NULL);
> Will it be better if you call "set_http_options()" here itself, instead of a 
> separate patch 4/4? In that way this patch would be self contained.
set_http_options is add option to http operation, so separate two patches.
And this patch just fix ticket
>> +if (ret < 0) {
>> +av_log(NULL, AV_LOG_ERROR, "Failed to open file '%s'\n",
>> +vs->avf->filename);
>> +return ret;
>> +}
>> +write_styp(vs->out);
>> +ret = flush_dynbuf(vs, _length);
>> +if (ret < 0) {
>> +return ret;
>> +}
>> +ff_format_io_close(s, >out);
> Again is it better to call hlsenc_io_close() here itself instead of patch 
> 3/4. Again just from self-containment perspective.
Replace API to hlsenc_io_close is a new operation, so separate two patch
And this patch just fix 

Re: [FFmpeg-devel] [PATCH 2/4] avformat/hlsenc: reindent after previous commits

2017-12-18 Thread Karthick Jeyapal



On 12/18/17 2:17 PM, Steven Liu wrote:

Signed-off-by: Steven Liu 
---
  libavformat/hlsenc.c | 24 
  1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index f51fec1030..0eebcb4462 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1806,14 +1806,14 @@ static int hls_write_packet(AVFormatContext *s, 
AVPacket *pkt)
  if (!byterange_mode) {
  if (hls->segment_type == SEGMENT_TYPE_FMP4) {
  if (!vs->init_range_length) {
-avio_flush(oc->pb);
-range_length = avio_close_dyn_buf(oc->pb, );
-avio_write(vs->out, buffer, range_length);
-vs->init_range_length = range_length;
-avio_open_dyn_buf(>pb);
-vs->packets_written = 0;
-ff_format_io_close(s, >out);
-hlsenc_io_close(s, >out, vs->base_output_dirname);
+avio_flush(oc->pb);
+range_length = avio_close_dyn_buf(oc->pb, );
+avio_write(vs->out, buffer, range_length);
+vs->init_range_length = range_length;
+avio_open_dyn_buf(>pb);
+vs->packets_written = 0;
+ff_format_io_close(s, >out);
+hlsenc_io_close(s, >out, vs->base_output_dirname);
  }
  } else {
  hlsenc_io_close(s, >pb, oc->filename);
@@ -1847,7 +1847,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
  }
  ff_format_io_close(s, >out);
  }
-ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, 
vs->size);
+ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, 
vs->size);
  vs->start_pos = new_start_pos;
  if (ret < 0) {
  av_free(old_filename);
@@ -1932,7 +1932,7 @@ static int hls_write_trailer(struct AVFormatContext *s)
  if (oc->pb) {
  vs->size = avio_tell(vs->avf->pb) - vs->start_pos;
  if (hls->segment_type != SEGMENT_TYPE_FMP4)
-ff_format_io_close(s, >pb);
+ff_format_io_close(s, >pb);
  
  if ((hls->flags & HLS_TEMP_FILE) && oc->filename[0]) {

  hls_rename_temp_file(s, oc);
@@ -2292,8 +2292,8 @@ static int hls_init(AVFormatContext *s)
  }
  }
  
-if ((ret = hls_start(s, vs)) < 0)

-goto fail;
+if ((ret = hls_start(s, vs)) < 0)
+goto fail;
  }
  
  fail:

LGTM

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


Re: [FFmpeg-devel] [PATCH 1/4] avformat/hlsenc: fix first fragment mp4 do not split bug

2017-12-18 Thread Karthick Jeyapal



On 12/18/17 2:17 PM, Steven Liu wrote:

fix ticket id: 6888

Signed-off-by: Steven Liu 
---
  libavformat/hlsenc.c | 72 
  1 file changed, 62 insertions(+), 10 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index e3442c368f..f51fec1030 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -352,6 +352,29 @@ static void write_styp(AVIOContext *pb)
  ffio_wfourcc(pb, "msix");
  }
  
+static int flush_dynbuf(VariantStream *vs, int *range_length)

+{
+AVFormatContext *ctx = vs->avf;
+uint8_t *buffer;
+
+if (!ctx->pb) {
+return AVERROR(EINVAL);
+}
+
+// flush
+av_write_frame(ctx, NULL);
+avio_flush(ctx->pb);
+
+// write out to file
+*range_length = avio_close_dyn_buf(ctx->pb, );
+ctx->pb = NULL;
+avio_write(vs->out, buffer, *range_length);
+av_free(buffer);
+
+// re-open buffer
+return avio_open_dyn_buf(>pb);
+}
+
  static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
 VariantStream *vs) {
  
@@ -677,7 +700,9 @@ static int hls_mux_init(AVFormatContext *s, VariantStream *vs)

  if ((ret = avio_open_dyn_buf(>pb)) < 0)
  return ret;
  
-if ((ret = s->io_open(s, >out, vs->base_output_dirname, AVIO_FLAG_WRITE, )) < 0) {

+ret = hlsenc_io_open(s, >out, vs->base_output_dirname, );
+av_dict_free();
+if (ret < 0) {
  av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", 
vs->fmp4_init_filename);
  return ret;
  }
@@ -1404,9 +1429,10 @@ static int hls_start(AVFormatContext *s, VariantStream 
*vs)
  av_dict_free();
  if (err < 0)
  return err;
-} else
+} else if (c->segment_type != SEGMENT_TYPE_FMP4) {
  if ((err = hlsenc_io_open(s, >pb, oc->filename, )) < 0)
  goto fail;
+}
  if (vs->vtt_basename) {
  set_http_options(s, , c);
  if ((err = hlsenc_io_open(s, _oc->pb, vtt_oc->filename, )) 
< 0)
@@ -1414,9 +1440,7 @@ static int hls_start(AVFormatContext *s, VariantStream 
*vs)
  }
  av_dict_free();
  
-if (c->segment_type == SEGMENT_TYPE_FMP4 && !(c->flags & HLS_SINGLE_FILE)) {

-write_styp(oc->pb);
-} else {
+if (c->segment_type != SEGMENT_TYPE_FMP4) {
  /* We only require one PAT/PMT per segment. */
  if (oc->oformat->priv_class && oc->priv_data) {
  char period[21];
@@ -1780,7 +1804,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
  vs->size = new_start_pos - vs->start_pos;
  
  if (!byterange_mode) {

-if (hls->segment_type == SEGMENT_TYPE_FMP4 && 
!vs->init_range_length) {
+if (hls->segment_type == SEGMENT_TYPE_FMP4) {
+if (!vs->init_range_length) {
  avio_flush(oc->pb);
  range_length = avio_close_dyn_buf(oc->pb, );
  avio_write(vs->out, buffer, range_length);
@@ -1789,6 +1814,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
  vs->packets_written = 0;
  ff_format_io_close(s, >out);
  hlsenc_io_close(s, >out, vs->base_output_dirname);
+}
  } else {
  hlsenc_io_close(s, >pb, oc->filename);
  }
@@ -1807,7 +1833,20 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
  vs->number--;
  }
  
-if (!vs->fmp4_init_mode || byterange_mode)

+if (hls->segment_type == SEGMENT_TYPE_FMP4) {
+ret = hlsenc_io_open(s, >out, vs->avf->filename, NULL);
Will it be better if you call "set_http_options()" here itself, instead 
of a separate patch 4/4? In that way this patch would be self contained.

+if (ret < 0) {
+av_log(NULL, AV_LOG_ERROR, "Failed to open file '%s'\n",
+vs->avf->filename);
+return ret;
+}
+write_styp(vs->out);
+ret = flush_dynbuf(vs, _length);
+if (ret < 0) {
+return ret;
+}
+ff_format_io_close(s, >out);
Again is it better to call hlsenc_io_close() here itself instead of 
patch 3/4. Again just from self-containment perspective.

+}
  ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, 
vs->size);
  vs->start_pos = new_start_pos;
  if (ret < 0) {
@@ -1861,6 +1900,7 @@ static int hls_write_trailer(struct AVFormatContext *s)
  AVFormatContext *vtt_oc = NULL;
  char *old_filename = NULL;
  int i;
+int ret = 0;
  VariantStream *vs = NULL;
  
  for (i = 0; i < hls->nb_varstreams; i++) {

@@ -1873,11 +1913,25 @@ static int hls_write_trailer(struct AVFormatContext *s)
  if (!old_filename) {
  return AVERROR(ENOMEM);
  }
-
+if ( 

Re: [FFmpeg-devel] [RFC] avcodec/avcodec.h: Add encryption info side data

2017-12-18 Thread Michael Niedermayer
On Mon, Dec 18, 2017 at 06:29:14PM -0500, Ronald S. Bultje wrote:
> Hi,
> 
> On Mon, Dec 18, 2017 at 6:00 PM, Michael Niedermayer  > wrote:
> 
> > If you decode this again you need the side data in the format of the
> > platform
> > the decoder runs on. This is very very basic logic. Something must convert
> > it
> 
> 
> Right, this concept is typically called a "serializer" and "deserializer".
> Adding them to the API is a good idea. But I don't understand why we'd want
> to store side-data as binary (platform-independent) data, that would ruin
> it accessibility from applications. Applications don't want to call hton or
> ntoh on each structure member they access, right?

yes, i fully agree

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf


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


Re: [FFmpeg-devel] [RFC] avcodec/avcodec.h: Add encryption info side data

2017-12-18 Thread wm4
On Tue, 19 Dec 2017 01:14:37 +0100
Michael Niedermayer  wrote:

> On Tue, Dec 19, 2017 at 12:17:11AM +0100, wm4 wrote:
> > On Tue, 19 Dec 2017 00:00:15 +0100
> > Michael Niedermayer  wrote:
> >   
> > > On Mon, Dec 18, 2017 at 10:28:14PM +0100, wm4 wrote:  
> > > > On Mon, 18 Dec 2017 22:17:14 +0100
> > > > Michael Niedermayer  wrote:
> > > > 
> > > > > On Mon, Dec 18, 2017 at 10:02:52PM +0100, wm4 wrote:
> > > > > > On Mon, 18 Dec 2017 21:38:24 +0100
> > > > > > Michael Niedermayer  wrote:
> > > > > >   
> > > > > > > On Mon, Dec 18, 2017 at 04:56:08PM -0300, James Almer wrote:  
> > > > > > > > On 12/18/2017 4:52 PM, wm4 wrote:
> > > > > > > > > On Fri, 15 Dec 2017 14:24:17 -0800
> > > > > > > > > Jacob Trimble  wrote:
> > > > > > > > > 
> > > > > > > > >> From a1b2cbcb7da4da69685f8f1299b70b672ce448e3 Mon Sep 17 
> > > > > > > > >> 00:00:00 2001
> > > > > > > > >> From: Jacob Trimble 
> > > > > > > > >> Date: Tue, 5 Dec 2017 14:52:22 -0800
> > > > > > > > >> Subject: [PATCH] avcodec/avcodec.h: Add encryption info side 
> > > > > > > > >> data.
> > > > > > > > >>
> > > > > > > > >> This new side-data will contain info on how a packet is 
> > > > > > > > >> encrypted.
> > > > > > > > >> This allows the app to handle packet decryption.  To allow 
> > > > > > > > >> for a
> > > > > > > > >> variable number of subsamples, the buffer for the side-data 
> > > > > > > > >> will be
> > > > > > > > >> allocated to hold both the structure and the array of 
> > > > > > > > >> subsamples.  So
> > > > > > > > >> the |subsamples| member will point to right after the struct.
> > > > > > > > >>
> > > > > > > > >> Signed-off-by: Jacob Trimble 
> > > > > > > > >> ---
> > > > > > > > >>  libavcodec/avcodec.h | 70 
> > > > > > > > >> 
> > > > > > > > >>  1 file changed, 70 insertions(+)
> > > > > > > > >>
> > > > > > > > >> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > > > > > > > >> index 5db6a81320..ccc89345e8 100644
> > > > > > > > >> --- a/libavcodec/avcodec.h
> > > > > > > > >> +++ b/libavcodec/avcodec.h
> > > > > > > > >> @@ -1112,6 +1112,63 @@ typedef struct AVCPBProperties {
> > > > > > > > >>  uint64_t vbv_delay;
> > > > > > > > >>  } AVCPBProperties;
> > > > > > > > >>  
> > > > > > > > >> +typedef struct AVPacketSubsampleEncryptionInfo {
> > > > > > > > >> +/** The number of bytes that are clear. */
> > > > > > > > >> +unsigned int bytes_of_clear_data;
> > > > > > > > >> +
> > > > > > > > >> +/**
> > > > > > > > >> + * The number of bytes that are protected.  If using 
> > > > > > > > >> pattern encryption,
> > > > > > > > >> + * the pattern applies to only the protected bytes; if 
> > > > > > > > >> not using pattern
> > > > > > > > >> + * encryption, all these bytes are encrypted.
> > > > > > > > >> + */
> > > > > > > > >> +unsigned int bytes_of_protected_data;
> > > > > > > > >> +} AVPacketSubsampleEncryptionInfo;
> > > > > > > > >> +
> > > > > > > > >> +/**
> > > > > > > > >> + * This describes encryption info for a packet.  This 
> > > > > > > > >> contains frame-specific
> > > > > > > > >> + * info for how to decrypt the packet before passing it to 
> > > > > > > > >> the decoder.  If this
> > > > > > > > >> + * side-data is present, then the packet is encrypted.
> > > > > > > > >> + */
> > > > > > > > >> +typedef struct AVPacketEncryptionInfo {
> > > > > > > > >> +/** The fourcc encryption scheme. */
> > > > > > > > >> +uint32_t scheme;
> > > > > > > > >> +
> > > > > > > > >> +/** The ID of the key used to encrypt the packet. */
> > > > > > > > >> +uint8_t key_id[16];
> > > > > > > > >> +
> > > > > > > > >> +/** The initialization vector. */
> > > > > > > > >> +uint8_t iv[16];
> > > > > > > > >> +
> > > > > > > > >> +/**
> > > > > > > > >> + * Only used for pattern encryption.  This is the 
> > > > > > > > >> number of 16-byte blocks
> > > > > > > > >> + * that are encrypted.
> > > > > > > > >> + */
> > > > > > > > >> +unsigned int crypt_byte_block;
> > > > > > > > >> +
> > > > > > > > >> +/**
> > > > > > > > >> + * Only used for pattern encryption.  This is the 
> > > > > > > > >> number of 16-byte blocks
> > > > > > > > >> + * that are clear.
> > > > > > > > >> + */
> > > > > > > > >> +unsigned int skip_byte_block;
> > > > > > > > >> +
> > > > > > > > >> +/**
> > > > > > > > >> + * The number of sub-samples in this packet.  If 0, 
> > > > > > > > >> then the whole sample
> > > > > > > > >> + * is encrypted.
> > > > > > > > >> + */
> > > > > > > > >> +unsigned int subsample_count;
> > > > > > > > >> +
> > > > > > > > >> +/** The subsample encryption info. */
> > > > > > > > >> +AVPacketSubsampleEncryptionInfo 

Re: [FFmpeg-devel] [RFC] avcodec/avcodec.h: Add encryption info side data

2017-12-18 Thread Michael Niedermayer
On Tue, Dec 19, 2017 at 12:17:11AM +0100, wm4 wrote:
> On Tue, 19 Dec 2017 00:00:15 +0100
> Michael Niedermayer  wrote:
> 
> > On Mon, Dec 18, 2017 at 10:28:14PM +0100, wm4 wrote:
> > > On Mon, 18 Dec 2017 22:17:14 +0100
> > > Michael Niedermayer  wrote:
> > >   
> > > > On Mon, Dec 18, 2017 at 10:02:52PM +0100, wm4 wrote:  
> > > > > On Mon, 18 Dec 2017 21:38:24 +0100
> > > > > Michael Niedermayer  wrote:
> > > > > 
> > > > > > On Mon, Dec 18, 2017 at 04:56:08PM -0300, James Almer wrote:
> > > > > > > On 12/18/2017 4:52 PM, wm4 wrote:  
> > > > > > > > On Fri, 15 Dec 2017 14:24:17 -0800
> > > > > > > > Jacob Trimble  wrote:
> > > > > > > >   
> > > > > > > >> From a1b2cbcb7da4da69685f8f1299b70b672ce448e3 Mon Sep 17 
> > > > > > > >> 00:00:00 2001
> > > > > > > >> From: Jacob Trimble 
> > > > > > > >> Date: Tue, 5 Dec 2017 14:52:22 -0800
> > > > > > > >> Subject: [PATCH] avcodec/avcodec.h: Add encryption info side 
> > > > > > > >> data.
> > > > > > > >>
> > > > > > > >> This new side-data will contain info on how a packet is 
> > > > > > > >> encrypted.
> > > > > > > >> This allows the app to handle packet decryption.  To allow for 
> > > > > > > >> a
> > > > > > > >> variable number of subsamples, the buffer for the side-data 
> > > > > > > >> will be
> > > > > > > >> allocated to hold both the structure and the array of 
> > > > > > > >> subsamples.  So
> > > > > > > >> the |subsamples| member will point to right after the struct.
> > > > > > > >>
> > > > > > > >> Signed-off-by: Jacob Trimble 
> > > > > > > >> ---
> > > > > > > >>  libavcodec/avcodec.h | 70 
> > > > > > > >> 
> > > > > > > >>  1 file changed, 70 insertions(+)
> > > > > > > >>
> > > > > > > >> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > > > > > > >> index 5db6a81320..ccc89345e8 100644
> > > > > > > >> --- a/libavcodec/avcodec.h
> > > > > > > >> +++ b/libavcodec/avcodec.h
> > > > > > > >> @@ -1112,6 +1112,63 @@ typedef struct AVCPBProperties {
> > > > > > > >>  uint64_t vbv_delay;
> > > > > > > >>  } AVCPBProperties;
> > > > > > > >>  
> > > > > > > >> +typedef struct AVPacketSubsampleEncryptionInfo {
> > > > > > > >> +/** The number of bytes that are clear. */
> > > > > > > >> +unsigned int bytes_of_clear_data;
> > > > > > > >> +
> > > > > > > >> +/**
> > > > > > > >> + * The number of bytes that are protected.  If using 
> > > > > > > >> pattern encryption,
> > > > > > > >> + * the pattern applies to only the protected bytes; if 
> > > > > > > >> not using pattern
> > > > > > > >> + * encryption, all these bytes are encrypted.
> > > > > > > >> + */
> > > > > > > >> +unsigned int bytes_of_protected_data;
> > > > > > > >> +} AVPacketSubsampleEncryptionInfo;
> > > > > > > >> +
> > > > > > > >> +/**
> > > > > > > >> + * This describes encryption info for a packet.  This 
> > > > > > > >> contains frame-specific
> > > > > > > >> + * info for how to decrypt the packet before passing it to 
> > > > > > > >> the decoder.  If this
> > > > > > > >> + * side-data is present, then the packet is encrypted.
> > > > > > > >> + */
> > > > > > > >> +typedef struct AVPacketEncryptionInfo {
> > > > > > > >> +/** The fourcc encryption scheme. */
> > > > > > > >> +uint32_t scheme;
> > > > > > > >> +
> > > > > > > >> +/** The ID of the key used to encrypt the packet. */
> > > > > > > >> +uint8_t key_id[16];
> > > > > > > >> +
> > > > > > > >> +/** The initialization vector. */
> > > > > > > >> +uint8_t iv[16];
> > > > > > > >> +
> > > > > > > >> +/**
> > > > > > > >> + * Only used for pattern encryption.  This is the number 
> > > > > > > >> of 16-byte blocks
> > > > > > > >> + * that are encrypted.
> > > > > > > >> + */
> > > > > > > >> +unsigned int crypt_byte_block;
> > > > > > > >> +
> > > > > > > >> +/**
> > > > > > > >> + * Only used for pattern encryption.  This is the number 
> > > > > > > >> of 16-byte blocks
> > > > > > > >> + * that are clear.
> > > > > > > >> + */
> > > > > > > >> +unsigned int skip_byte_block;
> > > > > > > >> +
> > > > > > > >> +/**
> > > > > > > >> + * The number of sub-samples in this packet.  If 0, then 
> > > > > > > >> the whole sample
> > > > > > > >> + * is encrypted.
> > > > > > > >> + */
> > > > > > > >> +unsigned int subsample_count;
> > > > > > > >> +
> > > > > > > >> +/** The subsample encryption info. */
> > > > > > > >> +AVPacketSubsampleEncryptionInfo *subsamples;  
> > > > > > > > 
> > > > > > > > I don't think this is sane. So far, side data could simply be 
> > > > > > > > copied
> > > > > > > > with memcpy, and having pointers to non-static data in side 
> > > > > > > > data would
> > > > > > > > break this completely.  
> > > > > > > 
> > > > > 

Re: [FFmpeg-devel] [PATCH] tests/fate/mov: Disable fate-mov-invalid-elst-entry-count, the test does not work reliable currently

2017-12-18 Thread Sasi Inguva
i was on vacation so I missed this. sorry for the trouble and thanks for
fixing the test. This test was fixed once before
http://git.videolan.org/?p=ffmpeg.git;a=commitdiff;h=4ccc1ef2a3b1a22d849861423df830e110c9a4ab
.  I've no idea why only this test needs to have the "-flags +bitexact
-idct simple" while the other tests are fine.  I've used the same file as
the other tests, but just changed the Entry count atom using an Atom editor.

On Tue, Dec 5, 2017 at 4:12 PM, Michael Niedermayer 
wrote:

> On Tue, Dec 05, 2017 at 08:17:14PM +, Derek Buitenhuis wrote:
> > >> The commit that broke it should be reverted until the author
> > >> of that commit can explain why it changed, or fix it.
> > >
> > > The commit that added the test was the one that broke fate. It never
> > > worked.
> > > So this "sort of" reverts what caused the issue.
> >
> > Wasn't the code it tests added directly before the commit that added this
> > test? That's the code that is broken.
> >
> > The way I see it, the code is  workaround for broken files, but it
> doesn't
> > actually work. It should either be fixed, or the workaround removed if
> > nobody (especially the author) is willing to fix it.
>
> The test produces different output on qemu arm and x86-64.
> From this we know there is a bug, but not where the bug is.
> It can be in the test, the newly added code tested or code that was
> there before.
>
> My guess was, its the test, i cannot logically explain why.
>
> ive looked into this now and its missing -idct, adding that makes it
> produce the same result here
>
> ill push a fix for this
>
> thanks
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> There will always be a question for which you do not know the correct
> answer.
>
> ___
> 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] libvmaf: exit gracefully if the library fails.

2017-12-18 Thread Carl Eugen Hoyos
2017-12-19 0:49 GMT+01:00 Ronald S. Bultje :
> Hi,
>
> On Mon, Dec 18, 2017 at 6:31 PM, Carl Eugen Hoyos 
> wrote:
>
>> 2017-12-18 14:00 GMT+01:00 Ronald S. Bultje :
>> > Hi,
>> >
>> > On Mon, Dec 18, 2017 at 12:28 AM, Gyan Doshi wrote:
>> >
>> >> Hi Ronald,
>> >>
>> >> When do you expect to apply this?
>>
>> > Oops, forgot; pushed.
>>
>> Sorry if my email was really so unclear!
>>
>> Even by my (low) standards, this patch was horrible and should
>> not have been committed, sorry if you disagree and sorry if you
>> believe I didn't make this clear in my first email.
>>
>> Please fix this mess, see #6921.
>>
>> Thank you, Carl Eugen
>>
>
> Please keep discussions on the list.
>
> I've mentioned (in my earlier email) that this could indeed use a version
> bump in libvmaf. If #6921 is related to this patch, updating libvmaf would
> probably be the correct solution both before and after such a version bump.

How is this related to the missing configure check?

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


Re: [FFmpeg-devel] [PATCH] libvmaf: exit gracefully if the library fails.

2017-12-18 Thread Ronald S. Bultje
Hi,

On Mon, Dec 18, 2017 at 6:31 PM, Carl Eugen Hoyos 
wrote:

> 2017-12-18 14:00 GMT+01:00 Ronald S. Bultje :
> > Hi,
> >
> > On Mon, Dec 18, 2017 at 12:28 AM, Gyan Doshi wrote:
> >
> >> Hi Ronald,
> >>
> >> When do you expect to apply this?
>
> > Oops, forgot; pushed.
>
> Sorry if my email was really so unclear!
>
> Even by my (low) standards, this patch was horrible and should
> not have been committed, sorry if you disagree and sorry if you
> believe I didn't make this clear in my first email.
>
> Please fix this mess, see #6921.
>
> Thank you, Carl Eugen
>

Please keep discussions on the list.

I've mentioned (in my earlier email) that this could indeed use a version
bump in libvmaf. If #6921 is related to this patch, updating libvmaf would
probably be the correct solution both before and after such a version bump.

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


Re: [FFmpeg-devel] [RFC] avcodec/avcodec.h: Add encryption info side data

2017-12-18 Thread wm4
On Tue, 19 Dec 2017 00:36:36 +0100
Carl Eugen Hoyos  wrote:

> 2017-12-19 0:17 GMT+01:00 wm4 :
> 
> [...]
> 
> Instead of sending random insults, could you just go away?

Why don't you follow your own advice? At this point you're acting like
a miserable troll who has absolutely nothing to contribute.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavf/mov.c: Guess video codec delay based on PTS while parsing MOV header.

2017-12-18 Thread Sasi Inguva
Signed-off-by: Sasi Inguva 
---
 libavformat/mov.c| 56 
 tests/fate/mov.mak   |  7 +
 tests/ref/fate/mov-guess-delay-1 |  3 +++
 tests/ref/fate/mov-guess-delay-2 |  3 +++
 tests/ref/fate/mov-guess-delay-3 |  3 +++
 5 files changed, 72 insertions(+)
 create mode 100644 tests/ref/fate/mov-guess-delay-1
 create mode 100644 tests/ref/fate/mov-guess-delay-2
 create mode 100644 tests/ref/fate/mov-guess-delay-3

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 28d60289aa..480e506370 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3241,6 +3241,60 @@ static int64_t add_ctts_entry(MOVStts** ctts_data, 
unsigned int* ctts_count, uns
 return *ctts_count;
 }
 
+#define MAX_REORDER_DELAY 16
+static void mov_estimate_video_delay(MOVContext *c, AVStream* st) {
+MOVStreamContext *msc = st->priv_data;
+int ind;
+int ctts_ind = 0;
+int ctts_sample = 0;
+int64_t pts_buf[MAX_REORDER_DELAY + 1]; // Circular buffer to sort pts.
+int buf_start = 0;
+int buf_size = 0;
+int j, r, num_swaps;
+
+if (st->codecpar->video_delay <= 0 && msc->ctts_data &&
+st->codecpar->codec_id == AV_CODEC_ID_H264) {
+st->codecpar->video_delay = 0;
+for(ind = 0; ind < st->nb_index_entries && ctts_ind < msc->ctts_count; 
++ind) {
+if (buf_size == (MAX_REORDER_DELAY + 1)) {
+// If circular buffer is full, then move the first element 
forward.
+buf_start = (buf_start + 1) % buf_size;
+} else {
+++buf_size;
+}
+
+// Point j to the last elem of the buffer and insert the current 
pts there.
+j = (buf_start + buf_size - 1) % buf_size;
+pts_buf[j] = st->index_entries[ind].timestamp + 
msc->ctts_data[ctts_ind].duration;
+
+// The timestamps that are already in the sorted buffer, and are 
greater than the
+// current pts, are exactly the timestamps that need to be 
buffered to output PTS
+// in correct sorted order.
+// Hence the video delay (which is the buffer size used to sort 
DTS and output PTS),
+// can be computed as the maximum no. of swaps any particular 
timestamp needs to
+// go through, to keep this buffer in sorted order.
+num_swaps = 0;
+while (j != buf_start) {
+r = (j - 1 + buf_size) % buf_size;
+if (pts_buf[j] < pts_buf[r]) {
+FFSWAP(int64_t, pts_buf[j], pts_buf[r]);
+++num_swaps;
+}
+j = r;
+}
+st->codecpar->video_delay = FFMAX(st->codecpar->video_delay, 
num_swaps);
+
+ctts_sample++;
+if (ctts_sample == msc->ctts_data[ctts_ind].count) {
+ctts_ind++;
+ctts_sample = 0;
+}
+}
+av_log(c->fc, AV_LOG_DEBUG, "Setting codecpar->delay to %d for stream 
st: %d\n",
+   st->codecpar->video_delay, st->index);
+}
+}
+
 static void mov_current_sample_inc(MOVStreamContext *sc)
 {
 sc->current_sample++;
@@ -3897,6 +3951,8 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
 // Fix index according to edit lists.
 mov_fix_index(mov, st);
 }
+
+mov_estimate_video_delay(mov, st);
 }
 
 static int test_same_origin(const char *src, const char *ref) {
diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index 19b01304fb..b37ba0e3aa 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -13,6 +13,9 @@ FATE_MOV = fate-mov-3elist \
fate-mov-elst-ends-betn-b-and-i \
fate-mov-frag-overlap \
fate-mov-bbi-elst-starts-b \
+   fate-mov-guess-delay-1 \
+   fate-mov-guess-delay-2 \
+   fate-mov-guess-delay-3 \
 
 FATE_MOV_FFPROBE = fate-mov-aac-2048-priming \
fate-mov-zombie \
@@ -82,3 +85,7 @@ fate-mov-spherical-mono: CMD = run 
ffprobe$(PROGSSUF)$(EXESUF) -show_entries str
 fate-mov-gpmf-remux: CMD = md5 -i 
$(TARGET_SAMPLES)/mov/fake-gp-media-with-real-gpmf.mp4 -map 0 -c copy -fflags 
+bitexact -f mp4
 fate-mov-gpmf-remux: CMP = oneline
 fate-mov-gpmf-remux: REF = 8f48e435ee1f6b7e173ea756141eabf3
+
+fate-mov-guess-delay-1: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries 
stream=has_b_frames -select_streams v 
$(TARGET_SAMPLES)/h264/h264_3bf_nopyramid_nobsrestriction.mp4
+fate-mov-guess-delay-2: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries 
stream=has_b_frames -select_streams v 
$(TARGET_SAMPLES)/h264/h264_3bf_pyramid_nobsrestriction.mp4
+fate-mov-guess-delay-3: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entries 
stream=has_b_frames -select_streams v 
$(TARGET_SAMPLES)/h264/h264_4bf_pyramid_nobsrestriction.mp4
\ No newline at end of file
diff --git a/tests/ref/fate/mov-guess-delay-1 b/tests/ref/fate/mov-guess-delay-1
new file mode 100644

Re: [FFmpeg-devel] [RFC] avcodec/avcodec.h: Add encryption info side data

2017-12-18 Thread Carl Eugen Hoyos
2017-12-19 0:17 GMT+01:00 wm4 :

[...]

Instead of sending random insults, could you just go away?

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


Re: [FFmpeg-devel] [RFC] avcodec/avcodec.h: Add encryption info side data

2017-12-18 Thread Ronald S. Bultje
Hi,

On Mon, Dec 18, 2017 at 6:00 PM, Michael Niedermayer  wrote:

> If you decode this again you need the side data in the format of the
> platform
> the decoder runs on. This is very very basic logic. Something must convert
> it


Right, this concept is typically called a "serializer" and "deserializer".
Adding them to the API is a good idea. But I don't understand why we'd want
to store side-data as binary (platform-independent) data, that would ruin
it accessibility from applications. Applications don't want to call hton or
ntoh on each structure member they access, right?

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


Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Guess video codec delay based on PTS while parsing MOV header.

2017-12-18 Thread Sasi Inguva
Sorry for getting back so late as I was on vacation. Submitting the patch
again. This time I compute the delay exactly using a 17 element circular
buffer to sort the timestamps. PTAL.

On Wed, Nov 22, 2017 at 4:43 AM, Michael Niedermayer  wrote:

> On Wed, Nov 22, 2017 at 01:21:45PM +0530, Sasi Inguva wrote:
> > I was just shooting for a heuristic which works for most of the cases.
>
> I do not think a heuristic is a good idea. Its not very hard to
> compute this exactly. You just reorder using a 16 entry buffer and
> keep track of what the largest size was that was actually needed.
>
> Or a buffer that is increased in size whenever it would lead to
> out of order output
>
>
>
> [...]
>
> > I can build a better heuristic by finding the  frame with next min. PTS
> > after Pmin and computing the distance between that frame and Pmin.
> However
> > that will still fail for this example,
> >  0, 3, 5, 1, 4, 2 . The delay computed will be 2 (because 2 frames
> between
> > 0 and 1 ) but we need a buffer size of 3 .
> >
> > On Wed, Nov 22, 2017 at 8:29 AM, Michael Niedermayer
>  > > wrote:
> >
> > > On Mon, Nov 20, 2017 at 08:27:05PM -0800, Sasi Inguva wrote:
> > > > Signed-off-by: Sasi Inguva 
> > > > ---
> > > >  libavformat/mov.c| 50 ++
> > > ++
> > > >  tests/fate/mov.mak   |  7 ++
> > > >  tests/ref/fate/mov-guess-delay-1 |  3 +++
> > > >  tests/ref/fate/mov-guess-delay-2 |  3 +++
> > > >  tests/ref/fate/mov-guess-delay-3 |  3 +++
> > > >  5 files changed, 66 insertions(+)
> > > >  create mode 100644 tests/ref/fate/mov-guess-delay-1
> > > >  create mode 100644 tests/ref/fate/mov-guess-delay-2
> > > >  create mode 100644 tests/ref/fate/mov-guess-delay-3
> > > >
> > > > diff --git a/libavformat/mov.c b/libavformat/mov.c
> > > > index fd170baa57..afb0d4ca5c 100644
> > > > --- a/libavformat/mov.c
> > > > +++ b/libavformat/mov.c
> > > > @@ -3213,6 +3213,54 @@ static int64_t add_ctts_entry(MOVStts**
> > > ctts_data, unsigned int* ctts_count, uns
> > > >  return *ctts_count;
> > > >  }
> > > >
> > > > +static void mov_guess_video_delay(MOVContext *c, AVStream* st) {
> > > > +MOVStreamContext *msc = st->priv_data;
> > > > +int ind;
> > > > +int ctts_ind = 0;
> > > > +int ctts_sample = 0;
> > > > +int64_t curr_pts = AV_NOPTS_VALUE;
> > > > +int64_t min_prev_pts = AV_NOPTS_VALUE;
> > > > +int64_t prev_max_pts = AV_NOPTS_VALUE;
> > > > +int num_steps = 0;
> > > > +
> > > > +if (st->codecpar->video_delay <= 0 && msc->ctts_data &&
> > > > +st->codecpar->codec_id == AV_CODEC_ID_H264) {
> > > > +st->codecpar->video_delay = 0;
> > > > +for(ind = 0; ind < st->nb_index_entries && ctts_ind <
> > > msc->ctts_count; ++ind) {
> > > > +curr_pts = st->index_entries[ind].timestamp +
> > > msc->ctts_data[ctts_ind].duration;
> > > > +
> > > > +// Everytime we encounter a new max_pts we reset
> num_steps
> > > and compute again.
> > > > +if (curr_pts > prev_max_pts) {
> > > > +st->codecpar->video_delay =
> FFMIN(FFMAX(st->codecpar->video_delay,
> > > num_steps), 16);
> > > > +num_steps = 0;
> > > > +prev_max_pts = curr_pts;
> > > > +min_prev_pts = curr_pts;
> > > > +} else {
> > > > +// Compute delay as the length of the path from max
> PTS
> > > to min PTS.
> > > > +// Frames: I0 I1 B0 B1 B2
> > > > +// PTS: 0  4  1  2  3 -> num_steps = delay = 1
> > > (4->1)
> > > > +//
> > > > +// Frames: I0 I1 B1 B0 B2
> > > > +// PTS: 0  4  2  1  3 -> num_steps = delay = 2
> > > (4->2, 2->1)
> > > > +if (min_prev_pts != AV_NOPTS_VALUE) {
> > > > +if (curr_pts < min_prev_pts) {
> > > > +++num_steps;
> > > > +min_prev_pts = curr_pts;
> > > > +}
> > > > +}
> > > > +}
> > >
> > > Can you explain why this algorithm is correct ?
> > > (iam asking as i suspect it is not correct, but i may be wrong)
> > >
> > > What this should do is find the minimum buffer size to sort the stream
> > > of frame timestamps.
> > >
> > >
> > > [...]
> > > --
> > > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC7
> 87040B0FAB
> > >
> > > Its not that you shouldnt use gotos but rather that you should write
> > > readable code and code with gotos often but not always is less readable
> > >
> > > ___
> > > 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] [RFC] avcodec/avcodec.h: Add encryption info side data

2017-12-18 Thread wm4
On Tue, 19 Dec 2017 00:00:15 +0100
Michael Niedermayer  wrote:

> On Mon, Dec 18, 2017 at 10:28:14PM +0100, wm4 wrote:
> > On Mon, 18 Dec 2017 22:17:14 +0100
> > Michael Niedermayer  wrote:
> >   
> > > On Mon, Dec 18, 2017 at 10:02:52PM +0100, wm4 wrote:  
> > > > On Mon, 18 Dec 2017 21:38:24 +0100
> > > > Michael Niedermayer  wrote:
> > > > 
> > > > > On Mon, Dec 18, 2017 at 04:56:08PM -0300, James Almer wrote:
> > > > > > On 12/18/2017 4:52 PM, wm4 wrote:  
> > > > > > > On Fri, 15 Dec 2017 14:24:17 -0800
> > > > > > > Jacob Trimble  wrote:
> > > > > > >   
> > > > > > >> From a1b2cbcb7da4da69685f8f1299b70b672ce448e3 Mon Sep 17 
> > > > > > >> 00:00:00 2001
> > > > > > >> From: Jacob Trimble 
> > > > > > >> Date: Tue, 5 Dec 2017 14:52:22 -0800
> > > > > > >> Subject: [PATCH] avcodec/avcodec.h: Add encryption info side 
> > > > > > >> data.
> > > > > > >>
> > > > > > >> This new side-data will contain info on how a packet is 
> > > > > > >> encrypted.
> > > > > > >> This allows the app to handle packet decryption.  To allow for a
> > > > > > >> variable number of subsamples, the buffer for the side-data will 
> > > > > > >> be
> > > > > > >> allocated to hold both the structure and the array of 
> > > > > > >> subsamples.  So
> > > > > > >> the |subsamples| member will point to right after the struct.
> > > > > > >>
> > > > > > >> Signed-off-by: Jacob Trimble 
> > > > > > >> ---
> > > > > > >>  libavcodec/avcodec.h | 70 
> > > > > > >> 
> > > > > > >>  1 file changed, 70 insertions(+)
> > > > > > >>
> > > > > > >> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > > > > > >> index 5db6a81320..ccc89345e8 100644
> > > > > > >> --- a/libavcodec/avcodec.h
> > > > > > >> +++ b/libavcodec/avcodec.h
> > > > > > >> @@ -1112,6 +1112,63 @@ typedef struct AVCPBProperties {
> > > > > > >>  uint64_t vbv_delay;
> > > > > > >>  } AVCPBProperties;
> > > > > > >>  
> > > > > > >> +typedef struct AVPacketSubsampleEncryptionInfo {
> > > > > > >> +/** The number of bytes that are clear. */
> > > > > > >> +unsigned int bytes_of_clear_data;
> > > > > > >> +
> > > > > > >> +/**
> > > > > > >> + * The number of bytes that are protected.  If using 
> > > > > > >> pattern encryption,
> > > > > > >> + * the pattern applies to only the protected bytes; if not 
> > > > > > >> using pattern
> > > > > > >> + * encryption, all these bytes are encrypted.
> > > > > > >> + */
> > > > > > >> +unsigned int bytes_of_protected_data;
> > > > > > >> +} AVPacketSubsampleEncryptionInfo;
> > > > > > >> +
> > > > > > >> +/**
> > > > > > >> + * This describes encryption info for a packet.  This contains 
> > > > > > >> frame-specific
> > > > > > >> + * info for how to decrypt the packet before passing it to the 
> > > > > > >> decoder.  If this
> > > > > > >> + * side-data is present, then the packet is encrypted.
> > > > > > >> + */
> > > > > > >> +typedef struct AVPacketEncryptionInfo {
> > > > > > >> +/** The fourcc encryption scheme. */
> > > > > > >> +uint32_t scheme;
> > > > > > >> +
> > > > > > >> +/** The ID of the key used to encrypt the packet. */
> > > > > > >> +uint8_t key_id[16];
> > > > > > >> +
> > > > > > >> +/** The initialization vector. */
> > > > > > >> +uint8_t iv[16];
> > > > > > >> +
> > > > > > >> +/**
> > > > > > >> + * Only used for pattern encryption.  This is the number of 
> > > > > > >> 16-byte blocks
> > > > > > >> + * that are encrypted.
> > > > > > >> + */
> > > > > > >> +unsigned int crypt_byte_block;
> > > > > > >> +
> > > > > > >> +/**
> > > > > > >> + * Only used for pattern encryption.  This is the number of 
> > > > > > >> 16-byte blocks
> > > > > > >> + * that are clear.
> > > > > > >> + */
> > > > > > >> +unsigned int skip_byte_block;
> > > > > > >> +
> > > > > > >> +/**
> > > > > > >> + * The number of sub-samples in this packet.  If 0, then 
> > > > > > >> the whole sample
> > > > > > >> + * is encrypted.
> > > > > > >> + */
> > > > > > >> +unsigned int subsample_count;
> > > > > > >> +
> > > > > > >> +/** The subsample encryption info. */
> > > > > > >> +AVPacketSubsampleEncryptionInfo *subsamples;  
> > > > > > > 
> > > > > > > I don't think this is sane. So far, side data could simply be 
> > > > > > > copied
> > > > > > > with memcpy, and having pointers to non-static data in side data 
> > > > > > > would
> > > > > > > break this completely.  
> > > > > > 
> > > > > > Even more reasons to ditch the current side data API and come up 
> > > > > > with a
> > > > > > better designed one that can also be reused for packet, frame and
> > > > > > container needs.  
> > > > > 
> > > > > yes, 
> > > > > also if its redesigned, it should become 

Re: [FFmpeg-devel] [RFC] avcodec/avcodec.h: Add encryption info side data

2017-12-18 Thread Michael Niedermayer
On Mon, Dec 18, 2017 at 10:28:14PM +0100, wm4 wrote:
> On Mon, 18 Dec 2017 22:17:14 +0100
> Michael Niedermayer  wrote:
> 
> > On Mon, Dec 18, 2017 at 10:02:52PM +0100, wm4 wrote:
> > > On Mon, 18 Dec 2017 21:38:24 +0100
> > > Michael Niedermayer  wrote:
> > >   
> > > > On Mon, Dec 18, 2017 at 04:56:08PM -0300, James Almer wrote:  
> > > > > On 12/18/2017 4:52 PM, wm4 wrote:
> > > > > > On Fri, 15 Dec 2017 14:24:17 -0800
> > > > > > Jacob Trimble  wrote:
> > > > > > 
> > > > > >> From a1b2cbcb7da4da69685f8f1299b70b672ce448e3 Mon Sep 17 00:00:00 
> > > > > >> 2001
> > > > > >> From: Jacob Trimble 
> > > > > >> Date: Tue, 5 Dec 2017 14:52:22 -0800
> > > > > >> Subject: [PATCH] avcodec/avcodec.h: Add encryption info side data.
> > > > > >>
> > > > > >> This new side-data will contain info on how a packet is encrypted.
> > > > > >> This allows the app to handle packet decryption.  To allow for a
> > > > > >> variable number of subsamples, the buffer for the side-data will be
> > > > > >> allocated to hold both the structure and the array of subsamples.  
> > > > > >> So
> > > > > >> the |subsamples| member will point to right after the struct.
> > > > > >>
> > > > > >> Signed-off-by: Jacob Trimble 
> > > > > >> ---
> > > > > >>  libavcodec/avcodec.h | 70 
> > > > > >> 
> > > > > >>  1 file changed, 70 insertions(+)
> > > > > >>
> > > > > >> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > > > > >> index 5db6a81320..ccc89345e8 100644
> > > > > >> --- a/libavcodec/avcodec.h
> > > > > >> +++ b/libavcodec/avcodec.h
> > > > > >> @@ -1112,6 +1112,63 @@ typedef struct AVCPBProperties {
> > > > > >>  uint64_t vbv_delay;
> > > > > >>  } AVCPBProperties;
> > > > > >>  
> > > > > >> +typedef struct AVPacketSubsampleEncryptionInfo {
> > > > > >> +/** The number of bytes that are clear. */
> > > > > >> +unsigned int bytes_of_clear_data;
> > > > > >> +
> > > > > >> +/**
> > > > > >> + * The number of bytes that are protected.  If using pattern 
> > > > > >> encryption,
> > > > > >> + * the pattern applies to only the protected bytes; if not 
> > > > > >> using pattern
> > > > > >> + * encryption, all these bytes are encrypted.
> > > > > >> + */
> > > > > >> +unsigned int bytes_of_protected_data;
> > > > > >> +} AVPacketSubsampleEncryptionInfo;
> > > > > >> +
> > > > > >> +/**
> > > > > >> + * This describes encryption info for a packet.  This contains 
> > > > > >> frame-specific
> > > > > >> + * info for how to decrypt the packet before passing it to the 
> > > > > >> decoder.  If this
> > > > > >> + * side-data is present, then the packet is encrypted.
> > > > > >> + */
> > > > > >> +typedef struct AVPacketEncryptionInfo {
> > > > > >> +/** The fourcc encryption scheme. */
> > > > > >> +uint32_t scheme;
> > > > > >> +
> > > > > >> +/** The ID of the key used to encrypt the packet. */
> > > > > >> +uint8_t key_id[16];
> > > > > >> +
> > > > > >> +/** The initialization vector. */
> > > > > >> +uint8_t iv[16];
> > > > > >> +
> > > > > >> +/**
> > > > > >> + * Only used for pattern encryption.  This is the number of 
> > > > > >> 16-byte blocks
> > > > > >> + * that are encrypted.
> > > > > >> + */
> > > > > >> +unsigned int crypt_byte_block;
> > > > > >> +
> > > > > >> +/**
> > > > > >> + * Only used for pattern encryption.  This is the number of 
> > > > > >> 16-byte blocks
> > > > > >> + * that are clear.
> > > > > >> + */
> > > > > >> +unsigned int skip_byte_block;
> > > > > >> +
> > > > > >> +/**
> > > > > >> + * The number of sub-samples in this packet.  If 0, then the 
> > > > > >> whole sample
> > > > > >> + * is encrypted.
> > > > > >> + */
> > > > > >> +unsigned int subsample_count;
> > > > > >> +
> > > > > >> +/** The subsample encryption info. */
> > > > > >> +AVPacketSubsampleEncryptionInfo *subsamples;
> > > > > > 
> > > > > > I don't think this is sane. So far, side data could simply be copied
> > > > > > with memcpy, and having pointers to non-static data in side data 
> > > > > > would
> > > > > > break this completely.
> > > > > 
> > > > > Even more reasons to ditch the current side data API and come up with 
> > > > > a
> > > > > better designed one that can also be reused for packet, frame and
> > > > > container needs.
> > > > 
> > > > yes, 
> > > > also if its redesigned, it should become possible to pass it over the
> > > > network. Currently all side data depends on the platform ABI, so its
> > > > only valid on the platform its created on. That also makes it different
> > > > from all other data, AVPacket.data and extradata are all
> > > > platform independant. And there is no API to
> > > > convert it into a platform ABI independant form.   
> > > 
> > > Why should 

Re: [FFmpeg-devel] [RFC] avcodec/avcodec.h: Add encryption info side data

2017-12-18 Thread wm4
On Mon, 18 Dec 2017 22:17:14 +0100
Michael Niedermayer  wrote:

> On Mon, Dec 18, 2017 at 10:02:52PM +0100, wm4 wrote:
> > On Mon, 18 Dec 2017 21:38:24 +0100
> > Michael Niedermayer  wrote:
> >   
> > > On Mon, Dec 18, 2017 at 04:56:08PM -0300, James Almer wrote:  
> > > > On 12/18/2017 4:52 PM, wm4 wrote:
> > > > > On Fri, 15 Dec 2017 14:24:17 -0800
> > > > > Jacob Trimble  wrote:
> > > > > 
> > > > >> From a1b2cbcb7da4da69685f8f1299b70b672ce448e3 Mon Sep 17 00:00:00 
> > > > >> 2001
> > > > >> From: Jacob Trimble 
> > > > >> Date: Tue, 5 Dec 2017 14:52:22 -0800
> > > > >> Subject: [PATCH] avcodec/avcodec.h: Add encryption info side data.
> > > > >>
> > > > >> This new side-data will contain info on how a packet is encrypted.
> > > > >> This allows the app to handle packet decryption.  To allow for a
> > > > >> variable number of subsamples, the buffer for the side-data will be
> > > > >> allocated to hold both the structure and the array of subsamples.  So
> > > > >> the |subsamples| member will point to right after the struct.
> > > > >>
> > > > >> Signed-off-by: Jacob Trimble 
> > > > >> ---
> > > > >>  libavcodec/avcodec.h | 70 
> > > > >> 
> > > > >>  1 file changed, 70 insertions(+)
> > > > >>
> > > > >> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > > > >> index 5db6a81320..ccc89345e8 100644
> > > > >> --- a/libavcodec/avcodec.h
> > > > >> +++ b/libavcodec/avcodec.h
> > > > >> @@ -1112,6 +1112,63 @@ typedef struct AVCPBProperties {
> > > > >>  uint64_t vbv_delay;
> > > > >>  } AVCPBProperties;
> > > > >>  
> > > > >> +typedef struct AVPacketSubsampleEncryptionInfo {
> > > > >> +/** The number of bytes that are clear. */
> > > > >> +unsigned int bytes_of_clear_data;
> > > > >> +
> > > > >> +/**
> > > > >> + * The number of bytes that are protected.  If using pattern 
> > > > >> encryption,
> > > > >> + * the pattern applies to only the protected bytes; if not 
> > > > >> using pattern
> > > > >> + * encryption, all these bytes are encrypted.
> > > > >> + */
> > > > >> +unsigned int bytes_of_protected_data;
> > > > >> +} AVPacketSubsampleEncryptionInfo;
> > > > >> +
> > > > >> +/**
> > > > >> + * This describes encryption info for a packet.  This contains 
> > > > >> frame-specific
> > > > >> + * info for how to decrypt the packet before passing it to the 
> > > > >> decoder.  If this
> > > > >> + * side-data is present, then the packet is encrypted.
> > > > >> + */
> > > > >> +typedef struct AVPacketEncryptionInfo {
> > > > >> +/** The fourcc encryption scheme. */
> > > > >> +uint32_t scheme;
> > > > >> +
> > > > >> +/** The ID of the key used to encrypt the packet. */
> > > > >> +uint8_t key_id[16];
> > > > >> +
> > > > >> +/** The initialization vector. */
> > > > >> +uint8_t iv[16];
> > > > >> +
> > > > >> +/**
> > > > >> + * Only used for pattern encryption.  This is the number of 
> > > > >> 16-byte blocks
> > > > >> + * that are encrypted.
> > > > >> + */
> > > > >> +unsigned int crypt_byte_block;
> > > > >> +
> > > > >> +/**
> > > > >> + * Only used for pattern encryption.  This is the number of 
> > > > >> 16-byte blocks
> > > > >> + * that are clear.
> > > > >> + */
> > > > >> +unsigned int skip_byte_block;
> > > > >> +
> > > > >> +/**
> > > > >> + * The number of sub-samples in this packet.  If 0, then the 
> > > > >> whole sample
> > > > >> + * is encrypted.
> > > > >> + */
> > > > >> +unsigned int subsample_count;
> > > > >> +
> > > > >> +/** The subsample encryption info. */
> > > > >> +AVPacketSubsampleEncryptionInfo *subsamples;
> > > > > 
> > > > > I don't think this is sane. So far, side data could simply be copied
> > > > > with memcpy, and having pointers to non-static data in side data would
> > > > > break this completely.
> > > > 
> > > > Even more reasons to ditch the current side data API and come up with a
> > > > better designed one that can also be reused for packet, frame and
> > > > container needs.
> > > 
> > > yes, 
> > > also if its redesigned, it should become possible to pass it over the
> > > network. Currently all side data depends on the platform ABI, so its
> > > only valid on the platform its created on. That also makes it different
> > > from all other data, AVPacket.data and extradata are all
> > > platform independant. And there is no API to
> > > convert it into a platform ABI independant form.   
> > 
> > Why should it be transferable over network? That makes no sense. We
> > don't have the ability to transfer AVFrame, AVPacket, or AVCodecContext
> > over network either.  
> 
> If you have an application that streams video, and on a different computer
> an application which plays that video you need to transfer the 

Re: [FFmpeg-devel] [RFC] avcodec/avcodec.h: Add encryption info side data

2017-12-18 Thread Michael Niedermayer
On Mon, Dec 18, 2017 at 10:02:52PM +0100, wm4 wrote:
> On Mon, 18 Dec 2017 21:38:24 +0100
> Michael Niedermayer  wrote:
> 
> > On Mon, Dec 18, 2017 at 04:56:08PM -0300, James Almer wrote:
> > > On 12/18/2017 4:52 PM, wm4 wrote:  
> > > > On Fri, 15 Dec 2017 14:24:17 -0800
> > > > Jacob Trimble  wrote:
> > > >   
> > > >> From a1b2cbcb7da4da69685f8f1299b70b672ce448e3 Mon Sep 17 00:00:00 2001
> > > >> From: Jacob Trimble 
> > > >> Date: Tue, 5 Dec 2017 14:52:22 -0800
> > > >> Subject: [PATCH] avcodec/avcodec.h: Add encryption info side data.
> > > >>
> > > >> This new side-data will contain info on how a packet is encrypted.
> > > >> This allows the app to handle packet decryption.  To allow for a
> > > >> variable number of subsamples, the buffer for the side-data will be
> > > >> allocated to hold both the structure and the array of subsamples.  So
> > > >> the |subsamples| member will point to right after the struct.
> > > >>
> > > >> Signed-off-by: Jacob Trimble 
> > > >> ---
> > > >>  libavcodec/avcodec.h | 70 
> > > >> 
> > > >>  1 file changed, 70 insertions(+)
> > > >>
> > > >> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > > >> index 5db6a81320..ccc89345e8 100644
> > > >> --- a/libavcodec/avcodec.h
> > > >> +++ b/libavcodec/avcodec.h
> > > >> @@ -1112,6 +1112,63 @@ typedef struct AVCPBProperties {
> > > >>  uint64_t vbv_delay;
> > > >>  } AVCPBProperties;
> > > >>  
> > > >> +typedef struct AVPacketSubsampleEncryptionInfo {
> > > >> +/** The number of bytes that are clear. */
> > > >> +unsigned int bytes_of_clear_data;
> > > >> +
> > > >> +/**
> > > >> + * The number of bytes that are protected.  If using pattern 
> > > >> encryption,
> > > >> + * the pattern applies to only the protected bytes; if not using 
> > > >> pattern
> > > >> + * encryption, all these bytes are encrypted.
> > > >> + */
> > > >> +unsigned int bytes_of_protected_data;
> > > >> +} AVPacketSubsampleEncryptionInfo;
> > > >> +
> > > >> +/**
> > > >> + * This describes encryption info for a packet.  This contains 
> > > >> frame-specific
> > > >> + * info for how to decrypt the packet before passing it to the 
> > > >> decoder.  If this
> > > >> + * side-data is present, then the packet is encrypted.
> > > >> + */
> > > >> +typedef struct AVPacketEncryptionInfo {
> > > >> +/** The fourcc encryption scheme. */
> > > >> +uint32_t scheme;
> > > >> +
> > > >> +/** The ID of the key used to encrypt the packet. */
> > > >> +uint8_t key_id[16];
> > > >> +
> > > >> +/** The initialization vector. */
> > > >> +uint8_t iv[16];
> > > >> +
> > > >> +/**
> > > >> + * Only used for pattern encryption.  This is the number of 
> > > >> 16-byte blocks
> > > >> + * that are encrypted.
> > > >> + */
> > > >> +unsigned int crypt_byte_block;
> > > >> +
> > > >> +/**
> > > >> + * Only used for pattern encryption.  This is the number of 
> > > >> 16-byte blocks
> > > >> + * that are clear.
> > > >> + */
> > > >> +unsigned int skip_byte_block;
> > > >> +
> > > >> +/**
> > > >> + * The number of sub-samples in this packet.  If 0, then the 
> > > >> whole sample
> > > >> + * is encrypted.
> > > >> + */
> > > >> +unsigned int subsample_count;
> > > >> +
> > > >> +/** The subsample encryption info. */
> > > >> +AVPacketSubsampleEncryptionInfo *subsamples;  
> > > > 
> > > > I don't think this is sane. So far, side data could simply be copied
> > > > with memcpy, and having pointers to non-static data in side data would
> > > > break this completely.  
> > > 
> > > Even more reasons to ditch the current side data API and come up with a
> > > better designed one that can also be reused for packet, frame and
> > > container needs.  
> > 
> > yes, 
> > also if its redesigned, it should become possible to pass it over the
> > network. Currently all side data depends on the platform ABI, so its
> > only valid on the platform its created on. That also makes it different
> > from all other data, AVPacket.data and extradata are all
> > platform independant. And there is no API to
> > convert it into a platform ABI independant form. 
> 
> Why should it be transferable over network? That makes no sense. We
> don't have the ability to transfer AVFrame, AVPacket, or AVCodecContext
> over network either.

If you have an application that streams video, and on a different computer
an application which plays that video you need to transfer the compressed
data (that is AVPackets and their side data) over the network.

You can use RT*P/hls and others but they lack the concept of our side data
so many cases will not work over such system, especially not if there is
no platform independant representation of the data which you have to
transmit between platforms.
At some point you have to 

Re: [FFmpeg-devel] [RFC] avcodec/avcodec.h: Add encryption info side data

2017-12-18 Thread wm4
On Mon, 18 Dec 2017 21:38:24 +0100
Michael Niedermayer  wrote:

> On Mon, Dec 18, 2017 at 04:56:08PM -0300, James Almer wrote:
> > On 12/18/2017 4:52 PM, wm4 wrote:  
> > > On Fri, 15 Dec 2017 14:24:17 -0800
> > > Jacob Trimble  wrote:
> > >   
> > >> From a1b2cbcb7da4da69685f8f1299b70b672ce448e3 Mon Sep 17 00:00:00 2001
> > >> From: Jacob Trimble 
> > >> Date: Tue, 5 Dec 2017 14:52:22 -0800
> > >> Subject: [PATCH] avcodec/avcodec.h: Add encryption info side data.
> > >>
> > >> This new side-data will contain info on how a packet is encrypted.
> > >> This allows the app to handle packet decryption.  To allow for a
> > >> variable number of subsamples, the buffer for the side-data will be
> > >> allocated to hold both the structure and the array of subsamples.  So
> > >> the |subsamples| member will point to right after the struct.
> > >>
> > >> Signed-off-by: Jacob Trimble 
> > >> ---
> > >>  libavcodec/avcodec.h | 70 
> > >> 
> > >>  1 file changed, 70 insertions(+)
> > >>
> > >> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> > >> index 5db6a81320..ccc89345e8 100644
> > >> --- a/libavcodec/avcodec.h
> > >> +++ b/libavcodec/avcodec.h
> > >> @@ -1112,6 +1112,63 @@ typedef struct AVCPBProperties {
> > >>  uint64_t vbv_delay;
> > >>  } AVCPBProperties;
> > >>  
> > >> +typedef struct AVPacketSubsampleEncryptionInfo {
> > >> +/** The number of bytes that are clear. */
> > >> +unsigned int bytes_of_clear_data;
> > >> +
> > >> +/**
> > >> + * The number of bytes that are protected.  If using pattern 
> > >> encryption,
> > >> + * the pattern applies to only the protected bytes; if not using 
> > >> pattern
> > >> + * encryption, all these bytes are encrypted.
> > >> + */
> > >> +unsigned int bytes_of_protected_data;
> > >> +} AVPacketSubsampleEncryptionInfo;
> > >> +
> > >> +/**
> > >> + * This describes encryption info for a packet.  This contains 
> > >> frame-specific
> > >> + * info for how to decrypt the packet before passing it to the decoder. 
> > >>  If this
> > >> + * side-data is present, then the packet is encrypted.
> > >> + */
> > >> +typedef struct AVPacketEncryptionInfo {
> > >> +/** The fourcc encryption scheme. */
> > >> +uint32_t scheme;
> > >> +
> > >> +/** The ID of the key used to encrypt the packet. */
> > >> +uint8_t key_id[16];
> > >> +
> > >> +/** The initialization vector. */
> > >> +uint8_t iv[16];
> > >> +
> > >> +/**
> > >> + * Only used for pattern encryption.  This is the number of 16-byte 
> > >> blocks
> > >> + * that are encrypted.
> > >> + */
> > >> +unsigned int crypt_byte_block;
> > >> +
> > >> +/**
> > >> + * Only used for pattern encryption.  This is the number of 16-byte 
> > >> blocks
> > >> + * that are clear.
> > >> + */
> > >> +unsigned int skip_byte_block;
> > >> +
> > >> +/**
> > >> + * The number of sub-samples in this packet.  If 0, then the whole 
> > >> sample
> > >> + * is encrypted.
> > >> + */
> > >> +unsigned int subsample_count;
> > >> +
> > >> +/** The subsample encryption info. */
> > >> +AVPacketSubsampleEncryptionInfo *subsamples;  
> > > 
> > > I don't think this is sane. So far, side data could simply be copied
> > > with memcpy, and having pointers to non-static data in side data would
> > > break this completely.  
> > 
> > Even more reasons to ditch the current side data API and come up with a
> > better designed one that can also be reused for packet, frame and
> > container needs.  
> 
> yes, 
> also if its redesigned, it should become possible to pass it over the
> network. Currently all side data depends on the platform ABI, so its
> only valid on the platform its created on. That also makes it different
> from all other data, AVPacket.data and extradata are all
> platform independant. And there is no API to
> convert it into a platform ABI independant form. 

Why should it be transferable over network? That makes no sense. We
don't have the ability to transfer AVFrame, AVPacket, or AVCodecContext
over network either.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [RFC] avcodec/avcodec.h: Add encryption info side data

2017-12-18 Thread wm4
On Mon, 18 Dec 2017 16:56:08 -0300
James Almer  wrote:

> On 12/18/2017 4:52 PM, wm4 wrote:
> > On Fri, 15 Dec 2017 14:24:17 -0800
> > Jacob Trimble  wrote:
> >   
> >> From a1b2cbcb7da4da69685f8f1299b70b672ce448e3 Mon Sep 17 00:00:00 2001
> >> From: Jacob Trimble 
> >> Date: Tue, 5 Dec 2017 14:52:22 -0800
> >> Subject: [PATCH] avcodec/avcodec.h: Add encryption info side data.
> >>
> >> This new side-data will contain info on how a packet is encrypted.
> >> This allows the app to handle packet decryption.  To allow for a
> >> variable number of subsamples, the buffer for the side-data will be
> >> allocated to hold both the structure and the array of subsamples.  So
> >> the |subsamples| member will point to right after the struct.
> >>
> >> Signed-off-by: Jacob Trimble 
> >> ---
> >>  libavcodec/avcodec.h | 70 
> >> 
> >>  1 file changed, 70 insertions(+)
> >>
> >> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> >> index 5db6a81320..ccc89345e8 100644
> >> --- a/libavcodec/avcodec.h
> >> +++ b/libavcodec/avcodec.h
> >> @@ -1112,6 +1112,63 @@ typedef struct AVCPBProperties {
> >>  uint64_t vbv_delay;
> >>  } AVCPBProperties;
> >>  
> >> +typedef struct AVPacketSubsampleEncryptionInfo {
> >> +/** The number of bytes that are clear. */
> >> +unsigned int bytes_of_clear_data;
> >> +
> >> +/**
> >> + * The number of bytes that are protected.  If using pattern 
> >> encryption,
> >> + * the pattern applies to only the protected bytes; if not using 
> >> pattern
> >> + * encryption, all these bytes are encrypted.
> >> + */
> >> +unsigned int bytes_of_protected_data;
> >> +} AVPacketSubsampleEncryptionInfo;
> >> +
> >> +/**
> >> + * This describes encryption info for a packet.  This contains 
> >> frame-specific
> >> + * info for how to decrypt the packet before passing it to the decoder.  
> >> If this
> >> + * side-data is present, then the packet is encrypted.
> >> + */
> >> +typedef struct AVPacketEncryptionInfo {
> >> +/** The fourcc encryption scheme. */
> >> +uint32_t scheme;
> >> +
> >> +/** The ID of the key used to encrypt the packet. */
> >> +uint8_t key_id[16];
> >> +
> >> +/** The initialization vector. */
> >> +uint8_t iv[16];
> >> +
> >> +/**
> >> + * Only used for pattern encryption.  This is the number of 16-byte 
> >> blocks
> >> + * that are encrypted.
> >> + */
> >> +unsigned int crypt_byte_block;
> >> +
> >> +/**
> >> + * Only used for pattern encryption.  This is the number of 16-byte 
> >> blocks
> >> + * that are clear.
> >> + */
> >> +unsigned int skip_byte_block;
> >> +
> >> +/**
> >> + * The number of sub-samples in this packet.  If 0, then the whole 
> >> sample
> >> + * is encrypted.
> >> + */
> >> +unsigned int subsample_count;
> >> +
> >> +/** The subsample encryption info. */
> >> +AVPacketSubsampleEncryptionInfo *subsamples;  
> > 
> > I don't think this is sane. So far, side data could simply be copied
> > with memcpy, and having pointers to non-static data in side data would
> > break this completely.  
> 
> Even more reasons to ditch the current side data API and come up with a
> better designed one that can also be reused for packet, frame and
> container needs.

I fully agree. But redesigning the entire side data API for such a
feature is probably a bit too much to ask. On the other hand I would
have no problem holding back such an obscure feature for a while...

On that note, I wonder if we should add an AVPacket reserved field for
this, just so we don't have to wait for the next ABI bump.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [RFC] avcodec/avcodec.h: Add encryption info side data

2017-12-18 Thread Michael Niedermayer
On Mon, Dec 18, 2017 at 04:56:08PM -0300, James Almer wrote:
> On 12/18/2017 4:52 PM, wm4 wrote:
> > On Fri, 15 Dec 2017 14:24:17 -0800
> > Jacob Trimble  wrote:
> > 
> >> From a1b2cbcb7da4da69685f8f1299b70b672ce448e3 Mon Sep 17 00:00:00 2001
> >> From: Jacob Trimble 
> >> Date: Tue, 5 Dec 2017 14:52:22 -0800
> >> Subject: [PATCH] avcodec/avcodec.h: Add encryption info side data.
> >>
> >> This new side-data will contain info on how a packet is encrypted.
> >> This allows the app to handle packet decryption.  To allow for a
> >> variable number of subsamples, the buffer for the side-data will be
> >> allocated to hold both the structure and the array of subsamples.  So
> >> the |subsamples| member will point to right after the struct.
> >>
> >> Signed-off-by: Jacob Trimble 
> >> ---
> >>  libavcodec/avcodec.h | 70 
> >> 
> >>  1 file changed, 70 insertions(+)
> >>
> >> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> >> index 5db6a81320..ccc89345e8 100644
> >> --- a/libavcodec/avcodec.h
> >> +++ b/libavcodec/avcodec.h
> >> @@ -1112,6 +1112,63 @@ typedef struct AVCPBProperties {
> >>  uint64_t vbv_delay;
> >>  } AVCPBProperties;
> >>  
> >> +typedef struct AVPacketSubsampleEncryptionInfo {
> >> +/** The number of bytes that are clear. */
> >> +unsigned int bytes_of_clear_data;
> >> +
> >> +/**
> >> + * The number of bytes that are protected.  If using pattern 
> >> encryption,
> >> + * the pattern applies to only the protected bytes; if not using 
> >> pattern
> >> + * encryption, all these bytes are encrypted.
> >> + */
> >> +unsigned int bytes_of_protected_data;
> >> +} AVPacketSubsampleEncryptionInfo;
> >> +
> >> +/**
> >> + * This describes encryption info for a packet.  This contains 
> >> frame-specific
> >> + * info for how to decrypt the packet before passing it to the decoder.  
> >> If this
> >> + * side-data is present, then the packet is encrypted.
> >> + */
> >> +typedef struct AVPacketEncryptionInfo {
> >> +/** The fourcc encryption scheme. */
> >> +uint32_t scheme;
> >> +
> >> +/** The ID of the key used to encrypt the packet. */
> >> +uint8_t key_id[16];
> >> +
> >> +/** The initialization vector. */
> >> +uint8_t iv[16];
> >> +
> >> +/**
> >> + * Only used for pattern encryption.  This is the number of 16-byte 
> >> blocks
> >> + * that are encrypted.
> >> + */
> >> +unsigned int crypt_byte_block;
> >> +
> >> +/**
> >> + * Only used for pattern encryption.  This is the number of 16-byte 
> >> blocks
> >> + * that are clear.
> >> + */
> >> +unsigned int skip_byte_block;
> >> +
> >> +/**
> >> + * The number of sub-samples in this packet.  If 0, then the whole 
> >> sample
> >> + * is encrypted.
> >> + */
> >> +unsigned int subsample_count;
> >> +
> >> +/** The subsample encryption info. */
> >> +AVPacketSubsampleEncryptionInfo *subsamples;
> > 
> > I don't think this is sane. So far, side data could simply be copied
> > with memcpy, and having pointers to non-static data in side data would
> > break this completely.
> 
> Even more reasons to ditch the current side data API and come up with a
> better designed one that can also be reused for packet, frame and
> container needs.

yes, 
also if its redesigned, it should become possible to pass it over the
network. Currently all side data depends on the platform ABI, so its
only valid on the platform its created on. That also makes it different
from all other data, AVPacket.data and extradata are all
platform independant. And there is no API to
convert it into a platform ABI independant form. 



[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Republics decline into democracies and democracies degenerate into
despotisms. -- Aristotle


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


Re: [FFmpeg-devel] [RFC] avcodec/avcodec.h: Add encryption info side data

2017-12-18 Thread James Almer
On 12/18/2017 4:52 PM, wm4 wrote:
> On Fri, 15 Dec 2017 14:24:17 -0800
> Jacob Trimble  wrote:
> 
>> From a1b2cbcb7da4da69685f8f1299b70b672ce448e3 Mon Sep 17 00:00:00 2001
>> From: Jacob Trimble 
>> Date: Tue, 5 Dec 2017 14:52:22 -0800
>> Subject: [PATCH] avcodec/avcodec.h: Add encryption info side data.
>>
>> This new side-data will contain info on how a packet is encrypted.
>> This allows the app to handle packet decryption.  To allow for a
>> variable number of subsamples, the buffer for the side-data will be
>> allocated to hold both the structure and the array of subsamples.  So
>> the |subsamples| member will point to right after the struct.
>>
>> Signed-off-by: Jacob Trimble 
>> ---
>>  libavcodec/avcodec.h | 70 
>> 
>>  1 file changed, 70 insertions(+)
>>
>> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
>> index 5db6a81320..ccc89345e8 100644
>> --- a/libavcodec/avcodec.h
>> +++ b/libavcodec/avcodec.h
>> @@ -1112,6 +1112,63 @@ typedef struct AVCPBProperties {
>>  uint64_t vbv_delay;
>>  } AVCPBProperties;
>>  
>> +typedef struct AVPacketSubsampleEncryptionInfo {
>> +/** The number of bytes that are clear. */
>> +unsigned int bytes_of_clear_data;
>> +
>> +/**
>> + * The number of bytes that are protected.  If using pattern encryption,
>> + * the pattern applies to only the protected bytes; if not using pattern
>> + * encryption, all these bytes are encrypted.
>> + */
>> +unsigned int bytes_of_protected_data;
>> +} AVPacketSubsampleEncryptionInfo;
>> +
>> +/**
>> + * This describes encryption info for a packet.  This contains 
>> frame-specific
>> + * info for how to decrypt the packet before passing it to the decoder.  If 
>> this
>> + * side-data is present, then the packet is encrypted.
>> + */
>> +typedef struct AVPacketEncryptionInfo {
>> +/** The fourcc encryption scheme. */
>> +uint32_t scheme;
>> +
>> +/** The ID of the key used to encrypt the packet. */
>> +uint8_t key_id[16];
>> +
>> +/** The initialization vector. */
>> +uint8_t iv[16];
>> +
>> +/**
>> + * Only used for pattern encryption.  This is the number of 16-byte 
>> blocks
>> + * that are encrypted.
>> + */
>> +unsigned int crypt_byte_block;
>> +
>> +/**
>> + * Only used for pattern encryption.  This is the number of 16-byte 
>> blocks
>> + * that are clear.
>> + */
>> +unsigned int skip_byte_block;
>> +
>> +/**
>> + * The number of sub-samples in this packet.  If 0, then the whole 
>> sample
>> + * is encrypted.
>> + */
>> +unsigned int subsample_count;
>> +
>> +/** The subsample encryption info. */
>> +AVPacketSubsampleEncryptionInfo *subsamples;
> 
> I don't think this is sane. So far, side data could simply be copied
> with memcpy, and having pointers to non-static data in side data would
> break this completely.

Even more reasons to ditch the current side data API and come up with a
better designed one that can also be reused for packet, frame and
container needs.

> 
>> +} AVPacketEncryptionInfo;
>> +/**
>> + * The size of the side-data for the AV_PKT_DATA_PACKET_ENCRYPTION_INFO 
>> type.
>> + * The side-data will contain the AVPacketEncryptionInfo struct followed by
>> + * the subsample array.  The subsamples member should point to after the 
>> struct
>> + * so the app can easily access it.
>> + */
>> +#define FF_PACKET_ENCRYPTION_INFO_SIZE(subsample_count) \
>> +(sizeof(AVPacketEncryptionInfo) + 
>> sizeof(AVPacketSubsampleEncryptionInfo) * subsample_count)
>> +
>>  /**
>>   * The decoder will keep a reference to the frame and may reuse it later.
>>   */
>> @@ -1327,6 +1384,19 @@ enum AVPacketSideDataType {
>>   */
>>  AV_PKT_DATA_A53_CC,
>>  
>> +/**
>> + * This side data is encryption "initialization data".
>> + * For MP4 this is the entire 'pssh' box.
>> + * For WebM this is the key ID.
>> + */
>> +AV_PKT_DATA_ENCRYPTION_INIT_DATA,
>> +
>> +/**
>> + * This side data is an AVPacketEncryptionInfo structure and contains 
>> info
>> + * about how the packet is encrypted.
>> + */
>> +AV_PKT_DATA_PACKET_ENCRYPTION_INFO,
>> +
>>  /**
>>   * The number of side data types.
>>   * This is not part of the public API/ABI in the sense that it may
> 
> ___
> 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] [RFC] avcodec/avcodec.h: Add encryption info side data

2017-12-18 Thread wm4
On Fri, 15 Dec 2017 14:24:17 -0800
Jacob Trimble  wrote:

> From a1b2cbcb7da4da69685f8f1299b70b672ce448e3 Mon Sep 17 00:00:00 2001
> From: Jacob Trimble 
> Date: Tue, 5 Dec 2017 14:52:22 -0800
> Subject: [PATCH] avcodec/avcodec.h: Add encryption info side data.
> 
> This new side-data will contain info on how a packet is encrypted.
> This allows the app to handle packet decryption.  To allow for a
> variable number of subsamples, the buffer for the side-data will be
> allocated to hold both the structure and the array of subsamples.  So
> the |subsamples| member will point to right after the struct.
> 
> Signed-off-by: Jacob Trimble 
> ---
>  libavcodec/avcodec.h | 70 
> 
>  1 file changed, 70 insertions(+)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 5db6a81320..ccc89345e8 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -1112,6 +1112,63 @@ typedef struct AVCPBProperties {
>  uint64_t vbv_delay;
>  } AVCPBProperties;
>  
> +typedef struct AVPacketSubsampleEncryptionInfo {
> +/** The number of bytes that are clear. */
> +unsigned int bytes_of_clear_data;
> +
> +/**
> + * The number of bytes that are protected.  If using pattern encryption,
> + * the pattern applies to only the protected bytes; if not using pattern
> + * encryption, all these bytes are encrypted.
> + */
> +unsigned int bytes_of_protected_data;
> +} AVPacketSubsampleEncryptionInfo;
> +
> +/**
> + * This describes encryption info for a packet.  This contains frame-specific
> + * info for how to decrypt the packet before passing it to the decoder.  If 
> this
> + * side-data is present, then the packet is encrypted.
> + */
> +typedef struct AVPacketEncryptionInfo {
> +/** The fourcc encryption scheme. */
> +uint32_t scheme;
> +
> +/** The ID of the key used to encrypt the packet. */
> +uint8_t key_id[16];
> +
> +/** The initialization vector. */
> +uint8_t iv[16];
> +
> +/**
> + * Only used for pattern encryption.  This is the number of 16-byte 
> blocks
> + * that are encrypted.
> + */
> +unsigned int crypt_byte_block;
> +
> +/**
> + * Only used for pattern encryption.  This is the number of 16-byte 
> blocks
> + * that are clear.
> + */
> +unsigned int skip_byte_block;
> +
> +/**
> + * The number of sub-samples in this packet.  If 0, then the whole sample
> + * is encrypted.
> + */
> +unsigned int subsample_count;
> +
> +/** The subsample encryption info. */
> +AVPacketSubsampleEncryptionInfo *subsamples;

I don't think this is sane. So far, side data could simply be copied
with memcpy, and having pointers to non-static data in side data would
break this completely.

> +} AVPacketEncryptionInfo;
> +/**
> + * The size of the side-data for the AV_PKT_DATA_PACKET_ENCRYPTION_INFO type.
> + * The side-data will contain the AVPacketEncryptionInfo struct followed by
> + * the subsample array.  The subsamples member should point to after the 
> struct
> + * so the app can easily access it.
> + */
> +#define FF_PACKET_ENCRYPTION_INFO_SIZE(subsample_count) \
> +(sizeof(AVPacketEncryptionInfo) + 
> sizeof(AVPacketSubsampleEncryptionInfo) * subsample_count)
> +
>  /**
>   * The decoder will keep a reference to the frame and may reuse it later.
>   */
> @@ -1327,6 +1384,19 @@ enum AVPacketSideDataType {
>   */
>  AV_PKT_DATA_A53_CC,
>  
> +/**
> + * This side data is encryption "initialization data".
> + * For MP4 this is the entire 'pssh' box.
> + * For WebM this is the key ID.
> + */
> +AV_PKT_DATA_ENCRYPTION_INIT_DATA,
> +
> +/**
> + * This side data is an AVPacketEncryptionInfo structure and contains 
> info
> + * about how the packet is encrypted.
> + */
> +AV_PKT_DATA_PACKET_ENCRYPTION_INFO,
> +
>  /**
>   * The number of side data types.
>   * This is not part of the public API/ABI in the sense that it may

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


Re: [FFmpeg-devel] [RFC] avcodec/avcodec.h: Add encryption info side data

2017-12-18 Thread Jacob Trimble
>> @@ -1327,6 +1384,19 @@ enum AVPacketSideDataType {
>>   */
>>  AV_PKT_DATA_A53_CC,
>>
>> +/**
>> + * This side data is encryption "initialization data".
>> + * For MP4 this is the entire 'pssh' box.
>> + * For WebM this is the key ID.
>> + */
>> +AV_PKT_DATA_ENCRYPTION_INIT_DATA,
>
> So its basically like extradata is for a codec ?
> If so it should be defined similarly as opaque encryption scheme specific 
> data.
> It should not be container specific.
> Data taken from one container should be storable in another if both support
> the features used

Yes, that's the idea.  Unfortunately the data is specific to a
container.  This isn't taken from the common encryption spec, but from
the EME spec.  The "EME initialization data registry" specifies
several fixed formats for initialization data that are all specific to
a container.  

It would be possible to parse the PSSH boxes and just push the generic
data to the app.  This would allow new containers to hold the same
data; then the app could wrap it back in a generic PSSH box for EME.
But that would remove the key ID information that exists in v1 PSSH
boxes.  Some apps parse the PSSH boxes and filter the initialization
based on whether they already have those key IDs to avoid creating too
many sessions.  So I would like to expose the whole PSSH box in the
side data so apps can do that.

I can change this to something that is specific to MP4 instead (e.g.
AV_PKT_DATA_MP4_PSSH).  The app could just pull the key ID from the
first sample in the case of WebM.

>
> thanks
>
> [...]
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] order T-shirts

2017-12-18 Thread Thilo Borgmann
Am 18.12.17 um 16:31 schrieb Paul B Mahol:
> On 12/18/17, Compn  wrote:
>> On Mon, 18 Dec 2017 14:29:51 +0100, Timo Rothenpieler
>>  wrote:
>>
>>> Forgot to mention it here, but I got my shirt a while ago and it fits
>>> perfectly.
>>> Thank you very much!
>>>
>>
>> ditto, much thanks.
>>
>> although Deutsche Post decided it did not like your envelope
>> so they put it in a protective plastic bag.

Good, I worried about the far away packages but it also arrived fine in India!


> How much healthy is wearing those shirts?

Well not too much, those shirts already got me free alcohol ;)

Thanks for feedback,
Thilo
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/7] fate: add 12 bit framerate filter tests

2017-12-18 Thread Paul B Mahol
On 12/10/17, Marton Balint  wrote:
> Signed-off-by: Marton Balint 
> ---
>  tests/fate/filter-video.mak|  4 ++
>  tests/ref/fate/filter-framerate-12bit-down | 55 +
>  tests/ref/fate/filter-framerate-12bit-up   | 64
> ++
>  3 files changed, 123 insertions(+)
>  create mode 100644 tests/ref/fate/filter-framerate-12bit-down
>  create mode 100644 tests/ref/fate/filter-framerate-12bit-up
>

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


Re: [FFmpeg-devel] [PATCH 6/7] avfilter/vf_framerate: do not calculate scene change score multiple times for the same frame

2017-12-18 Thread Paul B Mahol
On 12/10/17, Marton Balint  wrote:
> This speeds up the filter, and also fixes scene change detection score which
> is
> reduced based on the difference of the current MAFD to the preivous MAFD.
> Obviously if we compare two frames twice, the difference will be 0...
>
> Signed-off-by: Marton Balint 
> ---
>  libavfilter/vf_framerate.c | 45
> +++--
>  1 file changed, 27 insertions(+), 18 deletions(-)
>

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


Re: [FFmpeg-devel] order T-shirts

2017-12-18 Thread Paul B Mahol
On 12/18/17, Compn  wrote:
> On Mon, 18 Dec 2017 14:29:51 +0100, Timo Rothenpieler
>  wrote:
>
>> Forgot to mention it here, but I got my shirt a while ago and it fits
>> perfectly.
>> Thank you very much!
>>
>
> ditto, much thanks.
>
> although Deutsche Post decided it did not like your envelope
> so they put it in a protective plastic bag.

How much healthy is wearing those shirts?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] order T-shirts

2017-12-18 Thread Compn
On Mon, 18 Dec 2017 14:29:51 +0100, Timo Rothenpieler
 wrote:

> Forgot to mention it here, but I got my shirt a while ago and it fits 
> perfectly.
> Thank you very much!
> 

ditto, much thanks.

although Deutsche Post decided it did not like your envelope
so they put it in a protective plastic bag.

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


Re: [FFmpeg-devel] order T-shirts

2017-12-18 Thread Timo Rothenpieler
Forgot to mention it here, but I got my shirt a while ago and it fits 
perfectly.

Thank you very much!



smime.p7s
Description: S/MIME Cryptographic Signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v6 3/3] avformat/hlsenc:addition of CODECS attribute in the master playlist

2017-12-18 Thread Dixit, Vishwanath


>On 12/15/17, 8:19 PM, "Steven Liu"  wrote:
>
>2017-12-15 16:21 GMT+08:00 Jeyapal, Karthick :
>>
>>
>>>On 12/15/17, 4:45 AM, "Liu Steven"  wrote:
>>>
>>>
 在 2017年12月15日,上午6:28,Liu Steven  写道:

>
> 在 2017年12月15日,上午12:29,Jeyapal, Karthick  写道:
>
>> On 12/14/17, 8:24 PM, "Steven Liu"  wrote:
>>
>>
>>> 在 2017年12月14日,下午6:55,vdi...@akamai.com 写道:
>>> […]
>>> +libavformat/reverse.c
>>
>> this need double check for a better way
> The better way of doing this is to share ff_reverse function.
 No I don’t think that is a better way here.
> But such a patch submitted recently was not pushed due to several 
> objections. 
> http://ffmpeg.org/pipermail/ffmpeg-devel/2017-December/221472.html
> Hence, we are left with only this option. Moreover like same approach was 
> used for avcodec and avdevice(to add reverse.c), as well. So, extending 
> the same approach for avformat shouldn’t deviate from ffmpeg’s principles.
 I think there have better way, Please don’t define the ffmpeg’s principles 
 to every place. you are duplicate the code from libavcodec//reverse.c to 
 libavformat, IMHO, that is not a good option.
>>>I need some time to think about that.
>> Oh sure. Thanks.
>> In that case, could you please merge PATCH v6 1/3 alone, since that is a 
>> relatively independent feature.
>
>
>patch -p1 < 
>~/Downloads/FFmpeg-devel-v6-1-3-avformat-hlsenc-addition-of-EXT-X-MEDIA-tag-and-AUDIO-attribute.patch
>cd xxx/
>rm -rf *
>../configure --disable-network --disable-everything --enable-muxer=hls
>make
>
>
>CC libavformat/hlsenc.o
>src/libavformat/hlsenc.c:1142:21: error: use of undeclared identifier
>'master_pb'
>avio_printf(master_pb, "#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"group_%s\"",
>^
>src/libavformat/hlsenc.c:1144:21: error: use of undeclared identifier
>'master_pb'
>avio_printf(master_pb, ",NAME=\"audio_0\",DEFAULT=YES,URI=\"%s\"\n",
>^
>2 errors generated.
>make: *** [libavformat/hlsenc.o] Error 1
>make: *** Waiting for unfinished jobs
The patch needed rebasing since an hlsenc patch ([PATCH 3/3] avformat/hlsenc: 
Extend persistent http connections to playlists) was pushed on 15-dec. I have 
rebased the patch set and submitted with version v7. Could you please merge 
PATCH v7 1/3 (https://patchwork.ffmpeg.org/patch/6857/)

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


Re: [FFmpeg-devel] [PATCH] libvmaf: exit gracefully if the library fails.

2017-12-18 Thread Ronald S. Bultje
Hi,

On Mon, Dec 18, 2017 at 12:28 AM, Gyan Doshi  wrote:

> Hi Ronald,
>
> When do you expect to apply this?


Oops, forgot; pushed.

Nicolas makes a good point that we may want to add a version check for
libvmaf, but that can be done separately...

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


Re: [FFmpeg-devel] avfilter/vf_interlace : add checkasm for lowpass_line and AVX2 version

2017-12-18 Thread Thomas Mundt
2017-12-18 11:34 GMT+01:00 Martin Vignali :

> > >
> >
> > Please also add the changes you made in patch 1 and avx2 to
> vf_tinterlace.
> >
> >
> >
> > For patch 1, IMHO, it's not necessary (the modification is mainly to make
> checkasm test easier to write, and like vf_interlace and vf_tinterlace use
> the same asm
> only one is useful for checkasm)
>

I just thought it might be easier to maintain when code in both filters is
more similar.
But it´s not a big thing, so OK.

In attach new patchs, adding AVX2 lowpass_line 8 and 16 for vf_tinterlace
>

LGTM, thanks.
Do you think, that the complex low pass filter could also be improved that
way?

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


[FFmpeg-devel] [PATCH v7 1/3] avformat/hlsenc:addition of #EXT-X-MEDIA tag and AUDIO attribute

2017-12-18 Thread vdixit
From: Vishwanath Dixit 

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

diff --git a/doc/muxers.texi b/doc/muxers.texi
index 3d0c7bf..93db549 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -834,6 +834,18 @@ be a video only stream with video bitrate 1000k, the 
second variant stream will
 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_1.m3u8, out_2.m3u8 and out_3.m3u8 will be created.
+@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" \
+  -master_pl_name master.m3u8 \
+  http://example.com/live/out.m3u8
+@end example
+This example creates two audio only and two video only variant streams. In
+addition to the #EXT-X-STREAM-INF tag for each variant stream in the master
+playlist, #EXT-X-MEDIA tag is also added for the two audio only variant streams
+and they are mapped to the two video only variant streams with audio group 
names
+'aud_low' and 'aud_high'.
 
 By default, a single hls variant containing all the encoded streams is created.
 
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 5687530..f363418 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -759,7 +759,8 @@ static int write_manifest(AVFormatContext *s, int final)
 char playlist_file[64];
 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);
+ff_hls_write_stream_info(st, out, st->codecpar->bit_rate,
+playlist_file, NULL);
 }
 avio_close(out);
 if (use_rename)
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index e3442c3..2903e4e 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -144,6 +144,7 @@ typedef struct VariantStream {
 AVStream **streams;
 unsigned int nb_streams;
 int m3u8_created; /* status of media play-list creation */
+char *agroup; /* audio group name */
 char *baseurl;
 } VariantStream;
 
@@ -1085,7 +1086,7 @@ static int create_master_playlist(AVFormatContext *s,
   VariantStream * const input_vs)
 {
 HLSContext *hls = s->priv_data;
-VariantStream *vs;
+VariantStream *vs, *temp_vs;
 AVStream *vid_st, *aud_st;
 AVDictionary *options = NULL;
 unsigned int i, j;
@@ -1117,6 +1118,34 @@ static int create_master_playlist(AVFormatContext *s,
 
 ff_hls_write_playlist_version(hls->m3u8_out, hls->version);
 
+/* 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]);
+
+if (vs->has_video || vs->has_subtitle || !vs->agroup)
+continue;
+
+m3u8_name_size = strlen(vs->m3u8_name) + 1;
+m3u8_rel_name = av_malloc(m3u8_name_size);
+if (!m3u8_rel_name) {
+ret = AVERROR(ENOMEM);
+goto fail;
+}
+av_strlcpy(m3u8_rel_name, vs->m3u8_name, m3u8_name_size);
+ret = get_relative_url(hls->master_m3u8_url, vs->m3u8_name,
+   m3u8_rel_name, m3u8_name_size);
+if (ret < 0) {
+av_log(s, AV_LOG_ERROR, "Unable to find relative URL\n");
+goto fail;
+}
+
+avio_printf(hls->m3u8_out, 
"#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID=\"group_%s\"",
+vs->agroup);
+avio_printf(hls->m3u8_out, 
",NAME=\"audio_0\",DEFAULT=YES,URI=\"%s\"\n",
+m3u8_rel_name);
+av_freep(_rel_name);
+}
+
 /* For variant streams with video add #EXT-X-STREAM-INF tag with 
attributes*/
 for (i = 0; i < hls->nb_varstreams; i++) {
 vs = &(hls->var_streams[i]);
@@ -1149,6 +1178,25 @@ static int create_master_playlist(AVFormatContext *s,
 continue;
 }
 
+/**
+ * Traverse through the list of audio only rendition streams and find
+ * the rendition which has highest bitrate in the same audio group
+ */
+if (vs->agroup) {
+for (j = 0; j < hls->nb_varstreams; j++) {
+temp_vs = &(hls->var_streams[j]);
+if (!temp_vs->has_video && !temp_vs->has_subtitle &&
+temp_vs->agroup &&
+!strcmp(temp_vs->agroup, vs->agroup)) {
+if (!aud_st)
+aud_st = temp_vs->streams[0];
+if 

[FFmpeg-devel] [PATCH v7 2/3] avcodec/libx264:setting profile and level in avcodec context

2017-12-18 Thread vdixit
From: Vishwanath Dixit 

---
 libavcodec/libx264.c | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index e2455e1..0285213 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -19,11 +19,13 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/avassert.h"
 #include "libavutil/eval.h"
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/mem.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/reverse.h"
 #include "libavutil/stereo3d.h"
 #include "libavutil/intreadwrite.h"
 #include "avcodec.h"
@@ -454,6 +456,9 @@ static av_cold int X264_init(AVCodecContext *avctx)
 X264Context *x4 = avctx->priv_data;
 AVCPBProperties *cpb_props;
 int sw,sh;
+x264_nal_t *nal;
+uint8_t *p;
+int nnal, s, i;
 
 if (avctx->global_quality > 0)
 av_log(avctx, AV_LOG_WARNING, "-qscale is ignored, -crf is 
recommended.\n");
@@ -799,12 +804,17 @@ FF_ENABLE_DEPRECATION_WARNINGS
 if (!x4->enc)
 return AVERROR_EXTERNAL;
 
-if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
-x264_nal_t *nal;
-uint8_t *p;
-int nnal, s, i;
+s = x264_encoder_headers(x4->enc, , );
+// Assert for NAL start code and SPS unit type
+av_assert0((nal->p_payload[0] | nal->p_payload[1] | nal->p_payload[2]) == 
0 && nal->p_payload[3] == 1);
+av_assert0((nal->p_payload[4] & 0x1F) == 7);
+// bits 0-7 LSB for profile. bits 8-11 for constrained set flags.
+if (avctx->profile == FF_PROFILE_UNKNOWN)
+avctx->profile = ((uint32_t)nal->p_payload[5]) | 
((uint32_t)ff_reverse[nal->p_payload[6]] << 8);
+if (avctx->level == FF_LEVEL_UNKNOWN)
+avctx->level = nal->p_payload[7];
 
-s = x264_encoder_headers(x4->enc, , );
+if (avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER) {
 avctx->extradata = p = av_mallocz(s + AV_INPUT_BUFFER_PADDING_SIZE);
 if (!p)
 return AVERROR(ENOMEM);
-- 
1.9.1

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


[FFmpeg-devel] [PATCH v7 3/3] avformat/hlsenc:addition of CODECS attribute in the master playlist

2017-12-18 Thread vdixit
From: Vishwanath Dixit 

---
 libavformat/Makefile  |  2 +-
 libavformat/dashenc.c |  2 +-
 libavformat/hlsenc.c  | 65 +--
 libavformat/hlsplaylist.c |  5 +++-
 libavformat/hlsplaylist.h |  3 ++-
 libavformat/reverse.c |  1 +
 tests/ref/fate/source |  1 +
 7 files changed, 73 insertions(+), 6 deletions(-)
 create mode 100644 libavformat/reverse.c

diff --git a/libavformat/Makefile b/libavformat/Makefile
index cb70eac..1072ff9 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -61,7 +61,7 @@ OBJS-$(CONFIG_RTPDEC)+= rdt.o 
  \
 rtpdec_vp9.o\
 rtpdec_xiph.o
 OBJS-$(CONFIG_RTPENC_CHAIN)  += rtpenc_chain.o rtp.o
-OBJS-$(CONFIG_SHARED)+= log2_tab.o golomb_tab.o
+OBJS-$(CONFIG_SHARED)+= log2_tab.o golomb_tab.o reverse.o
 OBJS-$(CONFIG_SRTP)  += srtp.o
 
 # muxers/demuxers
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index f363418..016ada3 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 2903e4e..b6df3db 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -39,6 +39,7 @@
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/random_seed.h"
+#include "libavutil/reverse.h"
 #include "libavutil/opt.h"
 #include "libavutil/log.h"
 #include "libavutil/time_internal.h"
@@ -1082,6 +1083,63 @@ static int get_relative_url(const char *master_url, 
const char *media_url,
 return 0;
 }
 
+static char *get_codec_str(AVStream *vid_st, AVStream *aud_st) {
+size_t codec_str_size = 64;
+char *codec_str = av_malloc(codec_str_size);
+int video_str_len = 0;
+
+if (!codec_str)
+return NULL;
+
+if (!vid_st && !aud_st) {
+goto fail;
+}
+
+if (vid_st) {
+if (vid_st->codecpar->profile != FF_PROFILE_UNKNOWN &&
+vid_st->codecpar->level != FF_LEVEL_UNKNOWN &&
+vid_st->codecpar->codec_id == AV_CODEC_ID_H264) {
+snprintf(codec_str, codec_str_size, "avc1.%02x%02x%02x",
+ vid_st->codecpar->profile & 0xFF,
+ ff_reverse[(vid_st->codecpar->profile >> 8) & 0xFF],
+ vid_st->codecpar->level);
+} else {
+goto fail;
+}
+video_str_len = strlen(codec_str);
+}
+
+if (aud_st) {
+char *audio_str = codec_str;
+if (video_str_len) {
+codec_str[video_str_len] = ',';
+video_str_len += 1;
+audio_str += video_str_len;
+codec_str_size -= video_str_len;
+}
+if (aud_st->codecpar->codec_id == AV_CODEC_ID_MP2) {
+snprintf(audio_str, codec_str_size, "mp4a.40.33");
+} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_MP3) {
+snprintf(audio_str, codec_str_size, "mp4a.40.34");
+} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_AAC) {
+/* TODO : For HE-AAC, HE-AACv2, the last digit needs to be set to 
5 and 29 respectively */
+snprintf(audio_str, codec_str_size, "mp4a.40.2");
+} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_AC3) {
+snprintf(audio_str, codec_str_size, "mp4a.A5");
+} else if (aud_st->codecpar->codec_id == AV_CODEC_ID_EAC3) {
+snprintf(audio_str, codec_str_size, "mp4a.A6");
+} else {
+goto fail;
+}
+}
+
+return codec_str;
+
+fail:
+av_free(codec_str);
+return NULL;
+}
+
 static int create_master_playlist(AVFormatContext *s,
   VariantStream * const input_vs)
 {
@@ -1091,7 +1149,7 @@ static int create_master_playlist(AVFormatContext *s,
 AVDictionary *options = NULL;
 unsigned int i, j;
 int m3u8_name_size, ret, bandwidth;
-char *m3u8_rel_name;
+char *m3u8_rel_name, *codec_str;
 
 input_vs->m3u8_created = 1;
 if (!hls->master_m3u8_created) {
@@ -1204,9 +1262,12 @@ static int create_master_playlist(AVFormatContext *s,
 bandwidth += aud_st->codecpar->bit_rate;
 bandwidth += bandwidth / 10;
 
+codec_str = get_codec_str(vid_st, aud_st);
+
 ff_hls_write_stream_info(vid_st, hls->m3u8_out, bandwidth, 
m3u8_rel_name,
-aud_st ? vs->agroup : NULL);
+

[FFmpeg-devel] [PATCH] lavc/libx265: support all color parameters that x265 does

2017-12-18 Thread Rodger Combs
---
 libavcodec/libx265.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
index 25ccb02fcb..14710f8de0 100644
--- a/libavcodec/libx265.c
+++ b/libavcodec/libx265.c
@@ -115,11 +115,11 @@ static av_cold int libx265_encode_init(AVCodecContext 
*avctx)
 ctx->params->sourceHeight= avctx->height;
 ctx->params->bEnablePsnr = !!(avctx->flags & AV_CODEC_FLAG_PSNR);
 
-if ((avctx->color_primaries <= AVCOL_PRI_BT2020 &&
+if ((avctx->color_primaries <= AVCOL_PRI_SMPTE432 &&
  avctx->color_primaries != AVCOL_PRI_UNSPECIFIED) ||
-(avctx->color_trc <= AVCOL_TRC_BT2020_12 &&
+(avctx->color_trc <= AVCOL_TRC_ARIB_STD_B67 &&
  avctx->color_trc != AVCOL_TRC_UNSPECIFIED) ||
-(avctx->colorspace <= AVCOL_SPC_BT2020_CL &&
+(avctx->colorspace <= AVCOL_SPC_ICTCP &&
  avctx->colorspace != AVCOL_SPC_UNSPECIFIED)) {
 
 ctx->params->vui.bEnableVideoSignalTypePresentFlag  = 1;
-- 
2.15.1

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


Re: [FFmpeg-devel] [PATCH 4/8] sbc: implement SBC encoder (low-complexity subband codec)

2017-12-18 Thread Michael Niedermayer
On Sun, Dec 17, 2017 at 10:47:16PM +0100, Aurelien Jacobs wrote:
> This was originally based on libsbc, and was fully integrated into ffmpeg.
> ---
[...]
> +static inline void sbc_analyze_4b_4s_simd(SBCDSPContext *s,
> +  int16_t *x, int32_t *out, int 
> out_stride)
> +{
> +/* Analyze blocks */
> +s->sbc_analyze_4(x + 12, out, ff_sbcdsp_analysis_consts_fixed4_simd_odd);
> +out += out_stride;
> +s->sbc_analyze_4(x + 8, out, ff_sbcdsp_analysis_consts_fixed4_simd_even);
> +out += out_stride;
> +s->sbc_analyze_4(x + 4, out, ff_sbcdsp_analysis_consts_fixed4_simd_odd);
> +out += out_stride;
> +s->sbc_analyze_4(x + 0, out, ff_sbcdsp_analysis_consts_fixed4_simd_even);
> +
> +emms_c();
> +}
> +
> +static inline void sbc_analyze_4b_8s_simd(SBCDSPContext *s,
> +  int16_t *x, int32_t *out, int 
> out_stride)
> +{
> +/* Analyze blocks */
> +s->sbc_analyze_8(x + 24, out, ff_sbcdsp_analysis_consts_fixed8_simd_odd);
> +out += out_stride;
> +s->sbc_analyze_8(x + 16, out, 
> ff_sbcdsp_analysis_consts_fixed8_simd_even);
> +out += out_stride;
> +s->sbc_analyze_8(x + 8, out, ff_sbcdsp_analysis_consts_fixed8_simd_odd);
> +out += out_stride;
> +s->sbc_analyze_8(x + 0, out, ff_sbcdsp_analysis_consts_fixed8_simd_even);
> +
> +emms_c();
> +}
> +
> +static inline void sbc_analyze_1b_8s_simd_even(SBCDSPContext *s,
> +   int16_t *x, int32_t *out,
> +   int out_stride);
> +
> +static inline void sbc_analyze_1b_8s_simd_odd(SBCDSPContext *s,
> +  int16_t *x, int32_t *out,
> +  int out_stride)
> +{
> +s->sbc_analyze_8(x, out, ff_sbcdsp_analysis_consts_fixed8_simd_odd);
> +s->sbc_analyze_8s = sbc_analyze_1b_8s_simd_even;
> +
> +emms_c();
> +}
> +
> +static inline void sbc_analyze_1b_8s_simd_even(SBCDSPContext *s,
> +   int16_t *x, int32_t *out,
> +   int out_stride)
> +{
> +s->sbc_analyze_8(x, out, ff_sbcdsp_analysis_consts_fixed8_simd_even);
> +s->sbc_analyze_8s = sbc_analyze_1b_8s_simd_odd;
> +
> +emms_c();
> +}

at least some of the functions are always called in a loop, the emms_c() could
be called after the loop


[...]
> diff --git a/libavcodec/sbcdsp_data.c b/libavcodec/sbcdsp_data.c
> new file mode 100644
> index 00..1e19b9d9d1
> --- /dev/null
> +++ b/libavcodec/sbcdsp_data.c
> @@ -0,0 +1,329 @@
> +/*
> + * Bluetooth low-complexity, subband codec (SBC)
> + *
> + * Copyright (C) 2017  Aurelien Jacobs 
> + * Copyright (C) 2008-2010  Nokia Corporation
> + * Copyright (C) 2004-2010  Marcel Holtmann 
> + * Copyright (C) 2004-2005  Henryk Ploetz 
> + * Copyright (C) 2005-2006  Brad Midgley 
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
> + */
> +
> +/**
> + * @file
> + * miscellaneous SBC tables
> + */
> +
> +#include "sbcdsp_data.h"
> +
> +#define F_PROTO(x) (int32_t) ((x * 2) * ((int32_t) 1 << 15) + 0.5)
> +#define F_COS(x)   (int32_t) ((x) * ((int32_t) 1 << 15) + 0.5)

this needs more () to protect the argument x and the whole expression
for example F_PROTO(1+1) would produce unexpected results

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

What does censorship reveal? It reveals fear. -- Julian Assange


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


Re: [FFmpeg-devel] avfilter/vf_interlace : add checkasm for lowpass_line and AVX2 version

2017-12-18 Thread Martin Vignali
> >
>
> Please also add the changes you made in patch 1 and avx2 to vf_tinterlace.
>
>
>
> For patch 1, IMHO, it's not necessary (the modification is mainly to make
checkasm test easier to write, and like vf_interlace and vf_tinterlace use
the same asm
only one is useful for checkasm)

In attach new patchs, adding AVX2 lowpass_line 8 and 16 for vf_tinterlace

Martin


0001-avfilter-vf_interlace-move-func-init-in.patch
Description: Binary data


0002-checkasm-vf_interlace-add-test-for-lowpass_line-8-an.patch
Description: Binary data


0003-avfilter-vf_interlace-add-AVX2-for-lowpass_line-8-an.patch
Description: Binary data


0004-avfilter-vf_tinterlace-add-AVX2-func-for-lowpass_lin.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] avfilter/x86/vf_blend : add avx2 version for 8b func (WIP)

2017-12-18 Thread Martin Vignali
2017-12-17 19:41 GMT+01:00 Henrik Gramner :

> On Thu, Dec 14, 2017 at 11:16 AM, Martin Vignali
>  wrote:
> > 2017-12-13 17:37 GMT+01:00 Henrik Gramner :
> >> You could also do vextracti128 + 128-bit packuswb instead of 256-bit
> >> packuswb + vpermq.
> >>
> > Sorry don't understand this part
> > do you mean 128 bit packuswb + movh for each lane ?
> > or something else ?
>
> packuswb  m0, m0
> vpermqm0, m0, q3120
>
> vs.
>
> vextracti128 xm1, m0, 1
> packuswb xm0, xm1
>
> Uses a 128-bit op instead of a 256-bit one which is generally
> preferable whenever possible.
>
>
Thanks !
I will send a new patch, using this way.

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


Re: [FFmpeg-devel] avfilter/vf_interlace and vf_tinterlace : remove avx version

2017-12-18 Thread Martin Vignali
> when running checkasm several times sse2 is mostly faster here, not always.
> But the difference is quite small.
> Since I´m not an SIMD expert I´m fine with this patch as long as no one
> with more expertise objects.
>
>
> Seems like Paul B Mahol is against.
And I don't have strong opinion on this, and i'm not an SIMD expert,
So i will drop this patch.

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


[FFmpeg-devel] [PATCH] avformat/hls: update specification link of comments

2017-12-18 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavformat/hls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/hls.c b/libavformat/hls.c
index ab6ff187a6..786b19ab5d 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -23,7 +23,7 @@
 /**
  * @file
  * Apple HTTP Live Streaming demuxer
- * http://tools.ietf.org/html/draft-pantos-http-live-streaming
+ * https://www.rfc-editor.org/rfc/rfc8216.txt
  */
 
 #include "libavutil/avstring.h"
-- 
2.14.3 (Apple Git-98)



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


[FFmpeg-devel] [PATCH 1/4] avformat/hlsenc: fix first fragment mp4 do not split bug

2017-12-18 Thread Steven Liu
fix ticket id: 6888

Signed-off-by: Steven Liu 
---
 libavformat/hlsenc.c | 72 
 1 file changed, 62 insertions(+), 10 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index e3442c368f..f51fec1030 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -352,6 +352,29 @@ static void write_styp(AVIOContext *pb)
 ffio_wfourcc(pb, "msix");
 }
 
+static int flush_dynbuf(VariantStream *vs, int *range_length)
+{
+AVFormatContext *ctx = vs->avf;
+uint8_t *buffer;
+
+if (!ctx->pb) {
+return AVERROR(EINVAL);
+}
+
+// flush
+av_write_frame(ctx, NULL);
+avio_flush(ctx->pb);
+
+// write out to file
+*range_length = avio_close_dyn_buf(ctx->pb, );
+ctx->pb = NULL;
+avio_write(vs->out, buffer, *range_length);
+av_free(buffer);
+
+// re-open buffer
+return avio_open_dyn_buf(>pb);
+}
+
 static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls,
VariantStream *vs) {
 
@@ -677,7 +700,9 @@ static int hls_mux_init(AVFormatContext *s, VariantStream 
*vs)
 if ((ret = avio_open_dyn_buf(>pb)) < 0)
 return ret;
 
-if ((ret = s->io_open(s, >out, vs->base_output_dirname, 
AVIO_FLAG_WRITE, )) < 0) {
+ret = hlsenc_io_open(s, >out, vs->base_output_dirname, );
+av_dict_free();
+if (ret < 0) {
 av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", 
vs->fmp4_init_filename);
 return ret;
 }
@@ -1404,9 +1429,10 @@ static int hls_start(AVFormatContext *s, VariantStream 
*vs)
 av_dict_free();
 if (err < 0)
 return err;
-} else
+} else if (c->segment_type != SEGMENT_TYPE_FMP4) {
 if ((err = hlsenc_io_open(s, >pb, oc->filename, )) < 0)
 goto fail;
+}
 if (vs->vtt_basename) {
 set_http_options(s, , c);
 if ((err = hlsenc_io_open(s, _oc->pb, vtt_oc->filename, )) 
< 0)
@@ -1414,9 +1440,7 @@ static int hls_start(AVFormatContext *s, VariantStream 
*vs)
 }
 av_dict_free();
 
-if (c->segment_type == SEGMENT_TYPE_FMP4 && !(c->flags & HLS_SINGLE_FILE)) 
{
-write_styp(oc->pb);
-} else {
+if (c->segment_type != SEGMENT_TYPE_FMP4) {
 /* We only require one PAT/PMT per segment. */
 if (oc->oformat->priv_class && oc->priv_data) {
 char period[21];
@@ -1780,7 +1804,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 vs->size = new_start_pos - vs->start_pos;
 
 if (!byterange_mode) {
-if (hls->segment_type == SEGMENT_TYPE_FMP4 && 
!vs->init_range_length) {
+if (hls->segment_type == SEGMENT_TYPE_FMP4) {
+if (!vs->init_range_length) {
 avio_flush(oc->pb);
 range_length = avio_close_dyn_buf(oc->pb, );
 avio_write(vs->out, buffer, range_length);
@@ -1789,6 +1814,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 vs->packets_written = 0;
 ff_format_io_close(s, >out);
 hlsenc_io_close(s, >out, vs->base_output_dirname);
+}
 } else {
 hlsenc_io_close(s, >pb, oc->filename);
 }
@@ -1807,7 +1833,20 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 vs->number--;
 }
 
-if (!vs->fmp4_init_mode || byterange_mode)
+if (hls->segment_type == SEGMENT_TYPE_FMP4) {
+ret = hlsenc_io_open(s, >out, vs->avf->filename, NULL);
+if (ret < 0) {
+av_log(NULL, AV_LOG_ERROR, "Failed to open file '%s'\n",
+vs->avf->filename);
+return ret;
+}
+write_styp(vs->out);
+ret = flush_dynbuf(vs, _length);
+if (ret < 0) {
+return ret;
+}
+ff_format_io_close(s, >out);
+}
 ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, 
vs->size);
 vs->start_pos = new_start_pos;
 if (ret < 0) {
@@ -1861,6 +1900,7 @@ static int hls_write_trailer(struct AVFormatContext *s)
 AVFormatContext *vtt_oc = NULL;
 char *old_filename = NULL;
 int i;
+int ret = 0;
 VariantStream *vs = NULL;
 
 for (i = 0; i < hls->nb_varstreams; i++) {
@@ -1873,11 +1913,25 @@ static int hls_write_trailer(struct AVFormatContext *s)
 if (!old_filename) {
 return AVERROR(ENOMEM);
 }
-
+if ( hls->segment_type == SEGMENT_TYPE_FMP4) {
+int range_length = 0;
+ret = hlsenc_io_open(s, >out, vs->avf->filename, NULL);
+if (ret < 0) {
+av_log(NULL, AV_LOG_ERROR, "Failed to open file '%s'\n", 
vs->avf->filename);
+return AVERROR(ENOENT);
+}
+write_styp(vs->out);
+ret = flush_dynbuf(vs, _length);
+   

Re: [FFmpeg-devel] [PATCH] avfilter/vf_overlay: fix packed_rgb case

2017-12-18 Thread Paul B Mahol
On 12/18/17, Mateusz  wrote:
> Signed-off-by: Mateusz Brzostek 
> ---
>  libavfilter/vf_overlay.c | 17 ++---
>  1 file changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/libavfilter/vf_overlay.c b/libavfilter/vf_overlay.c
> index a7d3906016..aa5835ae3a 100644
> --- a/libavfilter/vf_overlay.c
> +++ b/libavfilter/vf_overlay.c
> @@ -456,9 +456,12 @@ static av_always_inline void
> blend_image_packed_rgb(AVFilterContext *ctx,
>  default:
>  // main_value = main_value * (1 - alpha) + overlay_value *
> alpha
>  // since alpha is in the range 0-255, the result must
> divided by 255
> -d[dr] = is_straight ? FAST_DIV255(d[dr] * (255 - alpha) +
> S[sr] * alpha) : FAST_DIV255(d[dr] * (255 - alpha) + S[sr]);
> -d[dg] = is_straight ? FAST_DIV255(d[dg] * (255 - alpha) +
> S[sg] * alpha) : FAST_DIV255(d[dr] * (255 - alpha) + S[sr]);
> -d[db] = is_straight ? FAST_DIV255(d[db] * (255 - alpha) +
> S[sb] * alpha) : FAST_DIV255(d[dr] * (255 - alpha) + S[sr]);
> +d[dr] = is_straight ? FAST_DIV255(d[dr] * (255 - alpha) +
> S[sr] * alpha) :
> +FFMIN(FAST_DIV255(d[dr] * (255 - alpha)) + S[sr],
> 255);
> +d[dg] = is_straight ? FAST_DIV255(d[dg] * (255 - alpha) +
> S[sg] * alpha) :
> +FFMIN(FAST_DIV255(d[dg] * (255 - alpha)) + S[sg],
> 255);
> +d[db] = is_straight ? FAST_DIV255(d[db] * (255 - alpha) +
> S[sb] * alpha) :
> +FFMIN(FAST_DIV255(d[db] * (255 - alpha)) + S[sb],
> 255);
>  }
>  if (main_has_alpha) {
>  switch (alpha) {
> @@ -742,22 +745,22 @@ static void blend_image_gbrap_pm(AVFilterContext *ctx,
> AVFrame *dst, const AVFra
>
>  static void blend_image_rgb(AVFilterContext *ctx, AVFrame *dst, const
> AVFrame *src, int x, int y)
>  {
> -blend_image_packed_rgb(ctx, dst, src, 0, x, y, 0);
> +blend_image_packed_rgb(ctx, dst, src, 0, x, y, 1);
>  }
>
>  static void blend_image_rgba(AVFilterContext *ctx, AVFrame *dst, const
> AVFrame *src, int x, int y)
>  {
> -blend_image_packed_rgb(ctx, dst, src, 1, x, y, 0);
> +blend_image_packed_rgb(ctx, dst, src, 1, x, y, 1);
>  }
>
>  static void blend_image_rgb_pm(AVFilterContext *ctx, AVFrame *dst, const
> AVFrame *src, int x, int y)
>  {
> -blend_image_packed_rgb(ctx, dst, src, 0, x, y, 1);
> +blend_image_packed_rgb(ctx, dst, src, 0, x, y, 0);
>  }
>
>  static void blend_image_rgba_pm(AVFilterContext *ctx, AVFrame *dst, const
> AVFrame *src, int x, int y)
>  {
> -blend_image_packed_rgb(ctx, dst, src, 1, x, y, 1);
> +blend_image_packed_rgb(ctx, dst, src, 1, x, y, 0);
>  }
>
>  static int config_input_main(AVFilterLink *inlink)
> --
> 2.15.1.windows.2
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

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


[FFmpeg-devel] [PATCH 4/4] avformat/hlsenc: add http options to m3u8 hlsenc

2017-12-18 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavformat/hlsenc.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 0cb75ff198..636b7db183 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1723,6 +1723,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 int stream_index = 0;
 int range_length = 0;
 uint8_t *buffer = NULL;
+AVDictionary *options = NULL;
 VariantStream *vs = NULL;
 
 for (i = 0; i < hls->nb_varstreams; i++) {
@@ -1835,7 +1836,8 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 }
 
 if (hls->segment_type == SEGMENT_TYPE_FMP4) {
-ret = hlsenc_io_open(s, >out, vs->avf->filename, NULL);
+set_http_options(s, , hls);
+ret = hlsenc_io_open(s, >out, vs->avf->filename, );
 if (ret < 0) {
 av_log(NULL, AV_LOG_ERROR, "Failed to open file '%s'\n",
 vs->avf->filename);
@@ -1899,6 +1901,7 @@ static int hls_write_trailer(struct AVFormatContext *s)
 HLSContext *hls = s->priv_data;
 AVFormatContext *oc = NULL;
 AVFormatContext *vtt_oc = NULL;
+AVDictionary *options = NULL;
 char *old_filename = NULL;
 int i;
 int ret = 0;
@@ -1916,7 +1919,8 @@ static int hls_write_trailer(struct AVFormatContext *s)
 }
 if ( hls->segment_type == SEGMENT_TYPE_FMP4) {
 int range_length = 0;
-ret = hlsenc_io_open(s, >out, vs->avf->filename, NULL);
+set_http_options(s, , hls);
+ret = hlsenc_io_open(s, >out, vs->avf->filename, );
 if (ret < 0) {
 av_log(NULL, AV_LOG_ERROR, "Failed to open file '%s'\n", 
vs->avf->filename);
 return AVERROR(ENOENT);
-- 
2.14.3 (Apple Git-98)



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


[FFmpeg-devel] [PATCH 3/4] avformat/hlsenc: use hlsenc_io_* APIs

2017-12-18 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavformat/hlsenc.c | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 0eebcb4462..0cb75ff198 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -440,7 +440,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
 av_dict_set(, "method", "DELETE", 0);
 if ((ret = vs->avf->io_open(vs->avf, , path, AVIO_FLAG_WRITE, 
)) < 0)
 goto fail;
-ff_format_io_close(vs->avf, );
+hlsenc_io_close(vs->avf, , path);
 } else if (unlink(path) < 0) {
 av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: %s\n",
  path, strerror(errno));
@@ -463,7 +463,7 @@ static int hls_delete_old_segments(AVFormatContext *s, 
HLSContext *hls,
 av_free(sub_path);
 goto fail;
 }
-ff_format_io_close(vs->avf, );
+hlsenc_io_close(vs->avf, , sub_path);
 } else if (unlink(sub_path) < 0) {
 av_log(hls, AV_LOG_ERROR, "failed to delete old segment %s: 
%s\n",
  sub_path, strerror(errno));
@@ -556,8 +556,10 @@ static int do_encrypt(AVFormatContext *s, VariantStream 
*vs)
 }
 
 ff_data_to_hex(hls->key_string, key, sizeof(key), 0);
-if ((ret = s->io_open(s, , hls->key_file, AVIO_FLAG_WRITE, NULL)) < 
0)
-return ret;
+ret = hlsenc_io_open(s, , hls->key_file, NULL);
+if (ret < 0) {
+return ret;;
+}
 avio_seek(pb, 0, SEEK_CUR);
 avio_write(pb, key, KEYSIZE);
 avio_close(pb);
@@ -588,7 +590,7 @@ static int hls_encryption_start(AVFormatContext *s)
 ff_get_line(pb, hls->iv_string, sizeof(hls->iv_string));
 hls->iv_string[strcspn(hls->iv_string, "\r\n")] = '\0';
 
-ff_format_io_close(s, );
+hlsenc_io_close(s, , hls->key_info_file);
 
 if (!*hls->key_uri) {
 av_log(hls, AV_LOG_ERROR, "no key URI specified in key info file\n");
@@ -606,7 +608,7 @@ static int hls_encryption_start(AVFormatContext *s)
 }
 
 ret = avio_read(pb, key, sizeof(key));
-ff_format_io_close(s, );
+hlsenc_io_close(s, , hls->key_file);
 if (ret != sizeof(key)) {
 av_log(hls, AV_LOG_ERROR, "error reading key file %s\n", 
hls->key_file);
 if (ret >= 0 || ret == AVERROR_EOF)
@@ -1812,7 +1814,6 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 vs->init_range_length = range_length;
 avio_open_dyn_buf(>pb);
 vs->packets_written = 0;
-ff_format_io_close(s, >out);
 hlsenc_io_close(s, >out, vs->base_output_dirname);
 }
 } else {
@@ -1845,7 +1846,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 if (ret < 0) {
 return ret;
 }
-ff_format_io_close(s, >out);
+hlsenc_io_close(s, >out, vs->avf->filename);
 }
 ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, 
vs->size);
 vs->start_pos = new_start_pos;
@@ -1925,14 +1926,14 @@ static int hls_write_trailer(struct AVFormatContext *s)
 if (ret < 0) {
 return ret;
 }
-ff_format_io_close(s, >out);
+hlsenc_io_close(s, >out, vs->avf->filename);
 }
 
 av_write_trailer(oc);
 if (oc->pb) {
 vs->size = avio_tell(vs->avf->pb) - vs->start_pos;
 if (hls->segment_type != SEGMENT_TYPE_FMP4)
-ff_format_io_close(s, >pb);
+hlsenc_io_close(s, >pb, oc->filename);
 
 if ((hls->flags & HLS_TEMP_FILE) && oc->filename[0]) {
 hls_rename_temp_file(s, oc);
@@ -1948,7 +1949,7 @@ static int hls_write_trailer(struct AVFormatContext *s)
 if (vtt_oc->pb)
 av_write_trailer(vtt_oc);
 vs->size = avio_tell(vs->vtt_avf->pb) - vs->start_pos;
-ff_format_io_close(s, _oc->pb);
+hlsenc_io_close(s, _oc->pb, vtt_oc->filename);
 }
 av_freep(>basename);
 av_freep(>base_output_dirname);
-- 
2.14.3 (Apple Git-98)



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


[FFmpeg-devel] [PATCH 2/4] avformat/hlsenc: reindent after previous commits

2017-12-18 Thread Steven Liu
Signed-off-by: Steven Liu 
---
 libavformat/hlsenc.c | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index f51fec1030..0eebcb4462 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1806,14 +1806,14 @@ static int hls_write_packet(AVFormatContext *s, 
AVPacket *pkt)
 if (!byterange_mode) {
 if (hls->segment_type == SEGMENT_TYPE_FMP4) {
 if (!vs->init_range_length) {
-avio_flush(oc->pb);
-range_length = avio_close_dyn_buf(oc->pb, );
-avio_write(vs->out, buffer, range_length);
-vs->init_range_length = range_length;
-avio_open_dyn_buf(>pb);
-vs->packets_written = 0;
-ff_format_io_close(s, >out);
-hlsenc_io_close(s, >out, vs->base_output_dirname);
+avio_flush(oc->pb);
+range_length = avio_close_dyn_buf(oc->pb, );
+avio_write(vs->out, buffer, range_length);
+vs->init_range_length = range_length;
+avio_open_dyn_buf(>pb);
+vs->packets_written = 0;
+ff_format_io_close(s, >out);
+hlsenc_io_close(s, >out, vs->base_output_dirname);
 }
 } else {
 hlsenc_io_close(s, >pb, oc->filename);
@@ -1847,7 +1847,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 }
 ff_format_io_close(s, >out);
 }
-ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, 
vs->size);
+ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, 
vs->size);
 vs->start_pos = new_start_pos;
 if (ret < 0) {
 av_free(old_filename);
@@ -1932,7 +1932,7 @@ static int hls_write_trailer(struct AVFormatContext *s)
 if (oc->pb) {
 vs->size = avio_tell(vs->avf->pb) - vs->start_pos;
 if (hls->segment_type != SEGMENT_TYPE_FMP4)
-ff_format_io_close(s, >pb);
+ff_format_io_close(s, >pb);
 
 if ((hls->flags & HLS_TEMP_FILE) && oc->filename[0]) {
 hls_rename_temp_file(s, oc);
@@ -2292,8 +2292,8 @@ static int hls_init(AVFormatContext *s)
 }
 }
 
-if ((ret = hls_start(s, vs)) < 0)
-goto fail;
+if ((ret = hls_start(s, vs)) < 0)
+goto fail;
 }
 
 fail:
-- 
2.14.3 (Apple Git-98)



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