[FFmpeg-cvslog] fate/h264: make mp4toannexb test use auto-BSF

2016-10-24 Thread Rodger Combs
ffmpeg | branch: master | Rodger Combs  | Fri Apr 15 
03:01:46 2016 -0500| [a6da754ef9a74fe09368491053e0b66611890f7f] | committer: 
Rodger Combs

fate/h264: make mp4toannexb test use auto-BSF

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

 tests/fate/h264.mak | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tests/fate/h264.mak b/tests/fate/h264.mak
index 472895f..b4d7f7a 100644
--- a/tests/fate/h264.mak
+++ b/tests/fate/h264.mak
@@ -205,7 +205,7 @@ FATE_H264-$(call DEMDEC,  MOV, H264) += 
fate-h264-invalid-ref-mod
 # this sample has invalid extradata that is not escaped
 FATE_H264-$(call DEMDEC,  MOV, H264) += fate-h264-unescaped-extradata
 
-FATE_H264-$(call ALLYES, MOV_DEMUXER H264_MP4TOANNEXB_BSF) += 
fate-h264-bsf-mp4toannexb
+FATE_H264-$(call ALLYES, MOV_DEMUXER H264_MP4TOANNEXB_BSF H264_MUXER) += 
fate-h264-bsf-mp4toannexb
 FATE_H264-$(call DEMDEC, MATROSKA, H264) += fate-h264-direct-bff
 FATE_H264-$(call DEMDEC, FLV, H264) += fate-h264-brokensps-2580
 FATE_H264-$(call DEMDEC, MXF, H264) += fate-h264-xavc-4389
@@ -405,7 +405,8 @@ fate-h264-conformance-sva_fm1_e:  CMD = 
framecrc -vsync drop -i
 fate-h264-conformance-sva_nl1_b:  CMD = framecrc -vsync drop 
-i $(TARGET_SAMPLES)/h264-conformance/SVA_NL1_B.264
 fate-h264-conformance-sva_nl2_e:  CMD = framecrc -vsync drop 
-i $(TARGET_SAMPLES)/h264-conformance/SVA_NL2_E.264
 
-fate-h264-bsf-mp4toannexb:CMD = md5 -i 
$(TARGET_SAMPLES)/h264/interlaced_crop.mp4 -vcodec copy -bsf h264_mp4toannexb 
-f h264
+fate-h264-bsf-mp4toannexb:CMD = md5 -i 
$(TARGET_SAMPLES)/h264/interlaced_crop.mp4 -vcodec copy -f h264
+
 fate-h264-crop-to-container:  CMD = framemd5 -i 
$(TARGET_SAMPLES)/h264/crop-to-container-dims-canon.mov
 fate-h264-extreme-plane-pred: CMD = framemd5 -i 
$(TARGET_SAMPLES)/h264/extreme-plane-pred.h264
 fate-h264-interlace-crop: CMD = framecrc -i 
$(TARGET_SAMPLES)/h264/interlaced_crop.mp4 -vframes 3

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


[FFmpeg-cvslog] lavf/movenc: add deinit function

2016-10-24 Thread Rodger Combs
ffmpeg | branch: master | Rodger Combs  | Thu Apr  7 
19:24:04 2016 -0500| [e83d5d7e58fff5f059dfdbe80e07ae7e49cdc2e9] | committer: 
Rodger Combs

lavf/movenc: add deinit function

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

 libavformat/movenc.c | 76 ++--
 1 file changed, 32 insertions(+), 44 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 50be8ff..4b6aa76 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5612,21 +5612,18 @@ static int mov_write_header(AVFormatContext *s)
 if (mov->encryption_key_len != AES_CTR_KEY_SIZE) {
 av_log(s, AV_LOG_ERROR, "Invalid encryption key len %d 
expected %d\n",
 mov->encryption_key_len, AES_CTR_KEY_SIZE);
-ret = AVERROR(EINVAL);
-goto error;
+return AVERROR(EINVAL);
 }
 
 if (mov->encryption_kid_len != CENC_KID_SIZE) {
 av_log(s, AV_LOG_ERROR, "Invalid encryption kid len %d 
expected %d\n",
 mov->encryption_kid_len, CENC_KID_SIZE);
-ret = AVERROR(EINVAL);
-goto error;
+return AVERROR(EINVAL);
 }
 } else {
 av_log(s, AV_LOG_ERROR, "unsupported encryption scheme %s\n",
 mov->encryption_scheme_str);
-ret = AVERROR(EINVAL);
-goto error;
+return AVERROR(EINVAL);
 }
 }
 
@@ -5646,8 +5643,7 @@ static int mov_write_header(AVFormatContext *s)
 av_log(s, AV_LOG_ERROR, "Could not find tag for codec %s in stream 
#%d, "
"codec not currently supported in container\n",
avcodec_get_name(st->codecpar->codec_id), i);
-ret = AVERROR(EINVAL);
-goto error;
+return AVERROR(EINVAL);
 }
 /* If hinting of this track is enabled by a later hint track,
  * this is updated. */
@@ -5661,8 +5657,7 @@ static int mov_write_header(AVFormatContext *s)
 track->tag == MKTAG('m','x','5','p') || track->tag == 
MKTAG('m','x','5','n')) {
 if (st->codecpar->width != 720 || (st->codecpar->height != 608 
&& st->codecpar->height != 512)) {
 av_log(s, AV_LOG_ERROR, "D-10/IMX must use 720x608 or 
720x512 video resolution\n");
-ret = AVERROR(EINVAL);
-goto error;
+return AVERROR(EINVAL);
 }
 track->height = track->tag >> 24 == 'n' ? 486 : 576;
 }
@@ -5675,8 +5670,7 @@ static int mov_write_header(AVFormatContext *s)
 }
 if (st->codecpar->width > 65535 || st->codecpar->height > 65535) {
 av_log(s, AV_LOG_ERROR, "Resolution %dx%d too large for 
mov/mp4\n", st->codecpar->width, st->codecpar->height);
-ret = AVERROR(EINVAL);
-goto error;
+return AVERROR(EINVAL);
 }
 if (track->mode == MODE_MOV && track->timescale > 10)
 av_log(s, AV_LOG_WARNING,
@@ -5704,8 +5698,7 @@ static int mov_write_header(AVFormatContext *s)
"VP9 in MP4 support is experimental, add "
"'-strict %d' if you want to use it.\n",
FF_COMPLIANCE_EXPERIMENTAL);
-ret = AVERROR_EXPERIMENTAL;
-goto error;
+return AVERROR_EXPERIMENTAL;
 }
 }
 } else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
@@ -5718,8 +5711,7 @@ static int mov_write_header(AVFormatContext *s)
  st->codecpar->codec_id == AV_CODEC_ID_ILBC){
 if (!st->codecpar->block_align) {
 av_log(s, AV_LOG_ERROR, "track %d: codec block align is 
not set for adpcm\n", i);
-ret = AVERROR(EINVAL);
-goto error;
+return AVERROR(EINVAL);
 }
 track->sample_size = st->codecpar->block_align;
 }else if (st->codecpar->frame_size > 1){ /* assume compressed 
audio */
@@ -5736,8 +5728,7 @@ static int mov_write_header(AVFormatContext *s)
 if (s->strict_std_compliance >= FF_COMPLIANCE_NORMAL) {
 av_log(s, AV_LOG_ERROR, "track %d: muxing mp3 at %dhz is 
not standard, to mux anyway set strict to -1\n",
 i, track->par->sample_rate);
-ret = AVERROR(EINVAL);
-goto error;
+return AVERROR(EINVAL);
 } else {
 av_log(s, AV_LOG_WARNING, "track %d: muxing mp3 at %dhz is 
not standard in MP4\n",
i, track->par->sample_rate);
@@ -5767,8 +5758,7 @@ static int mov_write_header(AVFo

[FFmpeg-cvslog] fate/hevc: add automatic bsf test

2016-10-24 Thread Rodger Combs
ffmpeg | branch: master | Rodger Combs  | Thu Apr 28 
17:00:43 2016 -0500| [3b3f979894a0aca01245fcaa2e4ff06f5f839e54] | committer: 
Rodger Combs

fate/hevc: add automatic bsf test

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

 tests/fate/hevc.mak | 11 +++
 1 file changed, 11 insertions(+)

diff --git a/tests/fate/hevc.mak b/tests/fate/hevc.mak
index 05266cd..bd09ab3 100644
--- a/tests/fate/hevc.mak
+++ b/tests/fate/hevc.mak
@@ -225,6 +225,17 @@ $(foreach N,$(HEVC_SAMPLES_444_12BIT),$(eval $(call 
FATE_HEVC_TEST_444_12BIT,$(N
 fate-hevc-paramchange-yuv420p-yuv420p10: CMD = framecrc -vsync 0 -i 
$(TARGET_SAMPLES)/hevc/paramchange_yuv420p_yuv420p10.hevc -sws_flags 
area+accurate_rnd+bitexact
 FATE_HEVC += fate-hevc-paramchange-yuv420p-yuv420p10
 
+tests/data/hevc-mp4.mov: TAG = GEN
+tests/data/hevc-mp4.mov: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data
+   $(M)$(TARGET_EXEC) $(TARGET_PATH)/$< \
+   -i $(TARGET_SAMPLES)/hevc-conformance/WPP_A_ericsson_MAIN10_2.bit -c 
copy -flags +bitexact $(TARGET_PATH)/$@ -y 2>/dev/null
+
+FATE_HEVC-$(call ALLYES, HEVC_DEMUXER MOV_DEMUXER HEVC_MP4TOANNEXB_BSF 
MOV_MUXER HEVC_MUXER) += fate-hevc-bsf-mp4toannexb
+fate-hevc-bsf-mp4toannexb: tests/data/hevc-mp4.mov
+fate-hevc-bsf-mp4toannexb: CMD = md5 -i $(TARGET_PATH)/tests/data/hevc-mp4.mov 
-vcodec copy -fflags +bitexact -f hevc
+fate-hevc-bsf-mp4toannexb: CMP = oneline
+fate-hevc-bsf-mp4toannexb: REF = 1873662a3af1848c37e4eb25722c8df9
+
 FATE_HEVC-$(call DEMDEC, HEVC, HEVC) += $(FATE_HEVC)
 
 FATE_SAMPLES_AVCONV += $(FATE_HEVC-yes)

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


[FFmpeg-cvslog] lavf/movenc+dashenc: add automatic bitstream filtering

2016-10-24 Thread Rodger Combs
ffmpeg | branch: master | Rodger Combs  | Thu Apr  7 
19:36:39 2016 -0500| [42cb050a05020e9da18136b8cd65944b378b74eb] | committer: 
Rodger Combs

lavf/movenc+dashenc: add automatic bitstream filtering

This is disabled by default when the empty_moov flag is enabled

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

 libavformat/dashenc.c |  43 +++-
 libavformat/movenc.c  | 107 +++---
 2 files changed, 124 insertions(+), 26 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 0848052..534fa75 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -551,7 +551,7 @@ static int write_manifest(AVFormatContext *s, int final)
 return avpriv_io_move(temp_filename, s->filename);
 }
 
-static int dash_write_header(AVFormatContext *s)
+static int dash_init(AVFormatContext *s)
 {
 DASHContext *c = s->priv_data;
 int ret = 0, i;
@@ -643,7 +643,7 @@ static int dash_write_header(AVFormatContext *s)
 os->init_start_pos = 0;
 
 av_dict_set(&opts, "movflags", "frag_custom+dash+delay_moov", 0);
-if ((ret = avformat_write_header(ctx, &opts)) < 0)
+if ((ret = avformat_init_output(ctx, &opts)) < 0)
 return ret;
 os->ctx_inited = 1;
 avio_flush(ctx->pb);
@@ -682,6 +682,20 @@ static int dash_write_header(AVFormatContext *s)
 av_log(s, AV_LOG_WARNING, "no video stream and no min seg duration 
set\n");
 return AVERROR(EINVAL);
 }
+return 0;
+}
+
+static int dash_write_header(AVFormatContext *s)
+{
+DASHContext *c = s->priv_data;
+int i, ret;
+for (i = 0; i < s->nb_streams; i++) {
+OutputStream *os = &c->streams[i];
+if ((ret = avformat_write_header(os->ctx, NULL)) < 0) {
+dash_free(s);
+return ret;
+}
+}
 ret = write_manifest(s, 0);
 if (!ret)
 av_log(s, AV_LOG_VERBOSE, "Manifest written to: %s\n", s->filename);
@@ -978,6 +992,29 @@ static int dash_write_trailer(AVFormatContext *s)
 return 0;
 }
 
+static int dash_check_bitstream(struct AVFormatContext *s, const AVPacket 
*avpkt)
+{
+DASHContext *c = s->priv_data;
+OutputStream *os = &c->streams[avpkt->stream_index];
+AVFormatContext *oc = os->ctx;
+if (oc->oformat->check_bitstream) {
+int ret;
+AVPacket pkt = *avpkt;
+pkt.stream_index = 0;
+ret = oc->oformat->check_bitstream(oc, &pkt);
+if (ret == 1) {
+AVStream *st = s->streams[avpkt->stream_index];
+AVStream *ost = oc->streams[0];
+st->internal->bsfcs = ost->internal->bsfcs;
+st->internal->nb_bsfcs = ost->internal->nb_bsfcs;
+ost->internal->bsfcs = NULL;
+ost->internal->nb_bsfcs = 0;
+}
+return ret;
+}
+return 1;
+}
+
 #define OFFSET(x) offsetof(DASHContext, x)
 #define E AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
@@ -1008,10 +1045,12 @@ AVOutputFormat ff_dash_muxer = {
 .audio_codec= AV_CODEC_ID_AAC,
 .video_codec= AV_CODEC_ID_H264,
 .flags  = AVFMT_GLOBALHEADER | AVFMT_NOFILE | AVFMT_TS_NEGATIVE,
+.init   = dash_init,
 .write_header   = dash_write_header,
 .write_packet   = dash_write_packet,
 .write_trailer  = dash_write_trailer,
 .deinit = dash_free,
 .codec_tag  = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 },
+.check_bitstream = dash_check_bitstream,
 .priv_class = &dash_class,
 };
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 4b6aa76..6228192 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5459,11 +5459,10 @@ static int 
mov_create_dvd_sub_decoder_specific_info(MOVTrack *track,
 return 0;
 }
 
-static int mov_write_header(AVFormatContext *s)
+static int mov_init(AVFormatContext *s)
 {
-AVIOContext *pb = s->pb;
 MOVMuxContext *mov = s->priv_data;
-AVDictionaryEntry *t, *global_tcr = av_dict_get(s->metadata, "timecode", 
NULL, 0);
+AVDictionaryEntry *global_tcr = av_dict_get(s->metadata, "timecode", NULL, 
0);
 int i, ret, hint_track = 0, tmcd_track = 0;
 
 mov->fc = s;
@@ -5500,6 +5499,11 @@ static int mov_write_header(AVFormatContext *s)
 mov->flags |= FF_MOV_FLAG_FRAGMENT | FF_MOV_FLAG_EMPTY_MOOV |
   FF_MOV_FLAG_DEFAULT_BASE_MOOF;
 
+if (mov->flags & FF_MOV_FLAG_EMPTY_MOOV && s->flags & AVFMT_FLAG_AUTO_BSF) 
{
+av_log(s, AV_LOG_VERBOSE, "Empty MOOV enabled; disabling automatic 
bitstream filtering\n");
+s->flags &= ~AVFMT_FLAG_AUTO_BSF;
+}
+
 if (mov->flags & FF_MOV_FLAG_FASTSTART) {
 mov->reserved_moov_size = -1;
 }
@@ -5546,11 +5550,6 @@ static int mov_write_header(AVFormatContext *s)
 return AVERROR(EINVAL);
 }
 
-if (!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {
-if ((ret = mov_write_id

[FFmpeg-cvslog] fate/aac: add automatic bsf test

2016-10-24 Thread Rodger Combs
ffmpeg | branch: master | Rodger Combs  | Fri Apr 15 
03:18:01 2016 -0500| [ed4e081a362d24b878201c2a3a289f9a5ec40a15] | committer: 
Rodger Combs

fate/aac: add automatic bsf test

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

 tests/fate/aac.mak | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak
index 3d64031..9ce8efb 100644
--- a/tests/fate/aac.mak
+++ b/tests/fate/aac.mak
@@ -241,6 +241,10 @@ FATE_AAC_LATM += fate-aac-latm_stereo_to_51
 fate-aac-latm_stereo_to_51: CMD = pcm -i 
$(TARGET_SAMPLES)/aac/latm_stereo_to_51.ts -channel_layout 5.1
 fate-aac-latm_stereo_to_51: REF = $(SAMPLES)/aac/latm_stereo_to_51_ref.s16
 
+fate-aac-autobsf-adtstoasc: CMD = md5 -i 
$(TARGET_SAMPLES)/audiomatch/tones_afconvert_16000_mono_aac_lc.adts -acodec 
copy -fflags +bitexact -f matroska
+fate-aac-autobsf-adtstoasc: CMP = oneline
+fate-aac-autobsf-adtstoasc: REF = 8c6fbebb64ebbe9e01b345d77844d7cd
+
 FATE_AAC-$(call  DEMDEC, AAC,AAC)  += $(FATE_AAC_CT_RAW)
 FATE_AAC-$(call  DEMDEC, MOV,AAC)  += $(FATE_AAC)
 FATE_AAC_LATM-$(call DEMDEC, MPEGTS, AAC_LATM) += $(FATE_AAC_LATM)
@@ -253,7 +257,9 @@ $(FATE_AAC_ALL): FUZZ = 2
 
 FATE_AAC_ENCODE-$(call ENCMUX, AAC, ADTS) += $(FATE_AAC_ENCODE)
 
-FATE_SAMPLES_FFMPEG += $(FATE_AAC_ALL) $(FATE_AAC_ENCODE-yes)
+FATE_AAC_BSF-$(call ALLYES, AAC_DEMUXER AAC_ADTSTOASC_BSF MATROSKA_MUXER) += 
fate-aac-autobsf-adtstoasc
+
+FATE_SAMPLES_FFMPEG += $(FATE_AAC_ALL) $(FATE_AAC_ENCODE-yes) 
$(FATE_AAC_BSF-yes)
 
-fate-aac: $(FATE_AAC_ALL) $(FATE_AAC_ENCODE)
+fate-aac: $(FATE_AAC_ALL) $(FATE_AAC_ENCODE) $(FATE_AAC_BSF-yes)
 fate-aac-latm: $(FATE_AAC_LATM-yes)

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


[FFmpeg-cvslog] lavf/rawenc: add automatic bitstream filtering for H264+HEVC

2016-10-24 Thread Rodger Combs
ffmpeg | branch: master | Rodger Combs  | Fri Sep  9 
23:27:54 2016 -0500| [d99d7cbdfc70023cd9692c19376772215d3a15b5] | committer: 
Rodger Combs

lavf/rawenc: add automatic bitstream filtering for H264+HEVC

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

 libavformat/rawenc.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
index c4d7a90..730e99a 100644
--- a/libavformat/rawenc.c
+++ b/libavformat/rawenc.c
@@ -20,8 +20,11 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/intreadwrite.h"
+
 #include "avformat.h"
 #include "rawenc.h"
+#include "internal.h"
 
 int ff_raw_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
@@ -236,6 +239,15 @@ AVOutputFormat ff_h263_muxer = {
 #endif
 
 #if CONFIG_H264_MUXER
+static int h264_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
+{
+AVStream *st = s->streams[0];
+if (pkt->size >= 5 && AV_RB32(pkt->data) != 0x001 &&
+  AV_RB24(pkt->data) != 0x01)
+return ff_stream_add_bitstream_filter(st, "h264_mp4toannexb", NULL);
+return 1;
+}
+
 AVOutputFormat ff_h264_muxer = {
 .name  = "h264",
 .long_name = NULL_IF_CONFIG_SMALL("raw H.264 video"),
@@ -244,11 +256,21 @@ AVOutputFormat ff_h264_muxer = {
 .video_codec   = AV_CODEC_ID_H264,
 .write_header  = force_one_stream,
 .write_packet  = ff_raw_write_packet,
+.check_bitstream   = h264_check_bitstream,
 .flags = AVFMT_NOTIMESTAMPS,
 };
 #endif
 
 #if CONFIG_HEVC_MUXER
+static int hevc_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt)
+{
+AVStream *st = s->streams[0];
+if (pkt->size >= 5 && AV_RB32(pkt->data) != 0x001 &&
+  AV_RB24(pkt->data) != 0x01)
+return ff_stream_add_bitstream_filter(st, "hevc_mp4toannexb", NULL);
+return 1;
+}
+
 AVOutputFormat ff_hevc_muxer = {
 .name  = "hevc",
 .long_name = NULL_IF_CONFIG_SMALL("raw HEVC video"),
@@ -257,6 +279,7 @@ AVOutputFormat ff_hevc_muxer = {
 .video_codec   = AV_CODEC_ID_HEVC,
 .write_header  = force_one_stream,
 .write_packet  = ff_raw_write_packet,
+.check_bitstream   = hevc_check_bitstream,
 .flags = AVFMT_NOTIMESTAMPS,
 };
 #endif

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


[FFmpeg-cvslog] lavf/segment: fix writing separate header with auto BSF

2016-10-24 Thread Rodger Combs
ffmpeg | branch: master | Rodger Combs  | Thu Apr  7 
19:18:45 2016 -0500| [45f5c5573203a48acb2dd6fbf18f4b0c25b7aff0] | committer: 
Rodger Combs

lavf/segment: fix writing separate header with auto BSF

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

 libavformat/segment.c | 29 -
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index a0beda2..868f0a8 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -89,6 +89,7 @@ typedef struct SegmentContext {
 int64_t last_val;  ///< remember last time for wrap around detection
 int64_t last_cut;  ///< remember last cut
 int cut_pending;
+int header_written;///< whether we've already called 
avformat_write_header
 
 char *entry_prefix;///< prefix to add to list entry filenames
 int list_type; ///< set the list type
@@ -260,6 +261,7 @@ static int segment_start(AVFormatContext *s, int 
write_header)
 if (write_header) {
 AVDictionary *options = NULL;
 av_dict_copy(&options, seg->format_options, 0);
+av_dict_set(&options, "fflags", "-autobsf", 0);
 err = avformat_write_header(oc, &options);
 av_dict_free(&options);
 if (err < 0)
@@ -756,7 +758,8 @@ static int seg_init(AVFormatContext *s)
 }
 
 av_dict_copy(&options, seg->format_options, 0);
-ret = avformat_write_header(oc, &options);
+av_dict_set(&options, "fflags", "-autobsf", 0);
+ret = avformat_init_output(oc, &options);
 if (av_dict_count(options)) {
 av_log(s, AV_LOG_ERROR,
"Some of the provided format options in '%s' are not 
recognized\n", seg->format_options_str);
@@ -772,6 +775,13 @@ static int seg_init(AVFormatContext *s)
 seg->segment_frame_count = 0;
 
 av_assert0(s->nb_streams == oc->nb_streams);
+if (ret == AVSTREAM_INIT_IN_WRITE_HEADER) {
+ret = avformat_write_header(oc, NULL);
+if (ret < 0)
+return ret;
+seg->header_written = 1;
+}
+
 for (i = 0; i < s->nb_streams; i++) {
 AVStream *inner_st  = oc->streams[i];
 AVStream *outer_st = s->streams[i];
@@ -781,6 +791,21 @@ static int seg_init(AVFormatContext *s)
 if (oc->avoid_negative_ts > 0 && s->avoid_negative_ts < 0)
 s->avoid_negative_ts = 1;
 
+return ret;
+}
+
+static int seg_write_header(AVFormatContext *s)
+{
+SegmentContext *seg = s->priv_data;
+AVFormatContext *oc = seg->avf;
+int ret;
+
+if (!seg->header_written) {
+ret = avformat_write_header(oc, NULL);
+if (ret < 0)
+return ret;
+}
+
 if (!seg->write_header_trailer || seg->header_filename) {
 if (seg->header_filename) {
 av_write_frame(oc, NULL);
@@ -1012,6 +1037,7 @@ AVOutputFormat ff_segment_muxer = {
 .priv_data_size = sizeof(SegmentContext),
 .flags  = AVFMT_NOFILE|AVFMT_GLOBALHEADER,
 .init   = seg_init,
+.write_header   = seg_write_header,
 .write_packet   = seg_write_packet,
 .write_trailer  = seg_write_trailer,
 .deinit = seg_free,
@@ -1031,6 +1057,7 @@ AVOutputFormat ff_stream_segment_muxer = {
 .priv_data_size = sizeof(SegmentContext),
 .flags  = AVFMT_NOFILE,
 .init   = seg_init,
+.write_header   = seg_write_header,
 .write_packet   = seg_write_packet,
 .write_trailer  = seg_write_trailer,
 .deinit = seg_free,

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


[FFmpeg-cvslog] lavf/segment: add deinit function

2016-10-24 Thread Rodger Combs
ffmpeg | branch: master | Rodger Combs  | Thu Apr  7 
19:18:19 2016 -0500| [c7cd6ad8509c7382664f5bfb7112df69b44f41e4] | committer: 
Rodger Combs

lavf/segment: add deinit function

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

 libavformat/segment.c | 47 ---
 1 file changed, 20 insertions(+), 27 deletions(-)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index 55dcaf0..a0beda2 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -627,8 +627,9 @@ static int select_reference_stream(AVFormatContext *s)
 return 0;
 }
 
-static void seg_free_context(SegmentContext *seg)
+static void seg_free(AVFormatContext *s)
 {
+SegmentContext *seg = s->priv_data;
 ff_format_io_close(seg->avf, &seg->list_pb);
 avformat_free_context(seg->avf);
 seg->avf = NULL;
@@ -693,7 +694,7 @@ static int seg_init(AVFormatContext *s)
 if (ret < 0) {
 av_log(s, AV_LOG_ERROR, "Could not parse format options list 
'%s'\n",
seg->format_options_str);
-goto fail;
+return ret;
 }
 }
 
@@ -707,7 +708,7 @@ static int seg_init(AVFormatContext *s)
 }
 if (!seg->list_size && seg->list_type != LIST_TYPE_M3U8) {
 if ((ret = segment_list_open(s)) < 0)
-goto fail;
+return ret;
 } else {
 const char *proto = avio_find_protocol_name(seg->list);
 seg->use_rename = proto && !strcmp(proto, "file");
@@ -718,29 +719,26 @@ static int seg_init(AVFormatContext *s)
 av_log(s, AV_LOG_WARNING, "'ext' list type option is deprecated in 
favor of 'csv'\n");
 
 if ((ret = select_reference_stream(s)) < 0)
-goto fail;
+return ret;
 av_log(s, AV_LOG_VERBOSE, "Selected stream id:%d type:%s\n",
seg->reference_stream_index,

av_get_media_type_string(s->streams[seg->reference_stream_index]->codecpar->codec_type));
 
 seg->oformat = av_guess_format(seg->format, s->filename, NULL);
 
-if (!seg->oformat) {
-ret = AVERROR_MUXER_NOT_FOUND;
-goto fail;
-}
+if (!seg->oformat)
+return AVERROR_MUXER_NOT_FOUND;
 if (seg->oformat->flags & AVFMT_NOFILE) {
 av_log(s, AV_LOG_ERROR, "format %s not supported.\n",
seg->oformat->name);
-ret = AVERROR(EINVAL);
-goto fail;
+return AVERROR(EINVAL);
 }
 
 if ((ret = segment_mux_init(s)) < 0)
-goto fail;
+return ret;
 
 if ((ret = set_segment_filename(s)) < 0)
-goto fail;
+return ret;
 oc = seg->avf;
 
 if (seg->write_header_trailer) {
@@ -748,13 +746,13 @@ static int seg_init(AVFormatContext *s)
   seg->header_filename ? seg->header_filename : 
oc->filename,
   AVIO_FLAG_WRITE, NULL)) < 0) {
 av_log(s, AV_LOG_ERROR, "Failed to open segment '%s'\n", 
oc->filename);
-goto fail;
+return ret;
 }
 if (!seg->individual_header_trailer)
 oc->pb->seekable = 0;
 } else {
 if ((ret = open_null_ctx(&oc->pb)) < 0)
-goto fail;
+return ret;
 }
 
 av_dict_copy(&options, seg->format_options, 0);
@@ -762,13 +760,14 @@ static int seg_init(AVFormatContext *s)
 if (av_dict_count(options)) {
 av_log(s, AV_LOG_ERROR,
"Some of the provided format options in '%s' are not 
recognized\n", seg->format_options_str);
-ret = AVERROR(EINVAL);
-goto fail;
+av_dict_free(&options);
+return AVERROR(EINVAL);
 }
+av_dict_free(&options);
 
 if (ret < 0) {
 ff_format_io_close(oc, &oc->pb);
-goto fail;
+return ret;
 }
 seg->segment_frame_count = 0;
 
@@ -790,17 +789,12 @@ static int seg_init(AVFormatContext *s)
 close_null_ctxp(&oc->pb);
 }
 if ((ret = oc->io_open(oc, &oc->pb, oc->filename, AVIO_FLAG_WRITE, 
NULL)) < 0)
-goto fail;
+return ret;
 if (!seg->individual_header_trailer)
 oc->pb->seekable = 0;
 }
 
-fail:
-av_dict_free(&options);
-if (ret < 0)
-seg_free_context(seg);
-
-return ret;
+return 0;
 }
 
 static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
@@ -913,9 +907,6 @@ fail:
 seg->segment_frame_count++;
 }
 
-if (ret < 0)
-seg_free_context(seg);
-
 return ret;
 }
 
@@ -1023,6 +1014,7 @@ AVOutputFormat ff_segment_muxer = {
 .init   = seg_init,
 .write_packet   = seg_write_packet,
 .write_trailer  = seg_write_trailer,
+.deinit = seg_free,
 .priv_class = &seg_class,
 };
 
@@ -1041,5 +1033,6 @@ AVOutputFormat ff_stream_segment_muxer = {
 .init   = seg_init,
 .write_packet   = seg_write_packet,
 .write_trailer  = seg_w

[FFmpeg-cvslog] lavf/dashenc: add deinit function

2016-10-24 Thread Rodger Combs
ffmpeg | branch: master | Rodger Combs  | Thu Apr  7 
19:36:15 2016 -0500| [c972a28fc3defe7cacee281fe1a30b9a026737ed] | committer: 
Rodger Combs

lavf/dashenc: add deinit function

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

 libavformat/dashenc.c | 51 +--
 1 file changed, 17 insertions(+), 34 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 519f9c4..0848052 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -580,16 +580,12 @@ static int dash_write_header(AVFormatContext *s)
 *ptr = '\0';
 
 oformat = av_guess_format("mp4", NULL, NULL);
-if (!oformat) {
-ret = AVERROR_MUXER_NOT_FOUND;
-goto fail;
-}
+if (!oformat)
+return AVERROR_MUXER_NOT_FOUND;
 
 c->streams = av_mallocz(sizeof(*c->streams) * s->nb_streams);
-if (!c->streams) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+if (!c->streams)
+return AVERROR(ENOMEM);
 
 for (i = 0; i < s->nb_streams; i++) {
 OutputStream *os = &c->streams[i];
@@ -606,17 +602,13 @@ static int dash_write_header(AVFormatContext *s)
 int level = s->strict_std_compliance >= FF_COMPLIANCE_STRICT ?
 AV_LOG_ERROR : AV_LOG_WARNING;
 av_log(s, level, "No bit rate set for stream %d\n", i);
-if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT) {
-ret = AVERROR(EINVAL);
-goto fail;
-}
+if (s->strict_std_compliance >= FF_COMPLIANCE_STRICT)
+return AVERROR(EINVAL);
 }
 
 ctx = avformat_alloc_context();
-if (!ctx) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+if (!ctx)
+return AVERROR(ENOMEM);
 os->ctx = ctx;
 ctx->oformat = oformat;
 ctx->interrupt_callback = s->interrupt_callback;
@@ -624,10 +616,8 @@ static int dash_write_header(AVFormatContext *s)
 ctx->io_close   = s->io_close;
 ctx->io_open= s->io_open;
 
-if (!(st = avformat_new_stream(ctx, NULL))) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+if (!(st = avformat_new_stream(ctx, NULL)))
+return AVERROR(ENOMEM);
 avcodec_parameters_copy(st->codecpar, s->streams[i]->codecpar);
 st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio;
 st->time_base = s->streams[i]->time_base;
@@ -635,10 +625,8 @@ static int dash_write_header(AVFormatContext *s)
 ctx->flags = s->flags;
 
 ctx->pb = avio_alloc_context(os->iobuf, sizeof(os->iobuf), 
AVIO_FLAG_WRITE, os, NULL, dash_write, NULL);
-if (!ctx->pb) {
-ret = AVERROR(ENOMEM);
-goto fail;
-}
+if (!ctx->pb)
+return AVERROR(ENOMEM);
 
 if (c->single_file) {
 if (c->single_file_name)
@@ -651,13 +639,12 @@ static int dash_write_header(AVFormatContext *s)
 snprintf(filename, sizeof(filename), "%s%s", c->dirname, os->initfile);
 ret = s->io_open(s, &os->out, filename, AVIO_FLAG_WRITE, NULL);
 if (ret < 0)
-goto fail;
+return ret;
 os->init_start_pos = 0;
 
 av_dict_set(&opts, "movflags", "frag_custom+dash+delay_moov", 0);
-if ((ret = avformat_write_header(ctx, &opts)) < 0) {
- goto fail;
-}
+if ((ret = avformat_write_header(ctx, &opts)) < 0)
+return ret;
 os->ctx_inited = 1;
 avio_flush(ctx->pb);
 av_dict_free(&opts);
@@ -693,15 +680,11 @@ static int dash_write_header(AVFormatContext *s)
 
 if (!c->has_video && c->min_seg_duration <= 0) {
 av_log(s, AV_LOG_WARNING, "no video stream and no min seg duration 
set\n");
-ret = AVERROR(EINVAL);
+return AVERROR(EINVAL);
 }
 ret = write_manifest(s, 0);
 if (!ret)
 av_log(s, AV_LOG_VERBOSE, "Manifest written to: %s\n", s->filename);
-
-fail:
-if (ret)
-dash_free(s);
 return ret;
 }
 
@@ -992,7 +975,6 @@ static int dash_write_trailer(AVFormatContext *s)
 unlink(s->filename);
 }
 
-dash_free(s);
 return 0;
 }
 
@@ -1029,6 +1011,7 @@ AVOutputFormat ff_dash_muxer = {
 .write_header   = dash_write_header,
 .write_packet   = dash_write_packet,
 .write_trailer  = dash_write_trailer,
+.deinit = dash_free,
 .codec_tag  = (const AVCodecTag* const []){ ff_mp4_obj_type, 0 },
 .priv_class = &dash_class,
 };

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


[FFmpeg-cvslog] lavf/mux: add avformat_init_output

2016-10-24 Thread Rodger Combs
ffmpeg | branch: master | Rodger Combs  | Fri Jun 24 
22:02:50 2016 -0500| [a246fef163387c0d79830a9bdf408443a9aba1c1] | committer: 
Rodger Combs

lavf/mux: add avformat_init_output

This allows a consumer to run the muxer's init function without actually
writing the header, which is useful in chained muxers that support
automatic bitstream filtering.

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

 doc/APIchanges |  3 +++
 libavformat/avformat.h | 34 +++--
 libavformat/internal.h | 10 
 libavformat/mux.c  | 68 +++---
 libavformat/version.h  |  2 +-
 5 files changed, 100 insertions(+), 17 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 502ab3f..5017eb4 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2015-08-28
 
 API changes, most recent first:
 
+2016-10-24 - xxx - lavf 57.54.100 - avformat.h
+  Add avformat_init_output() and AVSTREAM_INIT_IN_ macros
+
 2016-10-22 - xxx - lavu 55.33.100 - avassert.h
   Add av_assert0_fpu() / av_assert2_fpu()
 
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 057f8c5..82ca727 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -618,6 +618,8 @@ typedef struct AVOutputFormat {
  * AVStream parameters that need to be set before packets are sent.
  * This method must not write output.
  *
+ * Return 0 if streams were fully configured, 1 if not, negative AVERROR 
on failure
+ *
  * Any allocations made here must be freed in deinit().
  */
 int (*init)(struct AVFormatContext *);
@@ -2374,6 +2376,10 @@ void avformat_close_input(AVFormatContext **s);
  * @addtogroup lavf_encoding
  * @{
  */
+
+#define AVSTREAM_INIT_IN_WRITE_HEADER 0 ///< stream parameters initialized in 
avformat_write_header
+#define AVSTREAM_INIT_IN_INIT_OUTPUT  1 ///< stream parameters initialized in 
avformat_init_output
+
 /**
  * Allocate the stream private data and write the stream header to
  * an output media file.
@@ -2385,14 +2391,38 @@ void avformat_close_input(AVFormatContext **s);
  * On return this parameter will be destroyed and replaced 
with a dict containing
  * options that were not found. May be NULL.
  *
- * @return 0 on success, negative AVERROR on failure.
+ * @return AVSTREAM_INIT_IN_WRITE_HEADER on success if the codec had not 
already been fully initialized in avformat_init,
+ * AVSTREAM_INIT_IN_INIT_OUTPUT  on success if the codec had already 
been fully initialized in avformat_init,
+ * negative AVERROR on failure.
  *
- * @see av_opt_find, av_dict_set, avio_open, av_oformat_next.
+ * @see av_opt_find, av_dict_set, avio_open, av_oformat_next, 
avformat_init_output.
  */
 av_warn_unused_result
 int avformat_write_header(AVFormatContext *s, AVDictionary **options);
 
 /**
+ * Allocate the stream private data and initialize the codec, but do not write 
the header.
+ * May optionally be used before avformat_write_header to initialize stream 
parameters
+ * before actually writing the header.
+ * If using this function, do not pass the same options to 
avformat_write_header.
+ *
+ * @param s Media file handle, must be allocated with avformat_alloc_context().
+ *  Its oformat field must be set to the desired output format;
+ *  Its pb field must be set to an already opened AVIOContext.
+ * @param options  An AVDictionary filled with AVFormatContext and 
muxer-private options.
+ * On return this parameter will be destroyed and replaced 
with a dict containing
+ * options that were not found. May be NULL.
+ *
+ * @return AVSTREAM_INIT_IN_WRITE_HEADER on success if the codec requires 
avformat_write_header to fully initialize,
+ * AVSTREAM_INIT_IN_INIT_OUTPUT  on success if the codec has been 
fully initialized,
+ * negative AVERROR on failure.
+ *
+ * @see av_opt_find, av_dict_set, avio_open, av_oformat_next, 
avformat_write_header.
+ */
+av_warn_unused_result
+int avformat_init_output(AVFormatContext *s, AVDictionary **options);
+
+/**
  * Write a packet to an output media file.
  *
  * This function passes the packet directly to the muxer, without any buffering
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 95776a0..da64c64 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -130,6 +130,16 @@ struct AVFormatInternal {
  * Timestamp of the end of the shortest stream.
  */
 int64_t shortest_end;
+
+/**
+ * Whether or not avformat_init_output has already been called
+ */
+int initialized;
+
+/**
+ * Whether or not avformat_init_output fully initialized streams
+ */
+int streams_initialized;
 };
 
 struct AVStreamInternal {
diff --git a/libavformat/mux.c b/libavformat/mux.c
index bbfc0fc..06d87de 100644
--- a/libavformat/mux.c
+++ b/libavformat

[FFmpeg-cvslog] lavf/mov: improve `tref/chap` chapter handling

2016-10-24 Thread Rodger Combs
ffmpeg | branch: master | Rodger Combs  | Thu Jan  7 
17:14:08 2016 -0600| [697400eac07c0614f6b9f2e7615563982dbcbe4a] | committer: 
Rodger Combs

lavf/mov: improve `tref/chap` chapter handling

3 parts:
- Supports multiple chapter streams
- Exports regular text chapter streams as opaque data. This prevents consumers
  from showing chapters as if they were regular subtitle streams.
- Exports video chapter streams as thumbnails, and provides the first one as
  an attached_pic.

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

 libavformat/isom.h |  3 ++-
 libavformat/mov.c  | 54 +++---
 2 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 2246fed..9038057 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -210,7 +210,8 @@ typedef struct MOVContext {
 unsigned trex_count;
 int itunes_metadata;  ///< metadata are itunes style
 int handbrake_version;
-int chapter_track;
+int *chapter_tracks;
+unsigned int nb_chapter_tracks;
 int use_absolute_path;
 int ignore_editlist;
 int ignore_chapters;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index dada1e0..bf25db9 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3992,7 +3992,20 @@ static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 
 static int mov_read_chap(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 {
-c->chapter_track = avio_rb32(pb);
+unsigned i, num;
+void *new_tracks;
+
+num = atom.size / 4;
+if (!(new_tracks = av_malloc_array(num, sizeof(int
+return AVERROR(ENOMEM);
+
+av_free(c->chapter_tracks);
+c->chapter_tracks = new_tracks;
+c->nb_chapter_tracks = num;
+
+for (i = 0; i < num && !pb->eof_reached; i++)
+c->chapter_tracks[i] = avio_rb32(pb);
+
 return 0;
 }
 
@@ -5055,25 +5068,50 @@ static int mov_probe(AVProbeData *p)
 static void mov_read_chapters(AVFormatContext *s)
 {
 MOVContext *mov = s->priv_data;
-AVStream *st = NULL;
+AVStream *st;
 MOVStreamContext *sc;
 int64_t cur_pos;
-int i;
+int i, j;
+int chapter_track;
 
+for (j = 0; j < mov->nb_chapter_tracks; j++) {
+chapter_track = mov->chapter_tracks[j];
+st = NULL;
 for (i = 0; i < s->nb_streams; i++)
-if (s->streams[i]->id == mov->chapter_track) {
+if (s->streams[i]->id == chapter_track) {
 st = s->streams[i];
 break;
 }
 if (!st) {
 av_log(s, AV_LOG_ERROR, "Referenced QT chapter track not found\n");
-return;
+continue;
 }
 
-st->discard = AVDISCARD_ALL;
 sc = st->priv_data;
 cur_pos = avio_tell(sc->pb);
 
+if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+st->disposition |= AV_DISPOSITION_ATTACHED_PIC | 
AV_DISPOSITION_TIMED_THUMBNAILS;
+if (st->nb_index_entries) {
+// Retrieve the first frame, if possible
+AVPacket pkt;
+AVIndexEntry *sample = &st->index_entries[0];
+if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
+av_log(s, AV_LOG_ERROR, "Failed to retrieve first frame\n");
+goto finish;
+}
+
+if (av_get_packet(sc->pb, &pkt, sample->size) < 0)
+goto finish;
+
+st->attached_pic  = pkt;
+st->attached_pic.stream_index = st->index;
+st->attached_pic.flags   |= AV_PKT_FLAG_KEY;
+}
+} else {
+st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
+st->codecpar->codec_id = AV_CODEC_ID_BIN_DATA;
+st->discard = AVDISCARD_ALL;
 for (i = 0; i < st->nb_index_entries; i++) {
 AVIndexEntry *sample = &st->index_entries[i];
 int64_t end = i+1 < st->nb_index_entries ? 
st->index_entries[i+1].timestamp : st->duration;
@@ -5122,8 +5160,10 @@ static void mov_read_chapters(AVFormatContext *s)
 avpriv_new_chapter(s, i, st->time_base, sample->timestamp, end, title);
 av_freep(&title);
 }
+}
 finish:
 avio_seek(sc->pb, cur_pos, SEEK_SET);
+}
 }
 
 static int parse_timecode_in_framenum_format(AVFormatContext *s, AVStream *st,
@@ -5446,7 +5486,7 @@ static int mov_read_header(AVFormatContext *s)
 av_log(mov->fc, AV_LOG_TRACE, "on_parse_exit_offset=%"PRId64"\n", 
avio_tell(pb));
 
 if (pb->seekable) {
-if (mov->chapter_track > 0 && !mov->ignore_chapters)
+if (mov->nb_chapter_tracks > 0 && !mov->ignore_chapters)
 mov_read_chapters(s);
 for (i = 0; i < s->nb_streams; i++)
 if (s->streams[i]->codecpar->codec_tag == AV_RL32("tmcd")) {

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


[FFmpeg-cvslog] lavf/mov: reindent

2016-10-24 Thread Rodger Combs
ffmpeg | branch: master | Rodger Combs  | Thu Jan  7 
19:04:00 2016 -0600| [490c6bda0e35498a24936fd1524317aeebed026b] | committer: 
Rodger Combs

lavf/mov: reindent

Reviewed-By: Michael Niedermayer 

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

 libavformat/mov.c | 156 +++---
 1 file changed, 78 insertions(+), 78 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index bf25db9..357d800 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -5075,94 +5075,94 @@ static void mov_read_chapters(AVFormatContext *s)
 int chapter_track;
 
 for (j = 0; j < mov->nb_chapter_tracks; j++) {
-chapter_track = mov->chapter_tracks[j];
-st = NULL;
-for (i = 0; i < s->nb_streams; i++)
-if (s->streams[i]->id == chapter_track) {
-st = s->streams[i];
-break;
+chapter_track = mov->chapter_tracks[j];
+st = NULL;
+for (i = 0; i < s->nb_streams; i++)
+if (s->streams[i]->id == chapter_track) {
+st = s->streams[i];
+break;
+}
+if (!st) {
+av_log(s, AV_LOG_ERROR, "Referenced QT chapter track not found\n");
+continue;
 }
-if (!st) {
-av_log(s, AV_LOG_ERROR, "Referenced QT chapter track not found\n");
-continue;
-}
 
-sc = st->priv_data;
-cur_pos = avio_tell(sc->pb);
+sc = st->priv_data;
+cur_pos = avio_tell(sc->pb);
+
+if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
+st->disposition |= AV_DISPOSITION_ATTACHED_PIC | 
AV_DISPOSITION_TIMED_THUMBNAILS;
+if (st->nb_index_entries) {
+// Retrieve the first frame, if possible
+AVPacket pkt;
+AVIndexEntry *sample = &st->index_entries[0];
+if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
+av_log(s, AV_LOG_ERROR, "Failed to retrieve first 
frame\n");
+goto finish;
+}
 
-if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
-st->disposition |= AV_DISPOSITION_ATTACHED_PIC | 
AV_DISPOSITION_TIMED_THUMBNAILS;
-if (st->nb_index_entries) {
-// Retrieve the first frame, if possible
-AVPacket pkt;
-AVIndexEntry *sample = &st->index_entries[0];
-if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
-av_log(s, AV_LOG_ERROR, "Failed to retrieve first frame\n");
-goto finish;
-}
+if (av_get_packet(sc->pb, &pkt, sample->size) < 0)
+goto finish;
 
-if (av_get_packet(sc->pb, &pkt, sample->size) < 0)
-goto finish;
+st->attached_pic  = pkt;
+st->attached_pic.stream_index = st->index;
+st->attached_pic.flags   |= AV_PKT_FLAG_KEY;
+}
+} else {
+st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
+st->codecpar->codec_id = AV_CODEC_ID_BIN_DATA;
+st->discard = AVDISCARD_ALL;
+for (i = 0; i < st->nb_index_entries; i++) {
+AVIndexEntry *sample = &st->index_entries[i];
+int64_t end = i+1 < st->nb_index_entries ? 
st->index_entries[i+1].timestamp : st->duration;
+uint8_t *title;
+uint16_t ch;
+int len, title_len;
+
+if (end < sample->timestamp) {
+av_log(s, AV_LOG_WARNING, "ignoring stream duration which 
is shorter than chapters\n");
+end = AV_NOPTS_VALUE;
+}
 
-st->attached_pic  = pkt;
-st->attached_pic.stream_index = st->index;
-st->attached_pic.flags   |= AV_PKT_FLAG_KEY;
-}
-} else {
-st->codecpar->codec_type = AVMEDIA_TYPE_DATA;
-st->codecpar->codec_id = AV_CODEC_ID_BIN_DATA;
-st->discard = AVDISCARD_ALL;
-for (i = 0; i < st->nb_index_entries; i++) {
-AVIndexEntry *sample = &st->index_entries[i];
-int64_t end = i+1 < st->nb_index_entries ? 
st->index_entries[i+1].timestamp : st->duration;
-uint8_t *title;
-uint16_t ch;
-int len, title_len;
-
-if (end < sample->timestamp) {
-av_log(s, AV_LOG_WARNING, "ignoring stream duration which is 
shorter than chapters\n");
-end = AV_NOPTS_VALUE;
-}
+if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
+av_log(s, AV_LOG_ERROR, "Chapter %d not found in file\n", 
i);
+goto finish;
+}
 
-if (avio_seek(sc->pb, sample->pos, SEEK_SET) != sample->pos) {
-av_log(s, AV_LOG_ERROR, "Chapter %d not found in file\n", i);
-goto finish;
-}
+ 

[FFmpeg-cvslog] lavf: add AV_DISPOSITION_TIMED_THUMBNAILS

2016-10-24 Thread Rodger Combs
ffmpeg | branch: master | Rodger Combs  | Mon Oct 24 
05:47:05 2016 -0500| [73ead477ddd9dbfbe6f7e8d3fc90ebfd21b271b0] | committer: 
Rodger Combs

lavf: add AV_DISPOSITION_TIMED_THUMBNAILS

Reviewed-By: Michael Niedermayer 

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

 doc/APIchanges  |  3 +++
 doc/ffprobe.xsd |  1 +
 ffprobe.c   |  1 +
 libavformat/avformat.h  | 12 +---
 libavformat/version.h   |  2 +-
 tests/ref/fate/concat-demuxer-extended-lavf-mxf |  2 +-
 tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 |  2 +-
 tests/ref/fate/concat-demuxer-simple1-lavf-mxf  |  4 ++--
 tests/ref/fate/concat-demuxer-simple1-lavf-mxf_d10  |  4 ++--
 tests/ref/fate/concat-demuxer-simple2-lavf-ts   |  4 ++--
 tests/ref/fate/ffprobe_compact  |  6 +++---
 tests/ref/fate/ffprobe_csv  |  6 +++---
 tests/ref/fate/ffprobe_default  |  3 +++
 tests/ref/fate/ffprobe_flat |  3 +++
 tests/ref/fate/ffprobe_ini  |  3 +++
 tests/ref/fate/ffprobe_json |  9 ++---
 tests/ref/fate/ffprobe_xml  |  6 +++---
 17 files changed, 47 insertions(+), 24 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 5017eb4..eaa6e56 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil: 2015-08-28
 
 API changes, most recent first:
 
+2016-10-24 - xxx - lavf 57.55.100 - avformat.h
+  Add AV_DISPOSITION_TIMED_THUMBNAILS
+
 2016-10-24 - xxx - lavf 57.54.100 - avformat.h
   Add avformat_init_output() and AVSTREAM_INIT_IN_ macros
 
diff --git a/doc/ffprobe.xsd b/doc/ffprobe.xsd
index ac0347f..f64656a 100644
--- a/doc/ffprobe.xsd
+++ b/doc/ffprobe.xsd
@@ -166,6 +166,7 @@
   
   
   
+  
 
 
 
diff --git a/ffprobe.c b/ffprobe.c
index 7cd0034..a2980b3 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -2383,6 +2383,7 @@ static int show_stream(WriterContext *w, AVFormatContext 
*fmt_ctx, int stream_id
 PRINT_DISPOSITION(VISUAL_IMPAIRED,  "visual_impaired");
 PRINT_DISPOSITION(CLEAN_EFFECTS,"clean_effects");
 PRINT_DISPOSITION(ATTACHED_PIC, "attached_pic");
+PRINT_DISPOSITION(TIMED_THUMBNAILS, "timed_thumbnails");
 writer_print_section_footer(w);
 }
 
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 82ca727..f9f4d72 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -842,11 +842,17 @@ typedef struct AVIndexEntry {
 #define AV_DISPOSITION_CLEAN_EFFECTS 0x0200  /**< stream without voice */
 /**
  * The stream is stored in the file as an attached picture/"cover art" (e.g.
- * APIC frame in ID3v2). The single packet associated with it will be returned
- * among the first few packets read from the file unless seeking takes place.
- * It can also be accessed at any time in AVStream.attached_pic.
+ * APIC frame in ID3v2). The first (usually only) packet associated with it
+ * will be returned among the first few packets read from the file unless
+ * seeking takes place. It can also be accessed at any time in
+ * AVStream.attached_pic.
  */
 #define AV_DISPOSITION_ATTACHED_PIC  0x0400
+/**
+ * The stream is sparse, and contains thumbnail images, often corresponding
+ * to chapter markers. Only ever used with AV_DISPOSITION_ATTACHED_PIC.
+ */
+#define AV_DISPOSITION_TIMED_THUMBNAILS  0x0800
 
 typedef struct AVStreamInternal AVStreamInternal;
 
diff --git a/libavformat/version.h b/libavformat/version.h
index addff03..c4db5a5 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -32,7 +32,7 @@
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
 // Also please add any ticket numbers that you believe might be affected here
 #define LIBAVFORMAT_VERSION_MAJOR  57
-#define LIBAVFORMAT_VERSION_MINOR  54
+#define LIBAVFORMAT_VERSION_MINOR  55
 #define LIBAVFORMAT_VERSION_MICRO 100
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
diff --git a/tests/ref/fate/concat-demuxer-extended-lavf-mxf 
b/tests/ref/fate/concat-demuxer-extended-lavf-mxf
index 8bb2fb0..f6b1010 100644
--- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf
+++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf
@@ -1 +1 @@
-a277e04c23cf764abe692ca07e87b82e 
*tests/data/fate/concat-demuxer-extended-lavf-mxf.ffprobe
+32fe9ae5b89c7802c804ac51f62d89cb 
*tests/data/fate/concat-demuxer-extended-lavf-mxf.ffprobe
diff --git a/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10 
b/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
index e294538..6d84589 100644
--- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
+++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
@@ -1 +1 @@
-026045a43aa2dde1723d7331c2252

[FFmpeg-cvslog] vp9: change order of operations in adapt_prob().

2016-10-24 Thread Ronald S. Bultje
ffmpeg | branch: master | Ronald S. Bultje  | Fri Oct 14 
13:01:27 2016 -0400| [be885da3427c5d9a6fa68229d16318afffe67193] | committer: 
Ronald S. Bultje

vp9: change order of operations in adapt_prob().

This is intended to workaround bug "665 Integer Divide Instruction May
Cause Unpredictable Behavior" on some early AMD CPUs, which causes a
div-by-zero in this codepath, such as reported in Mozilla bug #1293996.

Note that this isn't guaranteed to fix the bug, since a compiler is free
to reorder instructions that don't depend on each other. However, it
appears to fix the bug in Firefox, and a similar patch was applied to
libvpx also (see Chrome bug #599899).

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

 libavcodec/vp9.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 779f2d5..1aab6ba 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -3705,11 +3705,10 @@ static av_always_inline void adapt_prob(uint8_t *p, 
unsigned ct0, unsigned ct1,
 if (!ct)
 return;
 
+update_factor = FASTDIV(update_factor * FFMIN(ct, max_count), max_count);
 p1 = *p;
-p2 = ((ct0 << 8) + (ct >> 1)) / ct;
+p2 = int64_t) ct0) << 8) + (ct >> 1)) / ct;
 p2 = av_clip(p2, 1, 255);
-ct = FFMIN(ct, max_count);
-update_factor = FASTDIV(update_factor * ct, max_count);
 
 // (p1 * (256 - update_factor) + p2 * update_factor + 128) >> 8
 *p = p1 + (((p2 - p1) * update_factor + 128) >> 8);

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


[FFmpeg-cvslog] vf_colorspace: don't spam console with warnings if range is unspecified.

2016-10-24 Thread Ronald S. Bultje
ffmpeg | branch: master | Ronald S. Bultje  | Mon Oct 24 
16:03:16 2016 -0400| [f141ac4d0bf1a05c77949edc9d679295fcc79f5f] | committer: 
Ronald S. Bultje

vf_colorspace: don't spam console with warnings if range is unspecified.

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

 libavfilter/vf_colorspace.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index 5b060f9..45b96c0 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -163,6 +163,8 @@ typedef struct ColorSpaceContext {
 yuv2yuv_fn yuv2yuv;
 double yuv2rgb_dbl_coeffs[3][3], rgb2yuv_dbl_coeffs[3][3];
 int in_y_rng, in_uv_rng, out_y_rng, out_uv_rng;
+
+int did_warn_range;
 } ColorSpaceContext;
 
 // FIXME deal with odd width/heights (or just forbid it)
@@ -523,8 +525,14 @@ static int get_range_off(AVFilterContext *ctx, int *off,
  enum AVColorRange rng, int depth)
 {
 switch (rng) {
-case AVCOL_RANGE_UNSPECIFIED:
-av_log(ctx, AV_LOG_WARNING, "Input range not set, assuming tv/mpeg\n");
+case AVCOL_RANGE_UNSPECIFIED: {
+ColorSpaceContext *s = ctx->priv;
+
+if (!s->did_warn_range) {
+av_log(ctx, AV_LOG_WARNING, "Input range not set, assuming 
tv/mpeg\n");
+s->did_warn_range = 1;
+}
+}
 // fall-through
 case AVCOL_RANGE_MPEG:
 *off = 16 << (depth - 8);

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


[FFmpeg-cvslog] vf_colorspace: Add support for iec61966-2.1 (sRGB) transfer

2016-10-24 Thread Vittorio Giovara
ffmpeg | branch: master | Vittorio Giovara  | Tue 
Oct 18 15:17:26 2016 -0400| [ba53d3ae8bfbd9a66b6f18569c1c4c4d0cc03d7a] | 
committer: Ronald S. Bultje

vf_colorspace: Add support for iec61966-2.1 (sRGB) transfer

Signed-off-by: Vittorio Giovara 
Signed-off-by: Ronald S. Bultje 

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

 libavfilter/vf_colorspace.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavfilter/vf_colorspace.c b/libavfilter/vf_colorspace.c
index 45b96c0..930aa95 100644
--- a/libavfilter/vf_colorspace.c
+++ b/libavfilter/vf_colorspace.c
@@ -231,6 +231,7 @@ static const struct TransferCharacteristics 
transfer_characteristics[AVCOL_TRC_N
 [AVCOL_TRC_GAMMA28]   = { 1.0,0.0,1.0 / 2.8, 0.0 },
 [AVCOL_TRC_SMPTE170M] = { 1.099,  0.018,  0.45, 4.5 },
 [AVCOL_TRC_SMPTE240M] = { 1.1115, 0.0228, 0.45, 4.0 },
+[AVCOL_TRC_IEC61966_2_1] = { 1.055, 0.0031308, 1.0 / 2.4, 12.92 },
 [AVCOL_TRC_BT2020_10] = { 1.099,  0.018,  0.45, 4.5 },
 [AVCOL_TRC_BT2020_12] = { 1.0993, 0.0181, 0.45, 4.5 },
 };
@@ -1075,6 +1076,8 @@ static const AVOption colorspace_options[] = {
 ENUM("gamma28",  AVCOL_TRC_GAMMA28,  "trc"),
 ENUM("smpte170m",AVCOL_TRC_SMPTE170M,"trc"),
 ENUM("smpte240m",AVCOL_TRC_SMPTE240M,"trc"),
+ENUM("srgb", AVCOL_TRC_IEC61966_2_1, "trc"),
+ENUM("iec61966-2-1", AVCOL_TRC_IEC61966_2_1, "trc"),
 ENUM("bt2020-10",AVCOL_TRC_BT2020_10,"trc"),
 ENUM("bt2020-12",AVCOL_TRC_BT2020_12,"trc"),
 

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


[FFmpeg-cvslog] avcodec/ffv1enc: Fix storing RGB48 without explicitly set level

2016-10-24 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue 
Oct 25 01:15:56 2016 +0200| [c1173437fc3e4ef36a0f19211a9cd4e5c95ccb6c] | 
committer: Michael Niedermayer

avcodec/ffv1enc: Fix storing RGB48 without explicitly set level

the bps value is only stored with level >= 1, using rgb48 with level 0 requires 
the
user app to keep track of the bps by external means, which does not always 
happen
also we force level >= 1 for other 16bps formats, so this is consistent.

Found-by: Jerome Martinez 
Signed-off-by: Michael Niedermayer 

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

 libavcodec/ffv1enc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index dae68ae..68d311d 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -629,6 +629,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 s->chroma_planes = 1;
 s->bits_per_raw_sample = 16;
 s->use32bit = 1;
+s->version = FFMAX(s->version, 1);
 if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
 av_log(avctx, AV_LOG_ERROR, "16bit RGB is experimental and under 
development, only use it for experiments\n");
 return AVERROR_INVALIDDATA;

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


[FFmpeg-cvslog] avcodec/interplayvideo: Check side data size before use

2016-10-24 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Tue 
Oct 25 03:51:17 2016 +0200| [85d23e5cbc9ad6835eef870a5b4247de78febe56] | 
committer: Michael Niedermayer

avcodec/interplayvideo: Check side data size before use

Fixes out of array read

Found-by: Thomas Garnier using libFuzzer
Signed-off-by: Michael Niedermayer 

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

 libavcodec/interplayvideo.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c
index aa03015..abfc935 100644
--- a/libavcodec/interplayvideo.c
+++ b/libavcodec/interplayvideo.c
@@ -1013,10 +1013,13 @@ static int ipvideo_decode_frame(AVCodecContext *avctx,
 return ret;
 
 if (!s->is_16bpp) {
-const uint8_t *pal = av_packet_get_side_data(avpkt, 
AV_PKT_DATA_PALETTE, NULL);
-if (pal) {
+int size;
+const uint8_t *pal = av_packet_get_side_data(avpkt, 
AV_PKT_DATA_PALETTE, &size);
+if (pal && size == AVPALETTE_SIZE) {
 frame->palette_has_changed = 1;
 memcpy(s->pal, pal, AVPALETTE_SIZE);
+} else if (pal) {
+av_log(avctx, AV_LOG_ERROR, "Palette size %d is wrong\n", size);
 }
 }
 

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