Re: [FFmpeg-devel] [FFmpeg-cvslog] avcodec/alsdec: Fix reading 0 mantisse bits

2016-09-09 Thread Thilo Borgmann
Am 08.09.16 um 23:41 schrieb James Almer:
>> ffmpeg | branch: master | Michael Niedermayer  | 
>> Thu Sep  8 22:02:44 2016 +0200| [037422178d7f1d0dd09e1ce424dd61a69e77668b] | 
>> committer: Michael Niedermayer
>>
>> avcodec/alsdec: Fix reading 0 mantisse bits
>>
>> Fixes assertion failure
>> Fixes: 
>> 848c24abc1721c9e3d1ba7bfee8d9fcc/asan_heap-oob_1d99eca_3709_567bba70d67e7d62714dcf56f26fb1da.mp4
>>
>> Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
>> Signed-off-by: Michael Niedermayer 
>>
>>> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=037422178d7f1d0dd09e1ce424dd61a69e77668b
>> ---
>>
>>  libavcodec/alsdec.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
>> index 1bb71f5..8c4ff53 100644
>> --- a/libavcodec/alsdec.c
>> +++ b/libavcodec/alsdec.c
>> @@ -1527,7 +1527,7 @@ static int read_diff_float_data(ALSDecContext *ctx, 
>> unsigned int ra_frame) {
>>  if (!get_bits1(gb)) { //uncompressed
>>  for (i = 0; i < frame_length; ++i) {
>>  if (ctx->raw_samples[c][i] != 0) {
>> -raw_mantissa[c][i] = get_bits(gb, nbits[i]);
>> +raw_mantissa[c][i] = nbits[i] ? get_bits(gb, 
>> nbits[i]) : 0;
> 
> No point changing it now, but keep in mind for future reference that there's 
> a get_bitsz()
> function. It in fact expands to this same code you wrote.

Thanks!

Will fix it soon anyway otherwise I will forget about it.

-Thilo

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


Re: [FFmpeg-devel] [PATCH] avformat/segment: fix the duration error of use output_ts_offset

2016-09-09 Thread Steven Liu
2016-09-09 15:28 GMT+08:00 Aman Gupta :

> I tried your patch and TARGETDURATION is fixed, but it is still creating
> some segments which are only 0.2s instead of 2s.
>
> Aman
>
> On Thu, Sep 8, 2016 at 8:14 PM, Steven Liu 
> wrote:
>
>> This patch can merge with 1da00be009aa74400042bf470b9a5ffbd82a1c5e
>> i have checked this modify:
>>
>> ./ffmpeg -i ~/facebook.mp4 -c copy -f segment -segment_time 2
>> -output_ts_offset 80 -segment_list output-test.m3u8 -v debug
>> output-test-%03d.ts
>>
>> #EXTM3U
>> #EXT-X-VERSION:3
>> #EXT-X-MEDIA-SEQUENCE:0
>> #EXT-X-ALLOW-CACHE:YES
>> #EXT-X-TARGETDURATION:10
>> #EXTINF:4.12,
>> output-test-000.ts
>> #EXTINF:7.84,
>> output-test-001.ts
>> #EXTINF:4.20,
>> output-test-002.ts
>> #EXTINF:2.92,
>> output-test-003.ts
>> #EXTINF:1.84,
>> output-test-004.ts
>> #EXTINF:2.24,
>> output-test-005.ts
>> #EXTINF:2.00,
>> output-test-006.ts
>> #EXTINF:3.56,
>>
>>
>> [root@localhost linux]# ffmpeg -i output-test.m3u8
>> ffmpeg version N-80917-ga1a240b Copyright (c) 2000-2016 the FFmpeg
>> developers
>>   built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
>>   configuration: --prefix=/usr/ --libdir=/usr/lib64 --enable-libx264
>> --enable-libfaac --enable-gpl --enable-nonfree
>>   libavutil  55. 28.100 / 55. 28.100
>>   libavcodec 57. 48.102 / 57. 48.102
>>   libavformat57. 41.100 / 57. 41.100
>>   libavdevice57.  0.102 / 57.  0.102
>>   libavfilter 6. 47.100 /  6. 47.100
>>   libswscale  4.  1.100 /  4.  1.100
>>   libswresample   2.  1.100 /  2.  1.100
>>   libpostproc54.  0.100 / 54.  0.100
>> Input #0, hls,applehttp, from 'output-test.m3u8':
>>   Duration: 00:03:21.04, start: 81.40, bitrate: 0 kb/s
>>   Program 0
>> Metadata:
>>   variant_bitrate : 0
>> Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p,
>> 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
>> Stream #0:1: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz,
>> 5.1(side), fltp, 384 kb/s
>> At least one output file must be specified
>>
>>
>>
>> [root@localhost linux]# ffmpeg -i output-test-000.ts -i
>> output-test-001.ts
>> ffmpeg version N-80917-ga1a240b Copyright (c) 2000-2016 the FFmpeg
>> developers
>>   built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
>>   configuration: --prefix=/usr/ --libdir=/usr/lib64 --enable-libx264
>> --enable-libfaac --enable-gpl --enable-nonfree
>>   libavutil  55. 28.100 / 55. 28.100
>>   libavcodec 57. 48.102 / 57. 48.102
>>   libavformat57. 41.100 / 57. 41.100
>>   libavdevice57.  0.102 / 57.  0.102
>>   libavfilter 6. 47.100 /  6. 47.100
>>   libswscale  4.  1.100 /  4.  1.100
>>   libswresample   2.  1.100 /  2.  1.100
>>   libpostproc54.  0.100 / 54.  0.100
>> Input #0, mpegts, from 'output-test-000.ts':
>>   Duration: 00:00:04.12, start: 81.40, bitrate: 1299 kb/s
>>   Program 1
>> Metadata:
>>   service_name: Service01
>>   service_provider: FFmpeg
>> Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
>> yuv420p, 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
>> Stream #0:1[0x101](und): Audio: ac3 ([129][0][0][0] / 0x0081), 48000
>> Hz, 5.1(side), fltp, 384 kb/s
>> Input #1, mpegts, from 'output-test-001.ts':
>>   Duration: 00:00:07.90, start: 85.464000, bitrate: 1679 kb/s
>>   Program 1
>> Metadata:
>>   service_name: Service01
>>   service_provider: FFmpeg
>> Stream #1:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
>> yuv420p, 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
>> Stream #1:1[0x101](und): Audio: ac3 ([129][0][0][0] / 0x0081), 48000
>> Hz, 5.1(side), fltp, 384 kb/s
>> At least one output file must be specified
>> [root@localhost linux]#
>>
>>
>>
>>
>> this commit is used for fix commit 1da00be009aa74400042bf470b9a5f
>> fbd82a1c5e
>> because the option initial_offset will deprecated
>>
>> Signed-off-by: Steven Liu 
>> ---
>>  libavformat/segment.c |5 +
>>  1 files changed, 5 insertions(+), 0 deletions(-)
>>
>> diff --git a/libavformat/segment.c b/libavformat/segment.c
>> index 33a5cf0..252f8b1 100644
>> --- a/libavformat/segment.c
>> +++ b/libavformat/segment.c
>> @@ -885,6 +885,11 @@ calc_times:
>>  av_log(s, AV_LOG_VERBOSE, "segment:'%s' starts with packet
>> stream:%d pts:%s pts_time:%s frame:%d\n",
>> seg->avf->filename, pkt->stream_index,
>> av_ts2str(pkt->pts), av_ts2timestr(pkt->pts,
>> &st->time_base), seg->frame_count);
>> +seg->cut_pending = 0;
>> +seg->cur_entry.index = seg->segment_idx + seg->segment_idx_wrap
>> * seg->segment_idx_wrap_nb;
>> +seg->cur_entry.start_time = (double)pkt->pts *
>> av_q2d(st->time_base);
>> +seg->cur_entry.start_pts = av_rescale_q(pkt->pts, st->time_base,
>> AV_TIME_BASE_Q);
>> +seg->cur_entry.end_time = seg->cur_entry.start_time;
>>  }
>>
>>  av_log(s, AV_LOG_DEBUG, "stream:%d start_pts_time:%s 

Re: [FFmpeg-devel] [PATCH] avformat/segment: fix the duration error of use output_ts_offset

2016-09-09 Thread Steven Liu
2016-09-09 15:33 GMT+08:00 Steven Liu :

>
>
> 2016-09-09 15:28 GMT+08:00 Aman Gupta :
>
>> I tried your patch and TARGETDURATION is fixed, but it is still creating
>> some segments which are only 0.2s instead of 2s.
>>
>> Aman
>>
>> On Thu, Sep 8, 2016 at 8:14 PM, Steven Liu 
>> wrote:
>>
>>> This patch can merge with 1da00be009aa74400042bf470b9a5ffbd82a1c5e
>>> i have checked this modify:
>>>
>>> ./ffmpeg -i ~/facebook.mp4 -c copy -f segment -segment_time 2
>>> -output_ts_offset 80 -segment_list output-test.m3u8 -v debug
>>> output-test-%03d.ts
>>>
>>> #EXTM3U
>>> #EXT-X-VERSION:3
>>> #EXT-X-MEDIA-SEQUENCE:0
>>> #EXT-X-ALLOW-CACHE:YES
>>> #EXT-X-TARGETDURATION:10
>>> #EXTINF:4.12,
>>> output-test-000.ts
>>> #EXTINF:7.84,
>>> output-test-001.ts
>>> #EXTINF:4.20,
>>> output-test-002.ts
>>> #EXTINF:2.92,
>>> output-test-003.ts
>>> #EXTINF:1.84,
>>> output-test-004.ts
>>> #EXTINF:2.24,
>>> output-test-005.ts
>>> #EXTINF:2.00,
>>> output-test-006.ts
>>> #EXTINF:3.56,
>>>
>>>
>>> [root@localhost linux]# ffmpeg -i output-test.m3u8
>>> ffmpeg version N-80917-ga1a240b Copyright (c) 2000-2016 the FFmpeg
>>> developers
>>>   built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
>>>   configuration: --prefix=/usr/ --libdir=/usr/lib64 --enable-libx264
>>> --enable-libfaac --enable-gpl --enable-nonfree
>>>   libavutil  55. 28.100 / 55. 28.100
>>>   libavcodec 57. 48.102 / 57. 48.102
>>>   libavformat57. 41.100 / 57. 41.100
>>>   libavdevice57.  0.102 / 57.  0.102
>>>   libavfilter 6. 47.100 /  6. 47.100
>>>   libswscale  4.  1.100 /  4.  1.100
>>>   libswresample   2.  1.100 /  2.  1.100
>>>   libpostproc54.  0.100 / 54.  0.100
>>> Input #0, hls,applehttp, from 'output-test.m3u8':
>>>   Duration: 00:03:21.04, start: 81.40, bitrate: 0 kb/s
>>>   Program 0
>>> Metadata:
>>>   variant_bitrate : 0
>>> Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p,
>>> 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
>>> Stream #0:1: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz,
>>> 5.1(side), fltp, 384 kb/s
>>> At least one output file must be specified
>>>
>>>
>>>
>>> [root@localhost linux]# ffmpeg -i output-test-000.ts -i
>>> output-test-001.ts
>>> ffmpeg version N-80917-ga1a240b Copyright (c) 2000-2016 the FFmpeg
>>> developers
>>>   built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
>>>   configuration: --prefix=/usr/ --libdir=/usr/lib64 --enable-libx264
>>> --enable-libfaac --enable-gpl --enable-nonfree
>>>   libavutil  55. 28.100 / 55. 28.100
>>>   libavcodec 57. 48.102 / 57. 48.102
>>>   libavformat57. 41.100 / 57. 41.100
>>>   libavdevice57.  0.102 / 57.  0.102
>>>   libavfilter 6. 47.100 /  6. 47.100
>>>   libswscale  4.  1.100 /  4.  1.100
>>>   libswresample   2.  1.100 /  2.  1.100
>>>   libpostproc54.  0.100 / 54.  0.100
>>> Input #0, mpegts, from 'output-test-000.ts':
>>>   Duration: 00:00:04.12, start: 81.40, bitrate: 1299 kb/s
>>>   Program 1
>>> Metadata:
>>>   service_name: Service01
>>>   service_provider: FFmpeg
>>> Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
>>> yuv420p, 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
>>> Stream #0:1[0x101](und): Audio: ac3 ([129][0][0][0] / 0x0081), 48000
>>> Hz, 5.1(side), fltp, 384 kb/s
>>> Input #1, mpegts, from 'output-test-001.ts':
>>>   Duration: 00:00:07.90, start: 85.464000, bitrate: 1679 kb/s
>>>   Program 1
>>> Metadata:
>>>   service_name: Service01
>>>   service_provider: FFmpeg
>>> Stream #1:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
>>> yuv420p, 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
>>> Stream #1:1[0x101](und): Audio: ac3 ([129][0][0][0] / 0x0081), 48000
>>> Hz, 5.1(side), fltp, 384 kb/s
>>> At least one output file must be specified
>>> [root@localhost linux]#
>>>
>>>
>>>
>>>
>>> this commit is used for fix commit 1da00be009aa74400042bf470b9a5f
>>> fbd82a1c5e
>>> because the option initial_offset will deprecated
>>>
>>> Signed-off-by: Steven Liu 
>>> ---
>>>  libavformat/segment.c |5 +
>>>  1 files changed, 5 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/libavformat/segment.c b/libavformat/segment.c
>>> index 33a5cf0..252f8b1 100644
>>> --- a/libavformat/segment.c
>>> +++ b/libavformat/segment.c
>>> @@ -885,6 +885,11 @@ calc_times:
>>>  av_log(s, AV_LOG_VERBOSE, "segment:'%s' starts with packet
>>> stream:%d pts:%s pts_time:%s frame:%d\n",
>>> seg->avf->filename, pkt->stream_index,
>>> av_ts2str(pkt->pts), av_ts2timestr(pkt->pts,
>>> &st->time_base), seg->frame_count);
>>> +seg->cut_pending = 0;
>>> +seg->cur_entry.index = seg->segment_idx + seg->segment_idx_wrap
>>> * seg->segment_idx_wrap_nb;
>>> +seg->cur_entry.start_time = (double)pkt->pts *
>>> av_q2d(st->time_base);
>>> +seg->cur_entry.start_pts = av_rescale_q(pkt->p

Re: [FFmpeg-devel] dash encoder. Correct generated manifest for MPEG-DASH MPD Validator and calculate current bandwidth for eath chunk. Now works correctly with dash.sj

2016-09-09 Thread Ligverd Haer
 
> missing commit mesage / not a proper git patch
...
> this looks unrelated, unrelated changes need to be in separate patches
> 
> please explain in the commit messages of the patch(es) what each
> patch does, why it does it and if you have at hand any reference to
> specs feel free to include them
> 
> floats make the binary output code platform dependant, theres no
> need to use floats here

Thanks for the positive comments Michael.

0001-libavformat-dashenc.c-fix-validation-manifest.mpd.patch
1. If the MPD is dynamic the Period element shall have an id.
2. Attribute ‘bandwidth’ must appear on element ‘Representation’
3. Attribute 
[profiles,width,height,sar,frameRate,audioSamplingRate,mimeType,segmentProfiles,codecs,maximumSAPPeriod,startWithSAP,maxPlayoutRate,codingDependency,scanType]
   Common attributes for AdaptationSet and Representation shall either be in 
one of the elements but not in both.
the tests were conducted on http://www-itec.uni-klu.ac.at/dash/?page_id=605

0002-libavformat-dashenc.c-calculation-bandwidth-for-mani.patch
When stream encoding is not counted bandwidth which makes it impossible to 
properly switch to the desired stream.
Use float I removed. Now the calculation accuracy decreased to kilobits.
Is it possible to supply test division by 0 ?

0003-libavformat-dashenc.c-change-moveflags-works-better.patch
Replaced flags movflags. These flags input rtsp stream looked better.
>From 9ae9406222bdf21ae8ba28d7e21cb4ab709dfde0 Mon Sep 17 00:00:00 2001
From: ligverd 
Date: Fri, 9 Sep 2016 10:35:18 +0300
Subject: [PATCH 1/3] libavformat/dashenc.c fix validation manifest.mpd

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

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 519f9c4..779ea59 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -498,17 +498,15 @@ static int write_manifest(AVFormatContext *s, int final)
 OutputStream *os = &c->streams[0];
 int start_index = FFMAX(os->nb_segments - c->window_size, 0);
 int64_t start_time = av_rescale_q(os->segments[start_index]->time, s->streams[0]->time_base, AV_TIME_BASE_Q);
-avio_printf(out, "\t\n");
 } else {
-avio_printf(out, "\t\n");
+avio_printf(out, "\t\n",final?"":" id=\"0\"");
 }
 
 if (c->has_video) {
 avio_printf(out, "\t\tmax_frame_rate.num && !c->ambiguous_frame_rate)
-avio_printf(out, " %s=\"%d/%d\"", (av_cmp_q(c->min_frame_rate, c->max_frame_rate) < 0) ? "maxFrameRate" : "frameRate", c->max_frame_rate.num, c->max_frame_rate.den);
 avio_printf(out, ">\n");
 
 for (i = 0; i < s->nb_streams; i++) {
@@ -603,6 +601,8 @@ static int dash_write_header(AVFormatContext *s)
 snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
  " bandwidth=\"%d\"", os->bit_rate);
 } else {
+snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
+ " bandwidth=\"%d\"", 0);
 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);
-- 
2.6.3

>From 5aaf033232dd473357a64475d663eba762422d10 Mon Sep 17 00:00:00 2001
From: ligverd 
Date: Fri, 9 Sep 2016 10:48:08 +0300
Subject: [PATCH 2/3] libavformat/dashenc.c calculation bandwidth for manifest

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

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 779ea59..d61aa90 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -596,7 +596,7 @@ static int dash_write_header(AVFormatContext *s)
 AVDictionary *opts = NULL;
 char filename[1024];
 
-os->bit_rate = s->streams[i]->codecpar->bit_rate;
+os->bit_rate = s->streams[i]->codecpar->bit_rate ? s->streams[i]->codecpar->bit_rate :  s->bit_rate;
 if (os->bit_rate) {
 snprintf(os->bandwidth_str, sizeof(os->bandwidth_str),
  " bandwidth=\"%d\"", os->bit_rate);
@@ -858,6 +858,9 @@ static int dash_flush(AVFormatContext *s, int final, int stream)
 if (ret < 0)
 break;
 }
+os->bit_rate = ( (range_length * 8 * 10) / (os->max_pts - os->start_pts) ) / 1;
+snprintf(os->bandwidth_str, sizeof(os->bandwidth_str)," bandwidth=\"%i\"", os->bit_rate);
+
 add_segment(os, filename, os->start_pts, os->max_pts - os->start_pts, start_pos, range_length, index_length);
 av_log(s, AV_LOG_VERBOSE, "Representation %d media segment %d written to: %s\n", i, os->segment_index, full_path);
 }
-- 
2.6.3

>From 8dc233c503d954f344933b81d4ae1d6cef584675 Mon Sep 17 00:00:00 2001
From: ligverd 
Date: Fri, 9 Sep 2016 10:49:28 +0300
Subject: [PATCH 3/3] libavformat/dashenc.c change moveflags, works better

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

Re: [FFmpeg-devel] [PATCH] avformat/segment: fix the duration error of use output_ts_offset

2016-09-09 Thread Steven Liu
2016-09-09 16:10 GMT+08:00 Steven Liu :

>
>
> 2016-09-09 15:33 GMT+08:00 Steven Liu :
>
>>
>>
>> 2016-09-09 15:28 GMT+08:00 Aman Gupta :
>>
>>> I tried your patch and TARGETDURATION is fixed, but it is still creating
>>> some segments which are only 0.2s instead of 2s.
>>>
>>> Aman
>>>
>>> On Thu, Sep 8, 2016 at 8:14 PM, Steven Liu 
>>> wrote:
>>>
 This patch can merge with 1da00be009aa74400042bf470b9a5ffbd82a1c5e
 i have checked this modify:

 ./ffmpeg -i ~/facebook.mp4 -c copy -f segment -segment_time 2
 -output_ts_offset 80 -segment_list output-test.m3u8 -v debug
 output-test-%03d.ts

 #EXTM3U
 #EXT-X-VERSION:3
 #EXT-X-MEDIA-SEQUENCE:0
 #EXT-X-ALLOW-CACHE:YES
 #EXT-X-TARGETDURATION:10
 #EXTINF:4.12,
 output-test-000.ts
 #EXTINF:7.84,
 output-test-001.ts
 #EXTINF:4.20,
 output-test-002.ts
 #EXTINF:2.92,
 output-test-003.ts
 #EXTINF:1.84,
 output-test-004.ts
 #EXTINF:2.24,
 output-test-005.ts
 #EXTINF:2.00,
 output-test-006.ts
 #EXTINF:3.56,


 [root@localhost linux]# ffmpeg -i output-test.m3u8
 ffmpeg version N-80917-ga1a240b Copyright (c) 2000-2016 the FFmpeg
 developers
   built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
   configuration: --prefix=/usr/ --libdir=/usr/lib64 --enable-libx264
 --enable-libfaac --enable-gpl --enable-nonfree
   libavutil  55. 28.100 / 55. 28.100
   libavcodec 57. 48.102 / 57. 48.102
   libavformat57. 41.100 / 57. 41.100
   libavdevice57.  0.102 / 57.  0.102
   libavfilter 6. 47.100 /  6. 47.100
   libswscale  4.  1.100 /  4.  1.100
   libswresample   2.  1.100 /  2.  1.100
   libpostproc54.  0.100 / 54.  0.100
 Input #0, hls,applehttp, from 'output-test.m3u8':
   Duration: 00:03:21.04, start: 81.40, bitrate: 0 kb/s
   Program 0
 Metadata:
   variant_bitrate : 0
 Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p,
 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
 Stream #0:1: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz,
 5.1(side), fltp, 384 kb/s
 At least one output file must be specified



 [root@localhost linux]# ffmpeg -i output-test-000.ts -i
 output-test-001.ts
 ffmpeg version N-80917-ga1a240b Copyright (c) 2000-2016 the FFmpeg
 developers
   built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
   configuration: --prefix=/usr/ --libdir=/usr/lib64 --enable-libx264
 --enable-libfaac --enable-gpl --enable-nonfree
   libavutil  55. 28.100 / 55. 28.100
   libavcodec 57. 48.102 / 57. 48.102
   libavformat57. 41.100 / 57. 41.100
   libavdevice57.  0.102 / 57.  0.102
   libavfilter 6. 47.100 /  6. 47.100
   libswscale  4.  1.100 /  4.  1.100
   libswresample   2.  1.100 /  2.  1.100
   libpostproc54.  0.100 / 54.  0.100
 Input #0, mpegts, from 'output-test-000.ts':
   Duration: 00:00:04.12, start: 81.40, bitrate: 1299 kb/s
   Program 1
 Metadata:
   service_name: Service01
   service_provider: FFmpeg
 Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
 yuv420p, 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
 Stream #0:1[0x101](und): Audio: ac3 ([129][0][0][0] / 0x0081),
 48000 Hz, 5.1(side), fltp, 384 kb/s
 Input #1, mpegts, from 'output-test-001.ts':
   Duration: 00:00:07.90, start: 85.464000, bitrate: 1679 kb/s
   Program 1
 Metadata:
   service_name: Service01
   service_provider: FFmpeg
 Stream #1:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
 yuv420p, 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
 Stream #1:1[0x101](und): Audio: ac3 ([129][0][0][0] / 0x0081),
 48000 Hz, 5.1(side), fltp, 384 kb/s
 At least one output file must be specified
 [root@localhost linux]#




 this commit is used for fix commit 1da00be009aa74400042bf470b9a5f
 fbd82a1c5e
 because the option initial_offset will deprecated

 Signed-off-by: Steven Liu 
 ---
  libavformat/segment.c |5 +
  1 files changed, 5 insertions(+), 0 deletions(-)

 diff --git a/libavformat/segment.c b/libavformat/segment.c
 index 33a5cf0..252f8b1 100644
 --- a/libavformat/segment.c
 +++ b/libavformat/segment.c
 @@ -885,6 +885,11 @@ calc_times:
  av_log(s, AV_LOG_VERBOSE, "segment:'%s' starts with packet
 stream:%d pts:%s pts_time:%s frame:%d\n",
 seg->avf->filename, pkt->stream_index,
 av_ts2str(pkt->pts), av_ts2timestr(pkt->pts,
 &st->time_base), seg->frame_count);
 +seg->cut_pending = 0;
 +seg->cur_entry.index = seg->segment_idx +
 seg->segment_idx_

[FFmpeg-devel] [PATCH] Select cubic and lanczos as alternative where super-sampling is not supported

2016-09-09 Thread Sven C. Dack
CUDA/NPP doesn't allow super-sampling in some cases and the module then prints 
an error message "NPP resize error: -23".


Example:
$ ffmpeg -f lavfi -i testsrc=duration=1:size=hd1080:rate=1 -pix_fmt nv12 -vf 
hwupload_cuda,scale_npp=w=1920:h=720:interp_algo=super:format=nv12,hwdownload -f 
null -

ffmpeg version N-81609-g7b3bc36 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 6.2.0 (GCC)
  configuration: --prefix=/home/sven/av --enable-gpl --enable-version3 
--enable-nonfree --arch=x86_64 --cpu=native --enable-debug --disable-shared 
--enable-static --enable-libvorbis --enable-libopus --enable-libx264 
--enable-libx265 --enable-opengl --enable-opencl --enable-vaapi --enable-vdpau 
--enable-cuda --enable-cuvid --enable-nvenc --enable-libnpp 
--extra-cflags='-I/home/sven/av/include -I/usr/local/cuda/include 
-I/usr/local/Video_Codec_SDK_7.0.1/Samples/common/inc' 
--extra-ldflags='-L/home/sven/av/lib -L/usr/local/cuda/lib64' --ar=gcc-ar 
--nm=gcc-nm --ranlib=true

  libavutil  55. 29.100 / 55. 29.100
  libavcodec 57. 55.101 / 57. 55.101
  libavformat57. 48.103 / 57. 48.103
  libavdevice57.  0.102 / 57.  0.102
  libavfilter 6. 61.100 /  6. 61.100
  libswscale  4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc54.  0.100 / 54.  0.100
Input #0, lavfi, from 'testsrc=duration=1:size=hd1080:rate=1':
  Duration: N/A, start: 0.00, bitrate: N/A
Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1920x1080 [SAR 
1:1 DAR 16:9], 1 tbr, 1 tbn, 1 tbc
[null @ 0x36aa440] Using AVStream.codec to pass codec parameters to muxers is 
deprecated, use AVStream.codecpar instead.

Output #0, null, to 'pipe:':
  Metadata:
encoder : Lavf57.48.103
Stream #0:0: Video: wrapped_avframe, nv12, 1920x720 [SAR 2:3 DAR 16:9], 
q=2-31, 200 kb/s, 1 fps, 1 tbn, 1 tbc

Metadata:
  encoder : Lavc57.55.101 wrapped_avframe
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> wrapped_avframe (native))
Press [q] to stop, [?] for help
[Parsed_scale_npp_1 @ 0x3ae8fa0] NPP resize error: -23
Failed to inject frame into filter network: Unknown error occurred
Conversion failed!

Super-sampling is currently only supported by CUDA/NPP when the output 
dimensions are both smaller than the input dimensions. The patch lets ffmpeg 
select an alternative algorithm and prints a warning in such cases.


Sven


>From aacd8ecc2f39a45bbfdf6780d9b3b13e6ed0fb41 Mon Sep 17 00:00:00 2001
From: "Sven C. Dack" 
Date: Fri, 9 Sep 2016 10:18:07 +0100
Subject: [PATCH] Select cubic and lanczos as alternative where super-sampling
 is not supported

---
 libavfilter/vf_scale_npp.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_scale_npp.c b/libavfilter/vf_scale_npp.c
index 68cee39..82ba2f4 100644
--- a/libavfilter/vf_scale_npp.c
+++ b/libavfilter/vf_scale_npp.c
@@ -294,9 +294,21 @@ static int init_processing_chain(AVFilterContext *ctx, int in_width, int in_heig
 
 /* figure out which stages need to be done */
 if (in_width != out_width || in_height != out_height ||
-in_deinterleaved_format != out_deinterleaved_format)
+in_deinterleaved_format != out_deinterleaved_format) {
 s->stages[STAGE_RESIZE].stage_needed = 1;
 
+	if (s->interp_algo == NPPI_INTER_SUPER &&
+	(out_width > in_width && out_height > in_height)) {
+	s->interp_algo = NPPI_INTER_LANCZOS;
+	av_log(ctx, AV_LOG_WARNING, "super-sampling not supported for output dimensions, using lanczos instead.\n");
+	}
+	if (s->interp_algo == NPPI_INTER_SUPER &&
+	!(out_width < in_width && out_height < in_height)) {
+	s->interp_algo = NPPI_INTER_CUBIC;
+	av_log(ctx, AV_LOG_WARNING, "super-sampling not supported for output dimensions, using cubic instead.\n");
+	}
+}
+
 if (!s->stages[STAGE_RESIZE].stage_needed && in_format == out_format)
 s->passthrough = 1;
 
-- 
2.9.3

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


Re: [FFmpeg-devel] [PATCH] Select cubic and lanczos as alternative where super-sampling is not supported

2016-09-09 Thread Carl Eugen Hoyos
2016-09-09 11:55 GMT+02:00 Sven C. Dack :

> Super-sampling is currently only supported by CUDA/NPP when the output
> dimensions are both smaller than the input dimensions. The patch lets ffmpeg
> select an alternative algorithm and prints a warning in such cases.

Tabs (as in your patch) cannot be committed to our git repository, please
remove them.
You can use the script tools/patcheck to find them.

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


Re: [FFmpeg-devel] [PATCH] Select cubic and lanczos as alternative where super-sampling is not supported

2016-09-09 Thread Sven C. Dack

On 09/09/16 11:03, Carl Eugen Hoyos wrote:

2016-09-09 11:55 GMT+02:00 Sven C. Dack :


Super-sampling is currently only supported by CUDA/NPP when the output
dimensions are both smaller than the input dimensions. The patch lets ffmpeg
select an alternative algorithm and prints a warning in such cases.

Tabs (as in your patch) cannot be committed to our git repository, please
remove them.
You can use the script tools/patcheck to find them.



Ok, thank you.

It tells me my change log entry is missing.

I've commited it with: git commit vf_scale_npp.c

Entered my comment and applied format-patch: git format-patch -1 vf_scale_npp.c

How would I get the missing change log entry in there?

Sven

>From aacd8ecc2f39a45bbfdf6780d9b3b13e6ed0fb41 Mon Sep 17 00:00:00 2001
From: "Sven C. Dack" 
Date: Fri, 9 Sep 2016 10:18:07 +0100
Subject: [PATCH] Select cubic and lanczos as alternative where super-sampling
 is not supported

---
 libavfilter/vf_scale_npp.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_scale_npp.c b/libavfilter/vf_scale_npp.c
index 68cee39..82ba2f4 100644
--- a/libavfilter/vf_scale_npp.c
+++ b/libavfilter/vf_scale_npp.c
@@ -294,10 +294,21 @@ static int init_processing_chain(AVFilterContext *ctx, int in_width, int in_heig
 
 /* figure out which stages need to be done */
 if (in_width != out_width || in_height != out_height ||
-in_deinterleaved_format != out_deinterleaved_format)
+in_deinterleaved_format != out_deinterleaved_format) {
 s->stages[STAGE_RESIZE].stage_needed = 1;
 
+   if (s->interp_algo == NPPI_INTER_SUPER &&
+   (out_width > in_width && out_height > in_height)) {
+   s->interp_algo = NPPI_INTER_LANCZOS;
+   av_log(ctx, AV_LOG_WARNING, "super-sampling not supported for output dimensions, using lanczos instead.\n");
+   }
+   if (s->interp_algo == NPPI_INTER_SUPER &&
+   !(out_width < in_width && out_height < in_height)) {
+   s->interp_algo = NPPI_INTER_CUBIC;
+   av_log(ctx, AV_LOG_WARNING, "super-sampling not supported for output dimensions, using cubic instead.\n");
+   }
+}
+
 if (!s->stages[STAGE_RESIZE].stage_needed && in_format == out_format)
 s->passthrough = 1;
 
-- 
2.9.3

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


Re: [FFmpeg-devel] [PATCH] Select cubic and lanczos as alternative where super-sampling is not supported

2016-09-09 Thread Carl Eugen Hoyos
2016-09-09 12:13 GMT+02:00 Sven C. Dack :

> It tells me my change log entry is missing.
>
> I've commited it with: git commit vf_scale_npp.c
>
> Entered my comment and applied format-patch: git format-patch -1
> vf_scale_npp.c
>
> How would I get the missing change log entry in there?

The change to the file Changelog in FFmpeg's root is only
necessary if you make a major addition to FFmpeg (like a
new filter, not a fix for an existing filter).

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


Re: [FFmpeg-devel] [FFmpeg-cvslog] avcodec/alsdec: Fix reading 0 mantisse bits

2016-09-09 Thread Thilo Borgmann
Am 09.09.16 um 09:11 schrieb Thilo Borgmann:
> Am 08.09.16 um 23:41 schrieb James Almer:
>>> ffmpeg | branch: master | Michael Niedermayer  | 
>>> Thu Sep  8 22:02:44 2016 +0200| [037422178d7f1d0dd09e1ce424dd61a69e77668b] 
>>> | committer: Michael Niedermayer
>>>
>>> avcodec/alsdec: Fix reading 0 mantisse bits
>>>
>>> Fixes assertion failure
>>> Fixes: 
>>> 848c24abc1721c9e3d1ba7bfee8d9fcc/asan_heap-oob_1d99eca_3709_567bba70d67e7d62714dcf56f26fb1da.mp4
>>>
>>> Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
>>> Signed-off-by: Michael Niedermayer 
>>>
 http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=037422178d7f1d0dd09e1ce424dd61a69e77668b
>>> ---
>>>
>>>  libavcodec/alsdec.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
>>> index 1bb71f5..8c4ff53 100644
>>> --- a/libavcodec/alsdec.c
>>> +++ b/libavcodec/alsdec.c
>>> @@ -1527,7 +1527,7 @@ static int read_diff_float_data(ALSDecContext *ctx, 
>>> unsigned int ra_frame) {
>>>  if (!get_bits1(gb)) { //uncompressed
>>>  for (i = 0; i < frame_length; ++i) {
>>>  if (ctx->raw_samples[c][i] != 0) {
>>> -raw_mantissa[c][i] = get_bits(gb, nbits[i]);
>>> +raw_mantissa[c][i] = nbits[i] ? get_bits(gb, 
>>> nbits[i]) : 0;
>>
>> No point changing it now, but keep in mind for future reference that there's 
>> a get_bitsz()
>> function. It in fact expands to this same code you wrote.
> 
> Thanks!
> 
> Will fix it soon anyway otherwise I will forget about it.

Patch attached. Somebody please push, I can not do that from this computer.

Thanks,
Thilo

From 0cdbf565a9b43f8770e77ae2b2b1a0bfb60b0b68 Mon Sep 17 00:00:00 2001
From: Thilo Borgmann 
Date: Fri, 9 Sep 2016 12:29:23 +0200
Subject: [PATCH] lavc/alsdec: use get_bitsz() to simplify reading of the
 mantissa

---
 libavcodec/alsdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index 8c4ff53..3986347 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -1527,7 +1527,7 @@ static int read_diff_float_data(ALSDecContext *ctx, 
unsigned int ra_frame) {
 if (!get_bits1(gb)) { //uncompressed
 for (i = 0; i < frame_length; ++i) {
 if (ctx->raw_samples[c][i] != 0) {
-raw_mantissa[c][i] = nbits[i] ? get_bits(gb, nbits[i]) 
: 0;
+raw_mantissa[c][i] = get_bitsz(gb, nbits[i]);
 }
 }
 } else { //compressed
-- 
2.5.4 (Apple Git-61)

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


Re: [FFmpeg-devel] [PATCH] avformat/segment: fix the duration error of use output_ts_offset

2016-09-09 Thread Steven Liu
2016-09-09 16:33 GMT+08:00 Steven Liu :

>
>
> 2016-09-09 16:10 GMT+08:00 Steven Liu :
>
>>
>>
>> 2016-09-09 15:33 GMT+08:00 Steven Liu :
>>
>>>
>>>
>>> 2016-09-09 15:28 GMT+08:00 Aman Gupta :
>>>
 I tried your patch and TARGETDURATION is fixed, but it is still
 creating some segments which are only 0.2s instead of 2s.

 Aman

 On Thu, Sep 8, 2016 at 8:14 PM, Steven Liu 
 wrote:

> This patch can merge with 1da00be009aa74400042bf470b9a5ffbd82a1c5e
> i have checked this modify:
>
> ./ffmpeg -i ~/facebook.mp4 -c copy -f segment -segment_time 2
> -output_ts_offset 80 -segment_list output-test.m3u8 -v debug
> output-test-%03d.ts
>
> #EXTM3U
> #EXT-X-VERSION:3
> #EXT-X-MEDIA-SEQUENCE:0
> #EXT-X-ALLOW-CACHE:YES
> #EXT-X-TARGETDURATION:10
> #EXTINF:4.12,
> output-test-000.ts
> #EXTINF:7.84,
> output-test-001.ts
> #EXTINF:4.20,
> output-test-002.ts
> #EXTINF:2.92,
> output-test-003.ts
> #EXTINF:1.84,
> output-test-004.ts
> #EXTINF:2.24,
> output-test-005.ts
> #EXTINF:2.00,
> output-test-006.ts
> #EXTINF:3.56,
>
>
> [root@localhost linux]# ffmpeg -i output-test.m3u8
> ffmpeg version N-80917-ga1a240b Copyright (c) 2000-2016 the FFmpeg
> developers
>   built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
>   configuration: --prefix=/usr/ --libdir=/usr/lib64 --enable-libx264
> --enable-libfaac --enable-gpl --enable-nonfree
>   libavutil  55. 28.100 / 55. 28.100
>   libavcodec 57. 48.102 / 57. 48.102
>   libavformat57. 41.100 / 57. 41.100
>   libavdevice57.  0.102 / 57.  0.102
>   libavfilter 6. 47.100 /  6. 47.100
>   libswscale  4.  1.100 /  4.  1.100
>   libswresample   2.  1.100 /  2.  1.100
>   libpostproc54.  0.100 / 54.  0.100
> Input #0, hls,applehttp, from 'output-test.m3u8':
>   Duration: 00:03:21.04, start: 81.40, bitrate: 0 kb/s
>   Program 0
> Metadata:
>   variant_bitrate : 0
> Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p,
> 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
> Stream #0:1: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz,
> 5.1(side), fltp, 384 kb/s
> At least one output file must be specified
>
>
>
> [root@localhost linux]# ffmpeg -i output-test-000.ts -i
> output-test-001.ts
> ffmpeg version N-80917-ga1a240b Copyright (c) 2000-2016 the FFmpeg
> developers
>   built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
>   configuration: --prefix=/usr/ --libdir=/usr/lib64 --enable-libx264
> --enable-libfaac --enable-gpl --enable-nonfree
>   libavutil  55. 28.100 / 55. 28.100
>   libavcodec 57. 48.102 / 57. 48.102
>   libavformat57. 41.100 / 57. 41.100
>   libavdevice57.  0.102 / 57.  0.102
>   libavfilter 6. 47.100 /  6. 47.100
>   libswscale  4.  1.100 /  4.  1.100
>   libswresample   2.  1.100 /  2.  1.100
>   libpostproc54.  0.100 / 54.  0.100
> Input #0, mpegts, from 'output-test-000.ts':
>   Duration: 00:00:04.12, start: 81.40, bitrate: 1299 kb/s
>   Program 1
> Metadata:
>   service_name: Service01
>   service_provider: FFmpeg
> Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
> yuv420p, 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
> Stream #0:1[0x101](und): Audio: ac3 ([129][0][0][0] / 0x0081),
> 48000 Hz, 5.1(side), fltp, 384 kb/s
> Input #1, mpegts, from 'output-test-001.ts':
>   Duration: 00:00:07.90, start: 85.464000, bitrate: 1679 kb/s
>   Program 1
> Metadata:
>   service_name: Service01
>   service_provider: FFmpeg
> Stream #1:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
> yuv420p, 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
> Stream #1:1[0x101](und): Audio: ac3 ([129][0][0][0] / 0x0081),
> 48000 Hz, 5.1(side), fltp, 384 kb/s
> At least one output file must be specified
> [root@localhost linux]#
>
>
>
>
> this commit is used for fix commit 1da00be009aa74400042bf470b9a5f
> fbd82a1c5e
> because the option initial_offset will deprecated
>
> Signed-off-by: Steven Liu 
> ---
>  libavformat/segment.c |5 +
>  1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/libavformat/segment.c b/libavformat/segment.c
> index 33a5cf0..252f8b1 100644
> --- a/libavformat/segment.c
> +++ b/libavformat/segment.c
> @@ -885,6 +885,11 @@ calc_times:
>  av_log(s, AV_LOG_VERBOSE, "segment:'%s' starts with packet
> stream:%d pts:%s pts_time:%s frame:%d\n",
> seg->avf->filename, pkt->stream_index,
> av_ts2str(pkt->pts), 

[FFmpeg-devel] [PATCH] lavc/ffjni: do not error out if the last non-mandatory field/method cannot be found

2016-09-09 Thread Matthieu Bouron
From: Matthieu Bouron 

---
 libavcodec/ffjni.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/ffjni.c b/libavcodec/ffjni.c
index 13eabb0..0597400 100644
--- a/libavcodec/ffjni.c
+++ b/libavcodec/ffjni.c
@@ -352,6 +352,8 @@ int ff_jni_init_jfields(JNIEnv *env, void *jfields, const 
struct FFJniField *jfi
 ret = AVERROR(EINVAL);
 goto done;
 }
+
+ret = 0;
 }
 }
 
-- 
2.9.3

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


Re: [FFmpeg-devel] [PATCH 1/2] lavc/hevc: store VPS/SPS/PPS data

2016-09-09 Thread Matthieu Bouron
On Fri, Sep 09, 2016 at 02:36:20AM +0200, Michael Niedermayer wrote:
> On Thu, Sep 08, 2016 at 04:18:26PM +0200, Matthieu Bouron wrote:
> > On Thu, Sep 8, 2016 at 2:28 PM, Michael Niedermayer 
> > wrote:
> > 
> > > On Wed, Sep 07, 2016 at 04:53:53PM +0200, Matthieu Bouron wrote:
> > > > From: Matthieu Bouron 
> > > >
> > > > ---
> > > >  libavcodec/hevc.h|  9 +
> > > >  libavcodec/hevc_ps.c | 27 +++
> > > >  2 files changed, 36 insertions(+)
> > > >
> > > > diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
> > > > index be91010..6a3c750 100644
> > > > --- a/libavcodec/hevc.h
> > > > +++ b/libavcodec/hevc.h
> > > > @@ -387,6 +387,9 @@ typedef struct HEVCVPS {
> > > >  uint8_t vps_poc_proportional_to_timing_flag;
> > > >  int vps_num_ticks_poc_diff_one; ///< 
> > > > vps_num_ticks_poc_diff_one_minus1
> > > + 1
> > > >  int vps_num_hrd_parameters;
> > > > +
> > > > +uint8_t data[4096];
> > > > +int data_size;
> > > >  } HEVCVPS;
> > > >
> > > >  typedef struct ScalingList {
> > > > @@ -483,6 +486,9 @@ typedef struct HEVCSPS {
> > > >  int vshift[3];
> > > >
> > > >  int qp_bd_offset;
> > > > +
> > > > +uint8_t data[4096];
> > > > +int data_size;
> > > >  } HEVCSPS;
> > > >
> > > >  typedef struct HEVCPPS {
> > > > @@ -557,6 +563,9 @@ typedef struct HEVCPPS {
> > > >  int *tile_pos_rs;   ///< TilePosRS
> > > >  int *min_tb_addr_zs;///< MinTbAddrZS
> > > >  int *min_tb_addr_zs_tab;///< MinTbAddrZS
> > > > +
> > > > +uint8_t data[4096];
> > > > +int data_size;
> > > >  } HEVCPPS;
> > > >
> > > >  typedef struct HEVCParamSets {
> > > > diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
> > > > index 83f2ec2..629e454 100644
> > > > --- a/libavcodec/hevc_ps.c
> > > > +++ b/libavcodec/hevc_ps.c
> > > > @@ -408,6 +408,15 @@ int ff_hevc_decode_nal_vps(GetBitContext *gb,
> > > AVCodecContext *avctx,
> > > >
> > > >  av_log(avctx, AV_LOG_DEBUG, "Decoding VPS\n");
> > > >
> > > > +vps->data_size = gb->buffer_end - gb->buffer;
> > >
> > > This theoretically could overflow, data_size is only an int the pointer
> > > difference might be larger
> > >
> > 
> > Updated patch attached.
> > 
> > [...]
> 
> >  hevc.h|9 +
> >  hevc_ps.c |   36 
> >  2 files changed, 45 insertions(+)
> > 74a311a04fc12daab6f9dc4dc228d3e2d574b12f  
> > 0001-lavc-hevc-store-VPS-SPS-PPS-data.patch
> > From e25cc9920accb43dd4af152358b78160e85d64a2 Mon Sep 17 00:00:00 2001
> > From: Matthieu Bouron 
> > Date: Wed, 7 Sep 2016 11:36:10 +0200
> > Subject: [PATCH 1/2] lavc/hevc: store VPS/SPS/PPS data
> 
> LGTM
> 
> thx

Pushed. Thanks.

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


Re: [FFmpeg-devel] [PATCH 2/2] lavc: add hevc mediacodec decoder

2016-09-09 Thread Matthieu Bouron
On Wed, Sep 7, 2016 at 4:53 PM, Matthieu Bouron 
wrote:

> From: Matthieu Bouron 
>
> ---
>  configure  |   3 +
>  libavcodec/Makefile|   3 +-
>  libavcodec/allcodecs.c |   2 +
>  libavcodec/hevc_parse.c| 134 ++
>  libavcodec/hevc_parse.h|  33 
>  libavcodec/mediacodecdec.c |   7 +
>  ...{mediacodecdec_h264.c => mediacodecdec_h2645.c} | 198
> ++---
>  7 files changed, 351 insertions(+), 29 deletions(-)
>  create mode 100644 libavcodec/hevc_parse.c
>  create mode 100644 libavcodec/hevc_parse.h
>  rename libavcodec/{mediacodecdec_h264.c => mediacodecdec_h2645.c} (68%)
>
> diff --git a/configure b/configure
> index b11ca7f..af3fbf4 100755
> --- a/configure
> +++ b/configure
> @@ -2585,6 +2585,9 @@ h264_videotoolbox_hwaccel_select="h264_decoder"
>  hevc_cuvid_hwaccel_deps="cuda cuvid CUVIDHEVCPICPARAMS"
>  hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
>  hevc_d3d11va_hwaccel_select="hevc_decoder"
> +hevc_mediacodec_decoder_deps="mediacodec"
> +hevc_mediacodec_hwaccel_deps="mediacodec"
> +hevc_mediacodec_decoder_select="hevc_mp4toannexb_bsf hevc_parser"
>  hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
>  hevc_dxva2_hwaccel_select="hevc_decoder"
>  hevc_qsv_hwaccel_deps="libmfx"
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 7396468..71420fb 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -316,7 +316,7 @@ OBJS-$(CONFIG_H264_DECODER)+= h264dec.o
> h264_cabac.o h264_cavlc.o \
>h264_slice.o h264data.o
> h264_parse.o \
>h2645_parse.o
>  OBJS-$(CONFIG_H264_CUVID_DECODER)  += cuvid.o
> -OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec_h264.o
> +OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec_h2645.o
>  OBJS-$(CONFIG_H264_MMAL_DECODER)   += mmaldec.o
>  OBJS-$(CONFIG_H264_NVENC_ENCODER)  += nvenc_h264.o
>  OBJS-$(CONFIG_NVENC_ENCODER)   += nvenc_h264.o
> @@ -333,6 +333,7 @@ OBJS-$(CONFIG_HEVC_DECODER)+= hevc.o
> hevc_mvs.o hevc_ps.o hevc_sei.o
>hevc_cabac.o hevc_refs.o
> hevcpred.o\
>hevcdsp.o hevc_filter.o
> h2645_parse.o hevc_data.o
>  OBJS-$(CONFIG_HEVC_CUVID_DECODER)  += cuvid.o
> +OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) += mediacodecdec_h2645.o
> hevc_parse.o
>  OBJS-$(CONFIG_HEVC_NVENC_ENCODER)  += nvenc_hevc.o
>  OBJS-$(CONFIG_NVENC_HEVC_ENCODER)  += nvenc_hevc.o
>  OBJS-$(CONFIG_HEVC_QSV_DECODER)+= qsvdec_h2645.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
> index a26a80e..142ccba 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -84,6 +84,7 @@ void avcodec_register_all(void)
>  REGISTER_HWACCEL(HEVC_CUVID,hevc_cuvid);
>  REGISTER_HWACCEL(HEVC_D3D11VA,  hevc_d3d11va);
>  REGISTER_HWACCEL(HEVC_DXVA2,hevc_dxva2);
> +REGISTER_HWACCEL(HEVC_MEDIACODEC,   hevc_mediacodec);
>  REGISTER_HWACCEL(HEVC_QSV,  hevc_qsv);
>  REGISTER_HWACCEL(HEVC_VAAPI,hevc_vaapi);
>  REGISTER_HWACCEL(HEVC_VDPAU,hevc_vdpau);
> @@ -644,6 +645,7 @@ void avcodec_register_all(void)
>  REGISTER_ENCODER(NVENC_HEVC,nvenc_hevc);
>  #endif
>  REGISTER_DECODER(HEVC_CUVID,hevc_cuvid);
> +REGISTER_DECODER(HEVC_MEDIACODEC,   hevc_mediacodec);
>  REGISTER_ENCODER(HEVC_NVENC,hevc_nvenc);
>  REGISTER_ENCODER(HEVC_QSV,  hevc_qsv);
>  REGISTER_ENCODER(HEVC_VAAPI,hevc_vaapi);
> diff --git a/libavcodec/hevc_parse.c b/libavcodec/hevc_parse.c
> new file mode 100644
> index 000..cf04bc2
> --- /dev/null
> +++ b/libavcodec/hevc_parse.c
> @@ -0,0 +1,134 @@
> +/*
> + * 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
> + */
> +
> +#include "bytestream.h"
> +#include "h2645_parse.h"
> +#include "hevc.h"
> +#include "hevc_parse.h"
> +
> +static int hevc_decode_nal_units(const uint8_t *buf, int buf_size,
> HEVCParamSets *ps,
> +

Re: [FFmpeg-devel] [FFmpeg-cvslog] avcodec/alsdec: Fix reading 0 mantisse bits

2016-09-09 Thread James Almer
On 9/9/2016 7:35 AM, Thilo Borgmann wrote:
> Am 09.09.16 um 09:11 schrieb Thilo Borgmann:
>> > Am 08.09.16 um 23:41 schrieb James Almer:
 >>> ffmpeg | branch: master | Michael Niedermayer >>> >>> niedermayer.cc> | Thu Sep  8 22:02:44 2016 +0200| 
 >>> [037422178d7f1d0dd09e1ce424dd61a69e77668b] | committer: Michael 
 >>> Niedermayer
 >>>
 >>> avcodec/alsdec: Fix reading 0 mantisse bits
 >>>
 >>> Fixes assertion failure
 >>> Fixes: 
 >>> 848c24abc1721c9e3d1ba7bfee8d9fcc/asan_heap-oob_1d99eca_3709_567bba70d67e7d62714dcf56f26fb1da.mp4
 >>>
 >>> Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
 >>> Signed-off-by: Michael Niedermayer 
 >>>
>  http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=037422178d7f1d0dd09e1ce424dd61a69e77668b
 >>> ---
 >>>
 >>>  libavcodec/alsdec.c | 2 +-
 >>>  1 file changed, 1 insertion(+), 1 deletion(-)
 >>>
 >>> diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
 >>> index 1bb71f5..8c4ff53 100644
 >>> --- a/libavcodec/alsdec.c
 >>> +++ b/libavcodec/alsdec.c
 >>> @@ -1527,7 +1527,7 @@ static int read_diff_float_data(ALSDecContext 
 >>> *ctx, unsigned int ra_frame) {
 >>>  if (!get_bits1(gb)) { //uncompressed
 >>>  for (i = 0; i < frame_length; ++i) {
 >>>  if (ctx->raw_samples[c][i] != 0) {
 >>> -raw_mantissa[c][i] = get_bits(gb, nbits[i]);
 >>> +raw_mantissa[c][i] = nbits[i] ? get_bits(gb, 
 >>> nbits[i]) : 0;
>>> >>
>>> >> No point changing it now, but keep in mind for future reference that 
>>> >> there's a get_bitsz()
>>> >> function. It in fact expands to this same code you wrote.
>> > 
>> > Thanks!
>> > 
>> > Will fix it soon anyway otherwise I will forget about it.
> Patch attached. Somebody please push, I can not do that from this computer.

Pushed.

> 
> Thanks,
> Thilo
> 
> 
> 0001-lavc-alsdec-use-get_bitsz-to-simplify-reading-of-the.patch
> 
> 
> From 0cdbf565a9b43f8770e77ae2b2b1a0bfb60b0b68 Mon Sep 17 00:00:00 2001
> From: Thilo Borgmann 
> Date: Fri, 9 Sep 2016 12:29:23 +0200
> Subject: [PATCH] lavc/alsdec: use get_bitsz() to simplify reading of the
>  mantissa
> 
> ---
>  libavcodec/alsdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
> index 8c4ff53..3986347 100644
> --- a/libavcodec/alsdec.c
> +++ b/libavcodec/alsdec.c
> @@ -1527,7 +1527,7 @@ static int read_diff_float_data(ALSDecContext *ctx, 
> unsigned int ra_frame) {
>  if (!get_bits1(gb)) { //uncompressed
>  for (i = 0; i < frame_length; ++i) {
>  if (ctx->raw_samples[c][i] != 0) {
> -raw_mantissa[c][i] = nbits[i] ? get_bits(gb, 
> nbits[i]) : 0;
> +raw_mantissa[c][i] = get_bitsz(gb, nbits[i]);
>  }
>  }
>  } else { //compressed
> -- 2.5.4 (Apple Git-61)
> 
> 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 

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


[FFmpeg-devel] [PATCH] lavf: add avformat_transfer_stream_timing_info() and use it in ffmpeg

2016-09-09 Thread Clément Bœsch
From: Clément Bœsch 

In lavf we have access to st->internal->avctx so it's a better place
than in ffmpeg*.c and will allow moving to codecpar.

TODO: avformat.h doxy
TODO: version.h minor bump
TODO: doc/APIchanges update
---
 ffmpeg.c   | 51 +++-
 libavformat/avformat.h | 12 +++
 libavformat/utils.c| 58 ++
 3 files changed, 73 insertions(+), 48 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index d858407..5c487c3 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2909,57 +2909,12 @@ static int transcode_init(void)
 enc_ctx->bits_per_coded_sample  = dec_ctx->bits_per_coded_sample;
 enc_ctx->bits_per_raw_sample= dec_ctx->bits_per_raw_sample;
 
-enc_ctx->time_base = ist->st->time_base;
-/*
- * Avi is a special case here because it supports variable fps but
- * having the fps and timebase differe significantly adds quite 
some
- * overhead
- */
-if(!strcmp(oc->oformat->name, "avi")) {
-if ( copy_tb<0 && ist->st->r_frame_rate.num
-   && av_q2d(ist->st->r_frame_rate) >= 
av_q2d(ist->st->avg_frame_rate)
-   && 0.5/av_q2d(ist->st->r_frame_rate) > 
av_q2d(ist->st->time_base)
-   && 0.5/av_q2d(ist->st->r_frame_rate) > 
av_q2d(dec_ctx->time_base)
-   && av_q2d(ist->st->time_base) < 1.0/500 && 
av_q2d(dec_ctx->time_base) < 1.0/500
- || copy_tb==2){
-enc_ctx->time_base.num = ist->st->r_frame_rate.den;
-enc_ctx->time_base.den = 2*ist->st->r_frame_rate.num;
-enc_ctx->ticks_per_frame = 2;
-} else if (   copy_tb<0 && 
av_q2d(dec_ctx->time_base)*dec_ctx->ticks_per_frame > 
2*av_q2d(ist->st->time_base)
- && av_q2d(ist->st->time_base) < 1.0/500
-|| copy_tb==0){
-enc_ctx->time_base = dec_ctx->time_base;
-enc_ctx->time_base.num *= dec_ctx->ticks_per_frame;
-enc_ctx->time_base.den *= 2;
-enc_ctx->ticks_per_frame = 2;
-}
-} else if(!(oc->oformat->flags & AVFMT_VARIABLE_FPS)
-  && strcmp(oc->oformat->name, "mov") && 
strcmp(oc->oformat->name, "mp4") && strcmp(oc->oformat->name, "3gp")
-  && strcmp(oc->oformat->name, "3g2") && 
strcmp(oc->oformat->name, "psp") && strcmp(oc->oformat->name, "ipod")
-  && strcmp(oc->oformat->name, "f4v")
-) {
-if(   copy_tb<0 && dec_ctx->time_base.den
-&& 
av_q2d(dec_ctx->time_base)*dec_ctx->ticks_per_frame > av_q2d(ist->st->time_base)
-&& av_q2d(ist->st->time_base) < 1.0/500
-   || copy_tb==0){
-enc_ctx->time_base = dec_ctx->time_base;
-enc_ctx->time_base.num *= dec_ctx->ticks_per_frame;
-}
-}
-if (   enc_ctx->codec_tag == AV_RL32("tmcd")
-&& dec_ctx->time_base.num < dec_ctx->time_base.den
-&& dec_ctx->time_base.num > 0
-&& 121LL*dec_ctx->time_base.num > dec_ctx->time_base.den) {
-enc_ctx->time_base = dec_ctx->time_base;
-}
+ret = avformat_transfer_stream_timing_info(oc->oformat, ost->st, 
ist->st, copy_tb);
+if (ret < 0)
+return ret;
 
 if (!ost->frame_rate.num)
 ost->frame_rate = ist->framerate;
-if(ost->frame_rate.num)
-enc_ctx->time_base = av_inv_q(ost->frame_rate);
-
-av_reduce(&enc_ctx->time_base.num, &enc_ctx->time_base.den,
-enc_ctx->time_base.num, enc_ctx->time_base.den, 
INT_MAX);
 
 if (ist->st->nb_side_data) {
 ost->st->side_data = av_realloc_array(NULL, 
ist->st->nb_side_data,
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 3ee7051..766e9b3 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -2893,6 +2893,18 @@ int av_apply_bitstream_filters(AVCodecContext *codec, 
AVPacket *pkt,
AVBitStreamFilterContext *bsfc);
 #endif
 
+enum AVTimebaseCopyFrom {
+AVFMT_TBCF_AUTO = -1,
+AVFMT_TBCF_DECODER,
+AVFMT_TBCF_DEMUXER,
+AVFMT_TBCF_R_FRAMERATE,
+};
+
+// TODO: doc
+int avformat_transfer_stream_timing_info(const AVOutputFormat *ofmt,
+ AVStream *ost, const AVStream *ist,
+ enum AVTimebaseCopyFrom copy_tb);
+
 /**
  * @}
  */
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 76cbff4..e0c307f 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -5281,3 +528

Re: [FFmpeg-devel] [PATCH 2/2] lavc: add hevc mediacodec decoder

2016-09-09 Thread James Almer
On 9/9/2016 11:46 AM, Matthieu Bouron wrote:
> diff --git a/libavcodec/hevc_parse.c b/libavcodec/hevc_parse.c
> new file mode 100644
> index 000..cf04bc2
> --- /dev/null
> +++ b/libavcodec/hevc_parse.c
> @@ -0,0 +1,134 @@
> +/*
> + * 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
> + */
> +
> +#include "bytestream.h"
> +#include "h2645_parse.h"
> +#include "hevc.h"
> +#include "hevc_parse.h"
> +
> +static int hevc_decode_nal_units(const uint8_t *buf, int buf_size, 
> HEVCParamSets *ps,
> + int is_nalff, int nal_length_size, void 
> *logctx)
> +{
> +int i;
> +int ret = 0;
> +H2645Packet pkt = { 0 };
> +
> +ret = ff_h2645_packet_split(&pkt, buf, buf_size, logctx, is_nalff, 
> nal_length_size, AV_CODEC_ID_HEVC, 1);
> +if (ret < 0) {
> +goto done;
> +}
> +
> +for (i = 0; i < pkt.nb_nals; i++) {
> +H2645NAL *nal = &pkt.nals[i];
> +
> +/* ignore everything except parameter sets and VCL NALUs */
> +switch (nal->type) {
> +case NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, logctx, ps);break;
> +case NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, logctx, ps, 1); break;
> +case NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, logctx, ps);break;
> +case NAL_TRAIL_R:
> +case NAL_TRAIL_N:
> +case NAL_TSA_N:
> +case NAL_TSA_R:
> +case NAL_STSA_N:
> +case NAL_STSA_R:
> +case NAL_BLA_W_LP:
> +case NAL_BLA_W_RADL:
> +case NAL_BLA_N_LP:
> +case NAL_IDR_W_RADL:
> +case NAL_IDR_N_LP:
> +case NAL_CRA_NUT:
> +case NAL_RADL_N:
> +case NAL_RADL_R:
> +case NAL_RASL_N:
> +case NAL_RASL_R:
> +av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", 
> nal->type);
> +ret = AVERROR_INVALIDDATA;
> +goto done;
> +break;
> +}
> +}
> +
> +done:
> +ff_h2645_packet_uninit(&pkt);
> +return ret;
> +}

This seems to be duplicating code from the "simple" parser in hevc_parser.c, 
which
is only compiled if libavcodec is built without the internal hevc decoder.

See if you can find a clean way to reuse it.

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


[FFmpeg-devel] [PATCH] ivfenc: Add VPX codec tags.

2016-09-09 Thread Alex Converse
This fixes remuxing VPX from MP4 without manually overwriting the tag.
---
 libavformat/ivfenc.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c
index 5dbcd97..f3ae4dc 100644
--- a/libavformat/ivfenc.c
+++ b/libavformat/ivfenc.c
@@ -97,6 +97,12 @@ static int ivf_check_bitstream(struct AVFormatContext *s, 
const AVPacket *pkt)
 return ret;
 }
 
+static const AVCodecTag codec_ivf_tags[] = {
+{ AV_CODEC_ID_VP8,  MKTAG('V', 'P', '8', '0') },
+{ AV_CODEC_ID_VP9,  MKTAG('V', 'P', '9', '0') },
+{ AV_CODEC_ID_NONE, 0 }
+};
+
 AVOutputFormat ff_ivf_muxer = {
 .priv_data_size = sizeof(IVFEncContext),
 .name = "ivf",
@@ -108,4 +114,5 @@ AVOutputFormat ff_ivf_muxer = {
 .write_packet = ivf_write_packet,
 .write_trailer = ivf_write_trailer,
 .check_bitstream = ivf_check_bitstream,
+.codec_tag= (const AVCodecTag* const []){ codec_ivf_tags, 0 },
 };
-- 
2.8.0.rc3.226.g39d4020

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


Re: [FFmpeg-devel] [PATCH 2/2] lavc: add hevc mediacodec decoder

2016-09-09 Thread James Almer
On 9/9/2016 12:04 PM, James Almer wrote:
> On 9/9/2016 11:46 AM, Matthieu Bouron wrote:
>> diff --git a/libavcodec/hevc_parse.c b/libavcodec/hevc_parse.c
>> new file mode 100644
>> index 000..cf04bc2
>> --- /dev/null
>> +++ b/libavcodec/hevc_parse.c
>> @@ -0,0 +1,134 @@
>> +/*
>> + * 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
>> + */
>> +
>> +#include "bytestream.h"
>> +#include "h2645_parse.h"
>> +#include "hevc.h"
>> +#include "hevc_parse.h"
>> +
>> +static int hevc_decode_nal_units(const uint8_t *buf, int buf_size, 
>> HEVCParamSets *ps,
>> + int is_nalff, int nal_length_size, void 
>> *logctx)
>> +{
>> +int i;
>> +int ret = 0;
>> +H2645Packet pkt = { 0 };
>> +
>> +ret = ff_h2645_packet_split(&pkt, buf, buf_size, logctx, is_nalff, 
>> nal_length_size, AV_CODEC_ID_HEVC, 1);
>> +if (ret < 0) {
>> +goto done;
>> +}
>> +
>> +for (i = 0; i < pkt.nb_nals; i++) {
>> +H2645NAL *nal = &pkt.nals[i];
>> +
>> +/* ignore everything except parameter sets and VCL NALUs */
>> +switch (nal->type) {
>> +case NAL_VPS: ff_hevc_decode_nal_vps(&nal->gb, logctx, ps);
>> break;
>> +case NAL_SPS: ff_hevc_decode_nal_sps(&nal->gb, logctx, ps, 1); 
>> break;
>> +case NAL_PPS: ff_hevc_decode_nal_pps(&nal->gb, logctx, ps);
>> break;
>> +case NAL_TRAIL_R:
>> +case NAL_TRAIL_N:
>> +case NAL_TSA_N:
>> +case NAL_TSA_R:
>> +case NAL_STSA_N:
>> +case NAL_STSA_R:
>> +case NAL_BLA_W_LP:
>> +case NAL_BLA_W_RADL:
>> +case NAL_BLA_N_LP:
>> +case NAL_IDR_W_RADL:
>> +case NAL_IDR_N_LP:
>> +case NAL_CRA_NUT:
>> +case NAL_RADL_N:
>> +case NAL_RADL_R:
>> +case NAL_RASL_N:
>> +case NAL_RASL_R:
>> +av_log(logctx, AV_LOG_ERROR, "Invalid NAL unit: %d\n", 
>> nal->type);
>> +ret = AVERROR_INVALIDDATA;
>> +goto done;
>> +break;
>> +}
>> +}
>> +
>> +done:
>> +ff_h2645_packet_uninit(&pkt);
>> +return ret;
>> +}
> 
> This seems to be duplicating code from the "simple" parser in hevc_parser.c, 
> which
> is only compiled if libavcodec is built without the internal hevc decoder.
> 
> See if you can find a clean way to reuse it.

Disregard this, it was addressed in the compose message.

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


Re: [FFmpeg-devel] [PATCH] ivfenc: Add VPX codec tags.

2016-09-09 Thread Carl Eugen Hoyos
2016-09-09 17:11 GMT+02:00 Alex Converse :
> This fixes remuxing VPX from MP4 without manually overwriting the tag.

Please push anytime.

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


[FFmpeg-devel] [PATCH]lavc: Enable a53cc by default

2016-09-09 Thread Carl Eugen Hoyos
Hi!

Attached patch enables saving closed caption by default if available.

Please comment, Carl Eugen
From f8db342abefbe33b78a7291592eb542bc18b3d07 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Fri, 9 Sep 2016 17:56:46 +0200
Subject: [PATCH] lavc: Enable a53cc by default for x264 and qsv_h264.

---
 libavcodec/libx264.c |2 +-
 libavcodec/qsvenc_h264.c |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index b730c91..9e12464 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -907,7 +907,7 @@ static const AVOption options[] = {
 {"level", "Specify level (as defined by Annex A)", OFFSET(level), 
AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE},
 {"passlogfile", "Filename for 2 pass stats", OFFSET(stats), 
AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE},
 {"wpredp", "Weighted prediction for P-frames", OFFSET(wpredp), 
AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, VE},
-{"a53cc",  "Use A53 Closed Captions (if available)",  
OFFSET(a53_cc),AV_OPT_TYPE_BOOL,   {.i64 = 0}, 0, 1, VE},
+{"a53cc",  "Use A53 Closed Captions (if available)",  
OFFSET(a53_cc),AV_OPT_TYPE_BOOL,   {.i64 = 1}, 0, 1, VE},
 {"x264opts", "x264 options", OFFSET(x264opts), AV_OPT_TYPE_STRING, 
{.str=NULL}, 0, 0, VE},
 { "crf",   "Select the quality for constant quality mode",
OFFSET(crf),   AV_OPT_TYPE_FLOAT,  {.dbl = -1 }, -1, FLT_MAX, VE },
 { "crf_max",   "In CRF mode, prevents VBV from lowering quality beyond 
this point.",OFFSET(crf_max), AV_OPT_TYPE_FLOAT, {.dbl = -1 }, -1, FLT_MAX, VE 
},
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 84513be..c1f6003 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -138,7 +138,7 @@ static const AVOption options[] = {
 { "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_AVC_MAIN
 }, INT_MIN, INT_MAX, VE, "profile" },
 { "high", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_AVC_HIGH
 }, INT_MIN, INT_MAX, VE, "profile" },
 
-{ "a53cc" , "Use A53 Closed Captions (if available)", OFFSET(qsv.a53_cc), 
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, VE},
+{ "a53cc" , "Use A53 Closed Captions (if available)", OFFSET(qsv.a53_cc), 
AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, VE},
 { NULL },
 };
 
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH v4] lavf : scale_vaapi : add denoise/sharpless support

2016-09-09 Thread Mark Thompson
On 09/09/16 04:31, Jun Zhao wrote:
> v4 : - fix sharpless typo(sharpless -> sharpness)
>  - when don't support denoise/sharpness, report the error and return
>  - fix denoise/sharpness params buffer leak in error handle
> v3 : fix sharpless mapping issue
> v2 : fix filter support flag check logic issue
> 
> From d1f0b556bdd6be4dffcd3b1b93cba5cd1098908a Mon Sep 17 00:00:00 2001
> From: Jun Zhao 
> Date: Tue, 30 Aug 2016 14:36:00 +0800
> Subject: [PATCH v4] lavf : scale_vaapi : add denoise/sharpless support.

I think libavfilter is generally "lavfi" ("lavf" is libavformat).

> add denoise/sharpless support, used scope [-1, 100] as the input
> scope.
>
> Signed-off-by: Jun Zhao 
> ---
>  libavfilter/vf_scale_vaapi.c | 112 
> +++
>  1 file changed, 112 insertions(+)
>
> diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
> index 8dd5acf..e48e201 100644
> --- a/libavfilter/vf_scale_vaapi.c
> +++ b/libavfilter/vf_scale_vaapi.c
> @@ -53,6 +53,14 @@ typedef struct ScaleVAAPIContext {
>  int output_width;
>  int output_height;
>
> +VAProcFilterCap denoise_caps;
> +int denoise; // enable denoise algo. level is the optional
> + // value from the interval [-1, 100], -1 means 
> disabled
> +
> +VAProcFilterCap sharpness_caps;
> +int sharpness;   // enable sharpness. level is the optional value
> + // from the interval [-1, 100], -1 means disabled
> +
>  } ScaleVAAPIContext;
>
>
> @@ -117,6 +125,8 @@ static int scale_vaapi_config_output(AVFilterLink 
> *outlink)
>  AVVAAPIFramesContext *va_frames;
>  VAStatus vas;
>  int err, i;
> +unsigned int num_denoise_caps = 1;
> +unsigned int num_sharpness_caps = 1;
>
>  scale_vaapi_pipeline_uninit(ctx);
>
> @@ -225,6 +235,28 @@ static int scale_vaapi_config_output(AVFilterLink 
> *outlink)
>  goto fail;
>  }
>
> +if (ctx->denoise != -1) {
> +vas = vaQueryVideoProcFilterCaps(ctx->hwctx->display, 
> ctx->va_context,
> + VAProcFilterNoiseReduction,
> + &ctx->denoise_caps, 
> &num_denoise_caps);
> +if (vas != VA_STATUS_SUCCESS) {
> +av_log(ctx, AV_LOG_ERROR, "Failed to query denoise caps "
> +   "context: %d (%s).\n", vas, vaErrorStr(vas));
> +return AVERROR(EIO);
> +}
> +}
> +
> +if (ctx->sharpness != -1) {
> +vas = vaQueryVideoProcFilterCaps(ctx->hwctx->display, 
> ctx->va_context,
> + VAProcFilterSharpening,
> + &ctx->sharpness_caps, 
> &num_sharpness_caps);
> +if (vas != VA_STATUS_SUCCESS) {
> +av_log(ctx, AV_LOG_ERROR, "Failed to query sharpness caps "
> +   "context: %d (%s).\n", vas, vaErrorStr(vas));
> +return AVERROR(EIO);
> +}
> +}
> +
>  av_freep(&hwconfig);
>  av_hwframe_constraints_free(&constraints);
>  return 0;
> @@ -250,6 +282,14 @@ static int vaapi_proc_colour_standard(enum AVColorSpace 
> av_cs)
>  }
>  }
>
> +static float map_to_range(
> +int input, int in_min, int in_max,
> +float out_min, float out_max)
> +{
> +return (input - in_min) * (out_max - out_min) / (in_max - in_min) + 
> out_min;
> +}
> +
> +
>  static int scale_vaapi_filter_frame(AVFilterLink *inlink, AVFrame 
> *input_frame)
>  {
>  AVFilterContext *avctx = inlink->dst;
> @@ -259,6 +299,10 @@ static int scale_vaapi_filter_frame(AVFilterLink 
> *inlink, AVFrame *input_frame)
>  VASurfaceID input_surface, output_surface;
>  VAProcPipelineParameterBuffer params;
>  VABufferID params_id;
> +VABufferID denoise_id;
> +VABufferID sharpness_id;
> +VABufferID filter_bufs[8];

VAProcFilterCount might be a better number than 8 as an upper bound on the 
number of filters which could ever be added to this.

> +int num_filter_bufs = 0;
>  VAStatus vas;
>  int err;
>
> @@ -290,6 +334,43 @@ static int scale_vaapi_filter_frame(AVFilterLink 
> *inlink, AVFrame *input_frame)
>  av_log(ctx, AV_LOG_DEBUG, "Using surface %#x for scale output.\n",
> output_surface);
>
> +if (ctx->denoise != -1) {
> +VAProcFilterParameterBuffer denoise;
> +denoise.type  = VAProcFilterNoiseReduction;
> +denoise.value =  map_to_range(ctx->denoise, 0, 100,
> +  ctx->denoise_caps.range.min_value,
> +  ctx->denoise_caps.range.max_value);
> +vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context,
> +   VAProcFilterParameterBufferType, sizeof(denoise), 1,
> +   &denoise, &denoise_id);
> +if (vas != VA_STATUS_SUCCESS) {
> +av_log(ctx, AV_LOG_ERROR,  "Failed to create denoise parameter 
> buffer: "
> +  

[FFmpeg-devel] [PATCH] Fix target_level for EAC3.

2016-09-09 Thread Nikolas Bowe
Currently when using target_level with EAC3 it produces silence. This small 
patch fixes target_level for decoding EAC3.

Example:
ffmpeg -y -i /tmp/test.wav -acodec eac3 -dialnorm -14 -ac 6 -b:a 384000 
/tmp/test.m2ts
ffmpeg -y -target_level -24 -i /tmp/test.m2ts -acodec pcm_s16le -f matroska 
/tmp/out.mkv
ffplay /tmp/out.mkv
---
 libavcodec/ac3.h |  2 +-
 libavcodec/ac3dec.c  |  9 ++---
 libavcodec/ac3dec.h  |  4 
 libavcodec/eac3dec.c | 14 +++---
 4 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h
index 747f2f5..5c9c377 100644
--- a/libavcodec/ac3.h
+++ b/libavcodec/ac3.h
@@ -87,7 +87,7 @@ typedef int16_t SHORTFLOAT;
 #define AC3_NORM(norm)  (1.0f/(norm))
 #define AC3_MUL(a,b)((a) * (b))
 #define AC3_RANGE(x)(dynamic_range_tab[(x)])
-#define AC3_HEAVY_RANGE(x)  (heavy_dynamic_range_tab[(x)])
+#define AC3_HEAVY_RANGE(x)  (ff_ac3_heavy_dynamic_range_tab[(x)])
 #define AC3_DYNAMIC_RANGE(x)(powf(x,  s->drc_scale))
 #define AC3_SPX_BLEND(x)(x)* (1.0f/32)
 #define AC3_DYNAMIC_RANGE1  1.0f
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index fac189b..a95c204 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -63,9 +63,11 @@ static const uint8_t quantization_tab[16] = {
 5, 6, 7, 8, 9, 10, 11, 12, 14, 16
 };
 
+#if (!USE_FIXED)
 /** dynamic range table. converts codes to scale factors. */
 static float dynamic_range_tab[256];
-static float heavy_dynamic_range_tab[256];
+float ff_ac3_heavy_dynamic_range_tab[256];
+#endif
 
 /** Adjustments in dB gain */
 static const float gain_levels[9] = {
@@ -159,6 +161,7 @@ static av_cold void ac3_tables_init(void)
 b5_mantissas[i] = symmetric_dequant(i, 15);
 }
 
+#if (!USE_FIXED)
 /* generate dynamic range table
reference: Section 7.7.1 Dynamic Range Control */
 for (i = 0; i < 256; i++) {
@@ -170,9 +173,9 @@ static av_cold void ac3_tables_init(void)
reference: Section 7.7.2 Heavy Compression */
 for (i = 0; i < 256; i++) {
 int v = (i >> 4) - ((i >> 7) << 4) - 4;
-heavy_dynamic_range_tab[i] = powf(2.0f, v) * ((i & 0xF) | 0x10);
+ff_ac3_heavy_dynamic_range_tab[i] = powf(2.0f, v) * ((i & 0xF) | 0x10);
 }
-
+#endif
 }
 
 /**
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index c2b867e..6cd67c0 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -260,4 +260,8 @@ static void 
ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch);
  */
 static void ff_eac3_apply_spectral_extension(AC3DecodeContext *s);
 
+#if (!USE_FIXED)
+extern float ff_ac3_heavy_dynamic_range_tab[256];
+#endif
+
 #endif /* AVCODEC_AC3DEC_H */
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index 47e5aa6..83a54bc 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -339,9 +339,17 @@ static int ff_eac3_parse_header(AC3DecodeContext *s)
 
 /* volume control params */
 for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
-skip_bits(gbc, 5); // skip dialog normalization
-if (get_bits1(gbc)) {
-skip_bits(gbc, 8); // skip compression gain word
+s->dialog_normalization[i] = -get_bits(gbc, 5);
+if (s->dialog_normalization[i] == 0) {
+s->dialog_normalization[i] = -31;
+}
+if (s->target_level != 0) {
+s->level_gain[i] = powf(2.0f,
+(float)(s->target_level - s->dialog_normalization[i])/6.0f);
+}
+s->compression_exists[i] = get_bits1(gbc);
+if (s->compression_exists[i]) {
+s->heavy_dynamic_range[i] = AC3_HEAVY_RANGE(get_bits(gbc, 8));
 }
 }
 
-- 
2.8.0.rc3.226.g39d4020

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


Re: [FFmpeg-devel] [PATCH] avformat/segment: fix the duration error of use output_ts_offset

2016-09-09 Thread Steven Liu
Steven Liu 于2016年9月9日 周五下午7:59写道:

> 2016-09-09 16:33 GMT+08:00 Steven Liu :
>
>>
>>
>> 2016-09-09 16:10 GMT+08:00 Steven Liu :
>>
>>>
>>>
>>> 2016-09-09 15:33 GMT+08:00 Steven Liu :
>>>


 2016-09-09 15:28 GMT+08:00 Aman Gupta :

> I tried your patch and TARGETDURATION is fixed, but it is still
> creating some segments which are only 0.2s instead of 2s.
>
> Aman
>
> On Thu, Sep 8, 2016 at 8:14 PM, Steven Liu 
> wrote:
>
>> This patch can merge with 1da00be009aa74400042bf470b9a5ffbd82a1c5e
>> i have checked this modify:
>>
>> ./ffmpeg -i ~/facebook.mp4 -c copy -f segment -segment_time 2
>> -output_ts_offset 80 -segment_list output-test.m3u8 -v debug
>> output-test-%03d.ts
>>
>> #EXTM3U
>> #EXT-X-VERSION:3
>> #EXT-X-MEDIA-SEQUENCE:0
>> #EXT-X-ALLOW-CACHE:YES
>> #EXT-X-TARGETDURATION:10
>> #EXTINF:4.12,
>> output-test-000.ts
>> #EXTINF:7.84,
>> output-test-001.ts
>> #EXTINF:4.20,
>> output-test-002.ts
>> #EXTINF:2.92,
>> output-test-003.ts
>> #EXTINF:1.84,
>> output-test-004.ts
>> #EXTINF:2.24,
>> output-test-005.ts
>> #EXTINF:2.00,
>> output-test-006.ts
>> #EXTINF:3.56,
>>
>>
>> [root@localhost linux]# ffmpeg -i output-test.m3u8
>> ffmpeg version N-80917-ga1a240b Copyright (c) 2000-2016 the FFmpeg
>> developers
>>   built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
>>   configuration: --prefix=/usr/ --libdir=/usr/lib64 --enable-libx264
>> --enable-libfaac --enable-gpl --enable-nonfree
>>   libavutil  55. 28.100 / 55. 28.100
>>   libavcodec 57. 48.102 / 57. 48.102
>>   libavformat57. 41.100 / 57. 41.100
>>   libavdevice57.  0.102 / 57.  0.102
>>   libavfilter 6. 47.100 /  6. 47.100
>>   libswscale  4.  1.100 /  4.  1.100
>>   libswresample   2.  1.100 /  2.  1.100
>>   libpostproc54.  0.100 / 54.  0.100
>> Input #0, hls,applehttp, from 'output-test.m3u8':
>>   Duration: 00:03:21.04, start: 81.40, bitrate: 0 kb/s
>>   Program 0
>> Metadata:
>>   variant_bitrate : 0
>> Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B),
>> yuv420p, 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
>> Stream #0:1: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz,
>> 5.1(side), fltp, 384 kb/s
>> At least one output file must be specified
>>
>>
>>
>> [root@localhost linux]# ffmpeg -i output-test-000.ts -i
>> output-test-001.ts
>> ffmpeg version N-80917-ga1a240b Copyright (c) 2000-2016 the FFmpeg
>> developers
>>   built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
>>   configuration: --prefix=/usr/ --libdir=/usr/lib64 --enable-libx264
>> --enable-libfaac --enable-gpl --enable-nonfree
>>   libavutil  55. 28.100 / 55. 28.100
>>   libavcodec 57. 48.102 / 57. 48.102
>>   libavformat57. 41.100 / 57. 41.100
>>   libavdevice57.  0.102 / 57.  0.102
>>   libavfilter 6. 47.100 /  6. 47.100
>>   libswscale  4.  1.100 /  4.  1.100
>>   libswresample   2.  1.100 /  2.  1.100
>>   libpostproc54.  0.100 / 54.  0.100
>> Input #0, mpegts, from 'output-test-000.ts':
>>   Duration: 00:00:04.12, start: 81.40, bitrate: 1299 kb/s
>>   Program 1
>> Metadata:
>>   service_name: Service01
>>   service_provider: FFmpeg
>> Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
>> yuv420p, 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
>> Stream #0:1[0x101](und): Audio: ac3 ([129][0][0][0] / 0x0081),
>> 48000 Hz, 5.1(side), fltp, 384 kb/s
>> Input #1, mpegts, from 'output-test-001.ts':
>>   Duration: 00:00:07.90, start: 85.464000, bitrate: 1679 kb/s
>>   Program 1
>> Metadata:
>>   service_name: Service01
>>   service_provider: FFmpeg
>> Stream #1:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
>> yuv420p, 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
>> Stream #1:1[0x101](und): Audio: ac3 ([129][0][0][0] / 0x0081),
>> 48000 Hz, 5.1(side), fltp, 384 kb/s
>> At least one output file must be specified
>> [root@localhost linux]#
>>
>>
>>
>>
>> this commit is used for fix commit
>> 1da00be009aa74400042bf470b9a5ffbd82a1c5e
>> because the option initial_offset will deprecated
>>
>> Signed-off-by: Steven Liu 
>> ---
>>  libavformat/segment.c |5 +
>>  1 files changed, 5 insertions(+), 0 deletions(-)
>>
>> diff --git a/libavformat/segment.c b/libavformat/segment.c
>> index 33a5cf0..252f8b1 100644
>> --- a/libavformat/segment.c
>> +++ b/libavformat/segment.c
>> @@ -885,6 +885,11 @@ calc_times:
>>  av_log(s, AV_LOG_VERBOSE, "segment:'%s' st

Re: [FFmpeg-devel] Evolution of lavfi's design and API

2016-09-09 Thread Paul B Mahol
On 9/4/16, Michael Niedermayer  wrote:
> On Sun, Sep 04, 2016 at 10:16:57PM +0200, Nicolas George wrote:
>> Le nonidi 19 fructidor, an CCXXIV, Paul B Mahol a ecrit :
>> > And what would that cleaner implementation do?
>>
>> There is a rather simple implementation of format change in lavfi: have
>> on
>> each input a boolean flag "can_deal_with_format_change". If a frame with
>> a
>> different format arrives on a filter that does not have the flag, just
>> insert the scale/aresample filter on the link to force the format to be
>> the
>> same.
>>
>> It is not entirely optimal, but it is quite simple and does the work.
>>
>> And it could probably be implemented independently of my changes. But I
>> do
>> not want to spend time on it before finishing this, or it will never end.
>>
>> (Actually, I think we had something like that for buffersrc but it
>> disappeared at some time. avconv also has some very strange code to
>> handle
>> format changes.)
>
> we have a few filters that should work fine with format changes
> i would have assumed that still works
>
>
>>
>> > At current rate your lavfi changes will never get in, which sucks.
>>
>> Which is why I would like to be authorized to ignore this kind of
>> hiccups.
>> Format change does not currently work, this particular case used to work
>> only by chance. Can I break it and repair it later?
>
> I think there are 2 things
> First, filters simply supporting format changes without any magic or
> reinitialization,
> they just work if formats change. This should continue to be so
> but it also shouldnt really add any complication or am i missing
> something ?
> This was the type i was interrested in previously ... (until patch
> reviews made me loose interrest)
>
> Second, graph reinitialization, this is hard to get right and if its
> done right it still doesnt work for many usecases due to destroyed
> state.
> I dont think temporary worsening graph reinitialization is a problem
> but thats just my oppinion
>

So everybody agrees, we should proceed.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 3/3] lavc/wmv2dec: add #if around AVCodec def

2016-09-09 Thread Rodger Combs
---
 libavcodec/wmv2dec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index 20dbee5..477196e 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -455,6 +455,7 @@ int ff_wmv2_decode_mb(MpegEncContext *s, int16_t 
block[6][64])
 return 0;
 }
 
+#if CONFIG_WMV2_DECODER
 static av_cold int wmv2_decode_init(AVCodecContext *avctx)
 {
 Wmv2Context *const w = avctx->priv_data;
@@ -495,3 +496,4 @@ AVCodec ff_wmv2_decoder = {
 .pix_fmts   = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV420P,
  AV_PIX_FMT_NONE },
 };
+#endif
-- 
2.10.0

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


[FFmpeg-devel] [PATCH 1/3] lavc/Makefile: g729dec: fix missing file

2016-09-09 Thread Rodger Combs
---
 libavcodec/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 7396468..fa2318a 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -297,7 +297,7 @@ OBJS-$(CONFIG_G723_1_DECODER)  += g723_1dec.o 
g723_1.o \
   acelp_vectors.o celp_filters.o 
celp_math.o
 OBJS-$(CONFIG_G723_1_ENCODER)  += g723_1enc.o g723_1.o \
   acelp_vectors.o celp_filters.o 
celp_math.o
-OBJS-$(CONFIG_G729_DECODER)+= g729dec.o lsp.o celp_math.o 
acelp_filters.o acelp_pitch_delay.o acelp_vectors.o g729postfilter.o
+OBJS-$(CONFIG_G729_DECODER)+= g729dec.o lsp.o celp_math.o 
celp_filters.o acelp_filters.o acelp_pitch_delay.o acelp_vectors.o 
g729postfilter.o
 OBJS-$(CONFIG_GIF_DECODER) += gifdec.o lzw.o
 OBJS-$(CONFIG_GIF_ENCODER) += gif.o lzwenc.o
 OBJS-$(CONFIG_GSM_DECODER) += gsmdec.o gsmdec_data.o msgsmdec.o
-- 
2.10.0

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


[FFmpeg-devel] [PATCH 2/3] lavc/Makefile: add missing ADPCM_THP_LE objs

2016-09-09 Thread Rodger Combs
---
 libavcodec/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index fa2318a..9c7302a 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -753,6 +753,7 @@ OBJS-$(CONFIG_ADPCM_SBPRO_4_DECODER)  += adpcm.o 
adpcm_data.o
 OBJS-$(CONFIG_ADPCM_SWF_DECODER)  += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_SWF_ENCODER)  += adpcmenc.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_THP_DECODER)  += adpcm.o adpcm_data.o
+OBJS-$(CONFIG_ADPCM_THP_LE_DECODER)   += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_VIMA_DECODER) += vima.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_XA_DECODER)   += adpcm.o adpcm_data.o
 OBJS-$(CONFIG_ADPCM_YAMAHA_DECODER)   += adpcm.o adpcm_data.o
-- 
2.10.0

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


[FFmpeg-devel] [PATCH] configure: add linker export script support on Darwin

2016-09-09 Thread Rodger Combs
This isn't a "version script" in the usual sense, since it doesn't set symbol
versions directly. Instead, the version for the whole .dylib is set in the
linker flags, and we generate a list of symbol patterns to export. This allows
us to keep our local symbols (e.g. ff_*) local on the platform.

The Darwin linker's exported_symbols_list format is a bit different than the
one used by the GNU linker. It doesn't handle local symbols at all, since when
a list is provided, all unlisted symbols are local by default; thus, we remove
local sections. It doesn't handle per-version sections, so we remove the
headers and brackets. It expects symbols to be prefixed with an underscore.
It errors if a listed symbol with no wildcards is not present in the output,
so we append an asterisk to any symbol that doesn't already end in one.
---
 configure | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configure b/configure
index b11ca7f..29eb35b 100755
--- a/configure
+++ b/configure
@@ -4704,6 +4704,8 @@ case $target_os in
 { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; }
 check_header dispatch/dispatch.h &&
 add_cppflags '-I\$(SRC_PATH)/compat/dispatch_semaphore'
+version_script='-exported_symbols_list'
+VERSION_SCRIPT_POSTPROCESS_CMD='tr " " "\n" | sed -n 
/global:/,/local:/p | grep ";" | tr ";" "\n" | sed -E "s/(.+)/_\1/g" | sed -E 
"s/(.+[^*])/\1*/"'
 ;;
 msys*)
 die "Native MSYS builds are discouraged, please use the MINGW 
environment."
-- 
2.10.0

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


Re: [FFmpeg-devel] [PATCH 1/3] lavc/Makefile: g729dec: fix missing file

2016-09-09 Thread Michael Niedermayer
On Fri, Sep 09, 2016 at 06:00:05PM -0500, Rodger Combs wrote:
> ---
>  libavcodec/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

LGTM

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

Those who are best at talking, realize last or never when they are wrong.


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


Re: [FFmpeg-devel] [PATCH 3/3] lavc/wmv2dec: add #if around AVCodec def

2016-09-09 Thread Michael Niedermayer
On Fri, Sep 09, 2016 at 06:00:07PM -0500, Rodger Combs wrote:
> ---
>  libavcodec/wmv2dec.c | 2 ++
>  1 file changed, 2 insertions(+)

why ?

the whole file is already conditionally build on just CONFIG_WMV2_DECODER

or am i missing something ?

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

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates


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


Re: [FFmpeg-devel] [PATCH 2/3] lavc/Makefile: add missing ADPCM_THP_LE objs

2016-09-09 Thread Michael Niedermayer
On Fri, Sep 09, 2016 at 06:00:06PM -0500, Rodger Combs wrote:
> ---
>  libavcodec/Makefile | 1 +
>  1 file changed, 1 insertion(+)

LGTM

thx

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

Observe your enemies, for they first find out your faults. -- Antisthenes


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


Re: [FFmpeg-devel] [PATCH] added expr evaluation to drawtext - fontsize

2016-09-09 Thread Brett Harrison
Here are the changes requested

On Thu, Sep 8, 2016 at 8:50 AM, Michael Niedermayer 
wrote:

> On Tue, Sep 06, 2016 at 10:27:24AM -0700, Brett Harrison wrote:
> > This patch addresses your concerns.
> >
> > On Fri, Sep 2, 2016 at 5:05 PM, Michael Niedermayer
> 
> > wrote:
> >
> > > On Fri, Sep 02, 2016 at 03:31:21PM -0700, Brett Harrison wrote:
> > > > Addressed the following concerns.
> > > >
> > > > ===
> > > >
> > > > >libavfilter/vf_drawtext.c: In function ‘update_fontsize’:
> > > > >libavfilter/vf_drawtext.c:422:5: warning: ISO C90 forbids mixed
> > > declarations and code [->Wdeclaration-after-statement]
> > > >
> > > > Fixed this.
> > > >
> > > > >also patch breaks:
> > > > >./ffmpeg -i m.mpg  -vf >drawtext=fontfile=/usr/share/
> > > fonts/truetype/msttcorefonts/arial.ttf:text=a -f null -
> > > >
> > > > >[AVFilterGraph @ 0x37a6960] Error initializing filter 'drawtext'
> with
> > > args >'fontfile=/usr/share/fonts/truetype/msttcorefonts/arial.
> ttf:text=a'
> > > >
> > > > This is fixed.
> > > >
> > > > ===
> > > >
> > > > >>* +av_log(ctx, AV_LOG_ERROR, "Font not open\n");
> > > > *
> > > > >I was wondering: Was does this message tell the user?
> > > >
> > > > I changed this error to read "Unable to initialize font".  This error
> > > > should only be seen if set_fontsize() is called before the font is
> > > > loaded.  I don't think a user would be able to cause this because if
> > > > the font fails to load ffmpeg would error out before this.  It is a
> > > > sanity check.
> > > >
> > > > ===
> > > >
> > > > For the concerns about multiple to many brackets on "if ((ret =
> > > > update_fontsize(ctx)))",
> > > >
> > > > I removed the "ret =" part as I wasn't using the value anyway.
> > > >
> > > >
> > > > On Fri, Sep 2, 2016 at 6:13 AM, Nicolas George 
> wrote:
> > > >
> > > > > Le septidi 17 fructidor, an CCXXIV, Moritz Barsnick a écrit :
> > > > > > *Assuming* he means "assign update_fontsize()'s return value to
> ret,
> > > > > > and check whether ret is != 0", which would correspond to the
> more
> > > > > > verbose
> > > > > >   if ((ret = update_fontsize(ctx)) != 0) {
> > > > > >
> > > > > > is it sufficient to say:
> > > > > >   if (ret = update_fontsize(ctx)) {
> > > > > >
> > > > > > or is it required, or is it more readable or even desired by
> "style
> > > > > > guide" to say:
> > > > > >   if ((ret = update_fontsize(ctx))) {
> > > > > > (to clarify it's a check of an assignment) - this is what Brett
> used,
> > > > >
> > > > > Ah. Parentheses over the whole expression are always optional, but
> in
> > > this
> > > > > particular case, there is a good reason:
> > > > >
> > > > > :4:1: warning: suggest parentheses around assignment used as
> > > truth
> > > > > value [-Wparentheses]
> > > > >
> > > > > Forgetting to double the equal in a comparison is a common mistake,
> > > > > compilers detect it. But then you need a way of stating when it is
> > > > > intentional.
> > > > >
> > > > > Regards,
> > > > >
> > > > > --
> > > > >   Nicolas George
> > > > >
> > > > > ___
> > > > > ffmpeg-devel mailing list
> > > > > ffmpeg-devel@ffmpeg.org
> > > > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > > > >
> > > > >
> > >
> > > >  vf_drawtext.c |  125 ++
> > > +---
> > > >  1 file changed, 112 insertions(+), 13 deletions(-)
> > > > 311d60f04d959ddfd47ed8ea66d0f015725dd511
> 0001-added-expr-evaluation-to-
> > > drawtext-fontsize.patch
> > > > From 665b3f1c458222d64a9ba4f1c71d343766ee9e6b Mon Sep 17 00:00:00
> 2001
> > > > From: Brett Harrison 
> > > > Date: Fri, 26 Aug 2016 14:29:34 -0700
> > > > Subject: [PATCH] added expr evaluation to drawtext - fontsize
> > > >
> > > > ---
> > > >  libavfilter/vf_drawtext.c | 125 ++
> > > +++-
> > > >  1 file changed, 112 insertions(+), 13 deletions(-)
> > > >
> > > > diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
> > > > index 214aef0..a483679 100644
> > > > --- a/libavfilter/vf_drawtext.c
> > > > +++ b/libavfilter/vf_drawtext.c
> > > > @@ -156,7 +156,10 @@ typedef struct DrawTextContext {
> > > >  int max_glyph_h;///< max glyph height
> > > >  int shadowx, shadowy;
> > > >  int borderw;///< border width
> > > > +char *fontsize_expr;///< expression for fontsize
> > > > +AVExpr *fontsize_pexpr; ///< parsed expressions for
> fontsize
> > > >  unsigned int fontsize;  ///< font size to use
> > > > +unsigned int default_fontsize;  ///< default font size to use
> > > >
> > > >  short int draw_box; ///< draw box around text -
> true or
> > > false
> > > >  int boxborderw; ///< box border width
> > > > @@ -209,7 +212,7 @@ static const AVOption drawtext_options[]= {
> > > >  {"shadowcolor", "set shadow color",
>  OFFSET(shadowcolor.rgba),
> > >  AV_OPT_TYPE_COLOR,  {.str="b

[FFmpeg-devel] [PATCH] lavf/mov: strip com.apple.quicktime prefix in meta; parse creation date

2016-09-09 Thread Rodger Combs
---
 libavformat/mov.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 54530e3..103927b 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -42,6 +42,7 @@
 #include "libavutil/aes_ctr.h"
 #include "libavutil/sha.h"
 #include "libavutil/timecode.h"
+#include "libavutil/parseutils.h"
 #include "libavcodec/ac3tab.h"
 #include "libavcodec/mpegaudiodecheader.h"
 #include "avformat.h"
@@ -476,6 +477,28 @@ retry:
 return ret;
 }
 str[str_size] = 0;
+if (!strcmp(key, "com.apple.quicktime.creationdate")) {
+struct tm *ptm, tmbuf;
+int64_t timeval;
+if (av_parse_time(&timeval, str, 0) >= 0) {
+time_t timet = timeval / 100;
+if (ptm = gmtime_r(&timet, &tmbuf)) {
+if (str_size < 29) {
+av_free(str);
+str = av_malloc(29);
+if (!str)
+return AVERROR(ENOMEM);
+}
+strftime(str, str_size, "%Y-%m-%dT%H:%M:%S", ptm);
+av_strlcatf(str, str_size, ".%06dZ", (int)(timeval % 
100));
+key = "creation_time";
+}
+}
+} else if (!strcmp(key, "com.apple.quicktime.location.ISO6709")) {
+key = "location";
+} else if (!strncmp(key, "com.apple.quicktime.", 20)) {
+key += 20;
+}
 }
 c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
 av_dict_set(&c->fc->metadata, key, str, 0);
-- 
2.10.0

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


[FFmpeg-devel] [PATCH 1/2] lavf/mov: fix parsing QuickTime meta after the first track

2016-09-09 Thread Rodger Combs
I'm not entirely sure why found_hdlr_mdta existed to begin with, so cc-ing
Tinglin Liu (who originally wrote the patch) and Derek Buitenhuis (who signed
off on it) hoping for some background. If these checks actually do have a
purpose, then the `type == MKTAG('m','d','t','a')` check should be moved
to before the `c->fc->nb_streams < 1` check instead of inside it.
---
 libavformat/isom.h |  1 -
 libavformat/mov.c  | 10 +++---
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 2246fed..6b6f678 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -198,7 +198,6 @@ typedef struct MOVContext {
 int64_t duration; ///< duration of the longest track
 int found_moov;   ///< 'moov' atom has been found
 int found_mdat;   ///< 'mdat' atom has been found
-int found_hdlr_mdta;  ///< 'hdlr' atom with type 'mdta' has been found
 int trak_index;   ///< Index of the current 'trak'
 char **meta_keys;
 unsigned meta_keys_count;
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 6e80b93..54530e3 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -381,7 +381,7 @@ retry:
 av_log(c->fc, AV_LOG_ERROR, "Error parsing cover art.\n");
 }
 return ret;
-} else if (!key && c->found_hdlr_mdta && c->meta_keys) {
+} else if (!key && c->meta_keys) {
 uint32_t index = AV_RB32(&atom.type);
 if (index < c->meta_keys_count) {
 key = c->meta_keys[index];
@@ -694,12 +694,8 @@ static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 av_log(c->fc, AV_LOG_TRACE, "ctype= %.4s (0x%08x)\n", (char*)&ctype, 
ctype);
 av_log(c->fc, AV_LOG_TRACE, "stype= %.4s\n", (char*)&type);
 
-if (c->trak_index < 0) {  // meta not inside a trak
-if (type == MKTAG('m','d','t','a')) {
-c->found_hdlr_mdta = 1;
-}
+if (c->fc->nb_streams < 1) // meta before first trak
 return 0;
-}
 
 st = c->fc->streams[c->fc->nb_streams-1];
 
@@ -4505,7 +4501,7 @@ static int mov_read_default(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 
 // Supports parsing the QuickTime Metadata Keys.
 // 
https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/Metadata/Metadata.html
-if (!parse && c->found_hdlr_mdta &&
+if (!parse &&
 atom.type == MKTAG('m','e','t','a') &&
 a.type == MKTAG('k','e','y','s')) {
 parse = mov_read_keys;
-- 
2.10.0

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


[FFmpeg-devel] [PATCH 2/2] lavf/mov: strip com.apple.quicktime prefix in meta; parse creation date

2016-09-09 Thread Rodger Combs
---
 libavformat/mov.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 54530e3..b75acd2 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -42,6 +42,7 @@
 #include "libavutil/aes_ctr.h"
 #include "libavutil/sha.h"
 #include "libavutil/timecode.h"
+#include "libavutil/parseutils.h"
 #include "libavcodec/ac3tab.h"
 #include "libavcodec/mpegaudiodecheader.h"
 #include "avformat.h"
@@ -476,6 +477,21 @@ retry:
 return ret;
 }
 str[str_size] = 0;
+if (!strcmp(key, "com.apple.quicktime.creationdate")) {
+struct tm *ptm, tmbuf;
+int64_t timeval;
+if (av_parse_time(&timeval, str, 0) >= 0) {
+time_t timet = timeval / 100;
+if (ptm = gmtime_r(&timet, &tmbuf)) {
+strftime(str, str_size, "%Y-%m-%d %H:%M:%S", ptm);
+key = "creation_time";
+}
+}
+} else if (!strcmp(key, "com.apple.quicktime.location.ISO6709")) {
+key = "location";
+} else if (!strncmp(key, "com.apple.quicktime.", 20)) {
+key += 20;
+}
 }
 c->fc->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
 av_dict_set(&c->fc->metadata, key, str, 0);
-- 
2.10.0

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


[FFmpeg-devel] [PATCH 3/3] lavf/mov: reindent

2016-09-09 Thread Rodger Combs
---
 libavformat/mov.c | 158 +++---
 1 file changed, 79 insertions(+), 79 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 22ca809..b387311 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4655,94 +4655,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);
-
-if (st->codec->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;
-}
+sc = st->priv_data;
+cur_pos = avio_tell(sc->pb);
+
+if (st->codec->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->codec->codec_type = AVMEDIA_TYPE_DATA;
-st->codec->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->codec->codec_type = AVMEDIA_TYPE_DATA;
+st->codec->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;
+}
 
-// the first two bytes are the length of the title
-len = avio_rb16(sc->pb);
-if (len > sample->size-2)
-continue;
-title_len = 2*len + 1;
-if (!(title = av_mallocz(title_len)))
-goto finish;
-
-// The samples could theoretically be in any encoding if there's 

[FFmpeg-devel] [PATCH 1/3] lavf: add AV_DISPOSITION_TIMED_THUMBNAILS

2016-09-09 Thread Rodger Combs
---
 ffprobe.c   |  1 +
 libavformat/avformat.h  | 12 +---
 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 +++---
 14 files changed, 42 insertions(+), 23 deletions(-)

diff --git a/ffprobe.c b/ffprobe.c
index 657867d..5063a81 100644
--- a/ffprobe.c
+++ b/ffprobe.c
@@ -2369,6 +2369,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 3ee7051..4792e20 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -837,11 +837,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/tests/ref/fate/concat-demuxer-extended-lavf-mxf 
b/tests/ref/fate/concat-demuxer-extended-lavf-mxf
index b894938..3905d9e 100644
--- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf
+++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf
@@ -1 +1 @@
-0aa1ca6ff6e2e5aa926454d22fdaecd5 
*tests/data/fate/concat-demuxer-extended-lavf-mxf.ffprobe
+1d10572ab480d3356f57940a09ea6dae 
*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 b378a2d..04f61cb 100644
--- a/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
+++ b/tests/ref/fate/concat-demuxer-extended-lavf-mxf_d10
@@ -1 +1 @@
-14c2b8d8f82f261c9627b33c481c0e8c 
*tests/data/fate/concat-demuxer-extended-lavf-mxf_d10.ffprobe
+b94a47d026a3fc1e9c28a9a6f3242b20 
*tests/data/fate/concat-demuxer-extended-lavf-mxf_d10.ffprobe
diff --git a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf 
b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
index 3fc7957..b605c26 100644
--- a/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
+++ b/tests/ref/fate/concat-demuxer-simple1-lavf-mxf
@@ -120,5 +120,5 @@ 
audio|1|65280|1.36|65280|1.36|1920|0.04|N/A|N/A|3840|206848|K|1
 Strings Metadata|8
 video|0|37|1.48|34|1.36|1|0.04|N/A|N/A|24786|211456|K|1
 Strings Metadata|8
-0|mpeg2video|4|video|1/25|[0][0][0][0]|0x|352|288|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|N/A|1|N/A|25/1|25/1|1/25|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|51|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001301
-1|pcm_s16le|unknown|audio|1/48000|[0][0][0][0]|0x|s16|48000|1|unknown|16|N/A|0/0|0/0|1/48000|0|0.00|N/A|N/A|768000|N/A|N/A|N/A|N/A|50|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001301
+0|mpeg2video|4|video|1/25|[0][0][0][0]|0x|352|288|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|N/A|1|N/A|25/1|25/1|1/25|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|51|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001301
+1|pcm_s16le|unknown|audio|1/48000|[0][0][0][0]|0x|s16|48000|1|unknown|16|N/A|0/0|0/0|1/48000|0|0.00|N/A|N/A|768000|N/A|N/A|N/A|N/A|50|0|0|0|0|0|0|0|0|0|0|0|0|0x060A2B340101010501010D001301
diff --git a/tests/ref/fate/concat-demuxer-s

[FFmpeg-devel] [PATCH 2/3] lavf/mov: improve `tref/chap` chapter handling

2016-09-09 Thread Rodger Combs
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.
---
 libavformat/isom.h |  3 ++-
 libavformat/mov.c  | 52 +---
 2 files changed, 47 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 6e80b93..22ca809 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3574,7 +3574,18 @@ 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;
+av_free(c->chapter_tracks);
+
+num = atom.size / 4;
+if (!(c->chapter_tracks = av_malloc(num * 4)))
+return AVERROR(ENOMEM);
+
+c->nb_chapter_tracks = num;
+
+for (i = 0; i < num; i++)
+c->chapter_tracks[i] = avio_rb32(pb);
+
 return 0;
 }
 
@@ -4637,25 +4648,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->codec->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->codec->codec_type = AVMEDIA_TYPE_DATA;
+st->codec->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;
@@ -4704,8 +4740,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,
@@ -5028,7 +5066,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")) {
-- 
2.10.0

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


[FFmpeg-devel] [PATCH] lavf/matroska: expose stream encoding as global side-data

2016-09-09 Thread Rodger Combs
Some demuxers can't handle Matroska compression, so this lets API users
check if a file uses it and determine whether those players will fail.
---
 libavcodec/avcodec.h  | 35 ++-
 libavcodec/avpacket.c |  1 +
 libavcodec/version.h  |  4 ++--
 libavformat/matroskadec.c | 23 +--
 4 files changed, 54 insertions(+), 9 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 01f9b29..0ecc6b4 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -1330,6 +1330,34 @@ typedef struct AVCPBProperties {
 uint64_t vbv_delay;
 } AVCPBProperties;
 
+/**
+ * This structure describes the Matroska encoding (compression or encryption) 
applied to
+ * a stream. It can be useful when determining whether or not other demuxers 
can handle
+ * a file, since some players don't support header compression.
+ */
+typedef struct AVMatroskaEncoding {
+/**
+ * Type of content encoding. 0 for compression; 1 for encryption.
+ */
+uint64_t type;
+/**
+ * Algorithm used for the compression or encryption.
+ * For compression:
+ * 0 - zlib,
+ * 1 - bzlib,
+ * 2 - lzo1x
+ * 3 - Header Stripping
+ * For encryption:
+ * 0 - Signing only
+ * 1 - DES
+ * 2 - 3DES
+ * 3 - Twofish
+ * 4 - Blowfish
+ * 5 - AES
+ */
+uint64_t algorithm;
+} AVMatroskaEncoding;
+
 #if FF_API_QSCALE_TYPE
 #define FF_QSCALE_TYPE_MPEG1 0
 #define FF_QSCALE_TYPE_MPEG2 1
@@ -1525,7 +1553,12 @@ enum AVPacketSideDataType {
  * should be associated with a video stream and containts data in the form
  * of the AVMasteringDisplayMetadata struct.
  */
-AV_PKT_DATA_MASTERING_DISPLAY_METADATA
+AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
+
+/**
+ * Corresponds to the AVMatroskaEncoding struct.
+ */
+AV_PKT_DATA_MATROSKA_ENCODING,
 };
 
 #define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index fa2844d..220e305 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -367,6 +367,7 @@ const char *av_packet_side_data_name(enum 
AVPacketSideDataType type)
 case AV_PKT_DATA_METADATA_UPDATE:return "Metadata Update";
 case AV_PKT_DATA_MPEGTS_STREAM_ID:   return "MPEGTS Stream ID";
 case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: return "Mastering display 
metadata";
+case AV_PKT_DATA_MATROSKA_ENCODING:  return "Matroska Encoding";
 }
 return NULL;
 }
diff --git a/libavcodec/version.h b/libavcodec/version.h
index f5dd118..ecd48c5 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -28,8 +28,8 @@
 #include "libavutil/version.h"
 
 #define LIBAVCODEC_VERSION_MAJOR  57
-#define LIBAVCODEC_VERSION_MINOR  55
-#define LIBAVCODEC_VERSION_MICRO 101
+#define LIBAVCODEC_VERSION_MINOR  56
+#define LIBAVCODEC_VERSION_MICRO 100
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 77b8a5d..9bae9c8 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1919,6 +1919,10 @@ static int matroska_parse_tracks(AVFormatContext *s)
 if (!track->codec_id)
 continue;
 
+st = track->stream = avformat_new_stream(s, NULL);
+if (!st)
+return AVERROR(ENOMEM);
+
 if (track->audio.samplerate < 0 || track->audio.samplerate > INT_MAX ||
 isnan(track->audio.samplerate)) {
 av_log(matroska->ctx, AV_LOG_WARNING,
@@ -1944,7 +1948,16 @@ static int matroska_parse_tracks(AVFormatContext *s)
 av_log(matroska->ctx, AV_LOG_ERROR,
"Multiple combined encodings not supported");
 } else if (encodings_list->nb_elem == 1) {
+AVMatroskaEncoding *side_data = (void*)av_stream_new_side_data(st,
+ 
AV_PKT_DATA_MATROSKA_ENCODING,
+ 
sizeof(AVMatroskaEncoding));
+if (!side_data)
+return AVERROR(ENOMEM);
+
+side_data->type = encodings[0].type;
+
 if (encodings[0].type) {
+side_data->algorithm = encodings[0].encryption.algo;
 if (encodings[0].encryption.key_id.size > 0) {
 /* Save the encryption key id to be stored later as a
metadata tag. */
@@ -1972,10 +1985,12 @@ static int matroska_parse_tracks(AVFormatContext *s)
  encodings[0].compression.algo != 
MATROSKA_TRACK_ENCODING_COMP_LZO   &&
 #endif
  encodings[0].compression.algo != 
MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP) {
+side_data->algorithm = encodings[0].compression.algo;
 encodings[0].scope = 0;
 av_log(matrosk

Re: [FFmpeg-devel] [PATCH] lavf/matroska: expose stream encoding as global side-data

2016-09-09 Thread James Almer
On 9/10/2016 12:39 AM, Rodger Combs wrote:
> Some demuxers can't handle Matroska compression, so this lets API users
> check if a file uses it and determine whether those players will fail.
> ---
>  libavcodec/avcodec.h  | 35 ++-
>  libavcodec/avpacket.c |  1 +
>  libavcodec/version.h  |  4 ++--
>  libavformat/matroskadec.c | 23 +--
>  4 files changed, 54 insertions(+), 9 deletions(-)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 01f9b29..0ecc6b4 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -1330,6 +1330,34 @@ typedef struct AVCPBProperties {
>  uint64_t vbv_delay;
>  } AVCPBProperties;
>  
> +/**
> + * This structure describes the Matroska encoding (compression or 
> encryption) applied to
> + * a stream. It can be useful when determining whether or not other demuxers 
> can handle
> + * a file, since some players don't support header compression.
> + */
> +typedef struct AVMatroskaEncoding {
> +/**
> + * Type of content encoding. 0 for compression; 1 for encryption.
> + */
> +uint64_t type;

If it's a boolean value then just use int/unsigned.

> +/**
> + * Algorithm used for the compression or encryption.
> + * For compression:
> + * 0 - zlib,
> + * 1 - bzlib,
> + * 2 - lzo1x
> + * 3 - Header Stripping
> + * For encryption:
> + * 0 - Signing only
> + * 1 - DES
> + * 2 - 3DES
> + * 3 - Twofish
> + * 4 - Blowfish
> + * 5 - AES
> + */
> +uint64_t algorithm;

Enum? Otherwise int/unsigned and ideally #defines.

> +} AVMatroskaEncoding;
> +
>  #if FF_API_QSCALE_TYPE
>  #define FF_QSCALE_TYPE_MPEG1 0
>  #define FF_QSCALE_TYPE_MPEG2 1
> @@ -1525,7 +1553,12 @@ enum AVPacketSideDataType {
>   * should be associated with a video stream and containts data in the 
> form
>   * of the AVMasteringDisplayMetadata struct.
>   */
> -AV_PKT_DATA_MASTERING_DISPLAY_METADATA
> +AV_PKT_DATA_MASTERING_DISPLAY_METADATA,
> +
> +/**
> + * Corresponds to the AVMatroskaEncoding struct.
> + */
> +AV_PKT_DATA_MATROSKA_ENCODING,
>  };
>  
>  #define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED
> diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
> index fa2844d..220e305 100644
> --- a/libavcodec/avpacket.c
> +++ b/libavcodec/avpacket.c
> @@ -367,6 +367,7 @@ const char *av_packet_side_data_name(enum 
> AVPacketSideDataType type)
>  case AV_PKT_DATA_METADATA_UPDATE:return "Metadata Update";
>  case AV_PKT_DATA_MPEGTS_STREAM_ID:   return "MPEGTS Stream ID";
>  case AV_PKT_DATA_MASTERING_DISPLAY_METADATA: return "Mastering display 
> metadata";
> +case AV_PKT_DATA_MATROSKA_ENCODING:  return "Matroska Encoding";
>  }
>  return NULL;
>  }
> diff --git a/libavcodec/version.h b/libavcodec/version.h
> index f5dd118..ecd48c5 100644
> --- a/libavcodec/version.h
> +++ b/libavcodec/version.h
> @@ -28,8 +28,8 @@
>  #include "libavutil/version.h"
>  
>  #define LIBAVCODEC_VERSION_MAJOR  57
> -#define LIBAVCODEC_VERSION_MINOR  55
> -#define LIBAVCODEC_VERSION_MICRO 101
> +#define LIBAVCODEC_VERSION_MINOR  56
> +#define LIBAVCODEC_VERSION_MICRO 100
>  
>  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
> LIBAVCODEC_VERSION_MINOR, \
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 77b8a5d..9bae9c8 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -1919,6 +1919,10 @@ static int matroska_parse_tracks(AVFormatContext *s)
>  if (!track->codec_id)
>  continue;
>  
> +st = track->stream = avformat_new_stream(s, NULL);
> +if (!st)
> +return AVERROR(ENOMEM);
> +
>  if (track->audio.samplerate < 0 || track->audio.samplerate > INT_MAX 
> ||
>  isnan(track->audio.samplerate)) {
>  av_log(matroska->ctx, AV_LOG_WARNING,
> @@ -1944,7 +1948,16 @@ static int matroska_parse_tracks(AVFormatContext *s)
>  av_log(matroska->ctx, AV_LOG_ERROR,
> "Multiple combined encodings not supported");
>  } else if (encodings_list->nb_elem == 1) {
> +AVMatroskaEncoding *side_data = 
> (void*)av_stream_new_side_data(st,
> + 
> AV_PKT_DATA_MATROSKA_ENCODING,
> + 
> sizeof(AVMatroskaEncoding));
> +if (!side_data)
> +return AVERROR(ENOMEM);
> +
> +side_data->type = encodings[0].type;
> +
>  if (encodings[0].type) {
> +side_data->algorithm = encodings[0].encryption.algo;
>  if (encodings[0].encryption.key_id.size > 0) {
>  /* Save the encryption key id to be stored later as a
> metadata tag. */
>

[FFmpeg-devel] [PATCH 03/11] lavf/segment: add deinit function

2016-09-09 Thread Rodger Combs
---
 libavformat/segment.c | 47 ---
 1 file changed, 20 insertions(+), 27 deletions(-)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index 33a5cf0..139761f 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(s->filename);
 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_write_trailer,
+.deinit = seg_free,
 .priv_class = &sseg_class,
 };
-- 
2.10.0

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


[FFmpeg-devel] [PATCH 01/11] lavf: add a flag to enable/disable automatic bitstream filtering

2016-09-09 Thread Rodger Combs
This is mostly useful for muxers that wrap other muxers, such as dashenc
and segment. The actual duplicated bitstream filtering is largely harmless,
but delaying the header can cause problems when the muxer intended the header
to be written to a separate file.
---
 libavformat/avformat.h  | 1 +
 libavformat/mux.c   | 5 -
 libavformat/options_table.h | 3 ++-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 3ee7051..585f00b 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -1448,6 +1448,7 @@ typedef struct AVFormatContext {
 #define AVFMT_FLAG_PRIV_OPT0x2 ///< Enable use of private options by 
delaying codec open (this could be made default once all code is converted)
 #define AVFMT_FLAG_KEEP_SIDE_DATA 0x4 ///< Don't merge side data but keep 
it separate.
 #define AVFMT_FLAG_FAST_SEEK   0x8 ///< Enable fast, but inaccurate seeks 
for some formats
+#define AVFMT_FLAG_AUTO_BSF0x10 ///< Wait for packet data before 
writing a header, and add bitstream filters as requested by the muxer
 
 /**
  * Maximum size of the data read from input for determining
diff --git a/libavformat/mux.c b/libavformat/mux.c
index a427f46..10d2ba3 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -500,7 +500,7 @@ int avformat_write_header(AVFormatContext *s, AVDictionary 
**options)
 if ((ret = init_muxer(s, options)) < 0)
 return ret;
 
-if (!s->oformat->check_bitstream) {
+if (!(s->oformat->check_bitstream && s->flags & AVFMT_FLAG_AUTO_BSF)) {
 ret = write_header_internal(s);
 if (ret < 0)
 goto fail;
@@ -830,6 +830,9 @@ static int do_packet_auto_bsf(AVFormatContext *s, AVPacket 
*pkt) {
 AVStream *st = s->streams[pkt->stream_index];
 int i, ret;
 
+if (!(s->flags & AVFMT_FLAG_AUTO_BSF))
+return 1;
+
 if (s->oformat->check_bitstream) {
 if (!st->internal->bitstream_checked) {
 if ((ret = s->oformat->check_bitstream(s, pkt)) < 0)
diff --git a/libavformat/options_table.h b/libavformat/options_table.h
index 3b74d1b..227c379 100644
--- a/libavformat/options_table.h
+++ b/libavformat/options_table.h
@@ -39,7 +39,7 @@ static const AVOption avformat_options[] = {
 {"probesize", "set probing size", OFFSET(probesize), AV_OPT_TYPE_INT64, {.i64 
= 500 }, 32, INT64_MAX, D},
 {"formatprobesize", "number of bytes to probe file format", 
OFFSET(format_probesize), AV_OPT_TYPE_INT, {.i64 = PROBE_BUF_MAX}, 0, 
INT_MAX-1, D},
 {"packetsize", "set packet size", OFFSET(packet_size), AV_OPT_TYPE_INT, {.i64 
= DEFAULT }, 0, INT_MAX, E},
-{"fflags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 
AVFMT_FLAG_FLUSH_PACKETS }, INT_MIN, INT_MAX, D|E, "fflags"},
+{"fflags", NULL, OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 
AVFMT_FLAG_FLUSH_PACKETS | AVFMT_FLAG_AUTO_BSF }, INT_MIN, INT_MAX, D|E, 
"fflags"},
 {"flush_packets", "reduce the latency by flushing out packets immediately", 0, 
AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_FLUSH_PACKETS }, INT_MIN, INT_MAX, E, 
"fflags"},
 {"ignidx", "ignore index", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_IGNIDX }, 
INT_MIN, INT_MAX, D, "fflags"},
 {"genpts", "generate pts", 0, AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_GENPTS }, 
INT_MIN, INT_MAX, D, "fflags"},
@@ -54,6 +54,7 @@ static const AVOption avformat_options[] = {
 {"nobuffer", "reduce the latency introduced by optional buffering", 0, 
AV_OPT_TYPE_CONST, {.i64 = AVFMT_FLAG_NOBUFFER }, 0, INT_MAX, D, "fflags"},
 {"seek2any", "allow seeking to non-keyframes on demuxer level when supported", 
OFFSET(seek2any), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, D},
 {"bitexact", "do not write random/volatile data", 0, AV_OPT_TYPE_CONST, { .i64 
= AVFMT_FLAG_BITEXACT }, 0, 0, E, "fflags" },
+{"autobsf", "add needed bsfs automatically (delays header until each stream's 
first packet is written)", 0, AV_OPT_TYPE_CONST, { .i64 = AVFMT_FLAG_AUTO_BSF 
}, 0, 0, E, "fflags" },
 {"analyzeduration", "specify how many microseconds are analyzed to probe the 
input", OFFSET(max_analyze_duration), AV_OPT_TYPE_INT64, {.i64 = 0 }, 0, 
INT64_MAX, D},
 {"cryptokey", "decryption key", OFFSET(key), AV_OPT_TYPE_BINARY, {.dbl = 0}, 
0, 0, D},
 {"indexmem", "max memory used for timestamp index (per stream)", 
OFFSET(max_index_size), AV_OPT_TYPE_INT, {.i64 = 1<<20 }, 0, INT_MAX, D},
-- 
2.10.0

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


[FFmpeg-devel] [PATCH 06/11] lavf/dashenc: add deinit function

2016-09-09 Thread Rodger Combs
---
 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,
 };
-- 
2.10.0

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


[FFmpeg-devel] [PATCH 05/11] lavf/movenc: add deinit function

2016-09-09 Thread Rodger Combs
---
 libavformat/movenc.c | 76 ++--
 1 file changed, 32 insertions(+), 44 deletions(-)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 319ff57..1fe1eb6 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5567,21 +5567,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);
 }
 }
 
@@ -5601,8 +5598,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. */
@@ -5616,8 +5612,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;
 }
@@ -5630,8 +5625,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,
@@ -5659,8 +5653,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) {
@@ -5673,8 +5666,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 */
@@ -5691,8 +5683,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);
@@ -5722,8 +5713,7 @@ static int mov_write_header(AVFormatContext *s)
 track->vos_len  = st->codecpar->extradata_size;
 track->vos_data = av_malloc(track->vos_len);
 if (!track->vos_data) {
-ret = AVERROR(ENOMEM);
-goto error;
+

[FFmpeg-devel] [PATCH 04/11] lavf/segment: fix writing separate header with auto BSF

2016-09-09 Thread Rodger Combs
---
 libavformat/segment.c | 29 -
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index 139761f..7e56f82 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,
-- 
2.10.0

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


[FFmpeg-devel] [PATCH 02/11] lavf/mux: add avformat_init_output

2016-09-09 Thread Rodger Combs
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.
---
 libavformat/avformat.h | 34 +++--
 libavformat/internal.h | 10 
 libavformat/mux.c  | 68 +++---
 libavformat/version.h  |  4 +--
 4 files changed, 98 insertions(+), 18 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 585f00b..7ac9127 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 *);
@@ -2370,6 +2372,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.
@@ -2381,14 +2387,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 f9278c5..71bcf22 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -125,6 +125,16 @@ struct AVFormatInternal {
  */
 int header_written;
 int write_header_ret;
+
+/**
+ * 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 10d2ba3..a8baee4e 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -423,10 +423,13 @@ FF_ENABLE_DEPRECATION_WARNINGS
  *options = tmp;
 }
 
-if (s->oformat->init && (ret = s->oformat->init(s)) < 0) {
-if (s->oformat->deinit)
-s->oformat->deinit(s);
-goto fail;
+if (s->oformat->init) {
+if ((ret = s->oformat->init(s)) < 0) {
+if (s->oformat->deinit)
+s->oformat->deinit(s);
+return ret;
+}
+return ret == 0;
 }
 
 return 0;
@@ -493,31 +496,64 @@ static int write_header_internal(AVFormatContext *s)
 return 0;
 }
 
-int avformat_write_header(AVFormatContext *s, AVDictionary **options)
+int avformat_init_output(AVFormatContext *s, AVDictionary **options)
 {
 int ret = 0;
 
 i

[FFmpeg-devel] [PATCH 07/11] lavf/movenc+dashenc: add automatic bitstream filtering

2016-09-09 Thread Rodger Combs
This is disabled by default when the empty_moov flag is enabled
---
 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 1fe1eb6..93f52f2 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -5415,11 +5415,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;
@@ -5456,6 +5455,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;
 }
@@ -5502,11 +5506,6 @@ static int mov_write_header(AVFormatContext *s)
 return AVERROR(EINVAL);
 }
 
-if (!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) {
-if ((ret = mov_write_identification(pb, s)) < 0)
-return ret;
-}
-
 mov->nb_streams = s->nb_streams;
 if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters)
 mov->chapter_track = mov->nb_streams++;
@@ -5529,7 +5528,7 @@ static int mov_write_header(AVFormatContext *s)
 /* +1 tmc

[FFmpeg-devel] [PATCH 08/11] lavf/rawenc: add automatic bitstream filtering for H264+HEVC

2016-09-09 Thread Rodger Combs
---
 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
-- 
2.10.0

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


[FFmpeg-devel] [PATCH 09/11] fate/h264: make mp4toannexb test use auto-BSF

2016-09-09 Thread Rodger Combs
---
 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
-- 
2.10.0

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


[FFmpeg-devel] [PATCH 10/11] fate/aac: add automatic bsf test

2016-09-09 Thread Rodger Combs
---
 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..b02b768 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 = b25ed78285f5c9004e2b027b347d33b7
+
 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)
-- 
2.10.0

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


[FFmpeg-devel] [PATCH 11/11] fate/hevc: add automatic bsf test

2016-09-09 Thread Rodger Combs
---
 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)
-- 
2.10.0

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


[FFmpeg-devel] [PATCH 1/2] ass_split: fix handling of streams with no [Events] or Format: line

2016-09-09 Thread Rodger Combs
---
 libavcodec/ass_split.c | 36 +++-
 1 file changed, 27 insertions(+), 9 deletions(-)

diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c
index beaba7e..cdb1aa2 100644
--- a/libavcodec/ass_split.c
+++ b/libavcodec/ass_split.c
@@ -229,7 +229,7 @@ static inline const char *skip_space(const char *buf)
 return buf;
 }
 
-static int *get_default_field_orders(const ASSSection *section)
+static int *get_default_field_orders(const ASSSection *section, int *number)
 {
 int i;
 int *order = av_malloc_array(FF_ARRAY_ELEMS(section->fields), 
sizeof(*order));
@@ -238,8 +238,9 @@ static int *get_default_field_orders(const ASSSection 
*section)
 return NULL;
 for (i = 0; section->fields[i].name; i++)
 order[i] = i;
+*number = i;
 while (i < FF_ARRAY_ELEMS(section->fields))
-order[i] = -1;
+order[i++] = -1;
 return order;
 }
 
@@ -255,12 +256,26 @@ static const char *ass_split_section(ASSSplitContext 
*ctx, const char *buf)
 ctx->current_section = -1;
 break;
 }
-if (buf[0] == ';' || (buf[0] == '!' && buf[1] == ':')) {
-/* skip comments */
-} else if (section->format_header && !order) {
+if (buf[0] == ';' || (buf[0] == '!' && buf[1] == ':'))
+goto next_line; // skip comments
+
+len = strcspn(buf, ":\r\n");
+if (buf[len] == ':' &&
+(!section->fields_header || strncmp(buf, section->fields_header, 
len))) {
+for (i = 0; i < FF_ARRAY_ELEMS(ass_sections); i++) {
+if (ass_sections[i].fields_header &&
+!strncmp(buf, ass_sections[i].fields_header, len)) {
+ctx->current_section = i;
+section = &ass_sections[ctx->current_section];
+number = &ctx->field_number[ctx->current_section];
+order = ctx->field_order[ctx->current_section];
+break;
+}
+}
+}
+if (section->format_header && !order) {
 len = strlen(section->format_header);
-if (strncmp(buf, section->format_header, len) || buf[len] != ':')
-goto next_line;
+if (buf[len] == ':' && !strncmp(buf, section->format_header, len)) 
{
 buf += len + 1;
 while (!is_eol(*buf)) {
 buf = skip_space(buf);
@@ -278,7 +293,10 @@ static const char *ass_split_section(ASSSplitContext *ctx, 
const char *buf)
 buf = skip_space(buf + len + (buf[len] == ','));
 }
 ctx->field_order[ctx->current_section] = order;
-} else if (section->fields_header) {
+goto next_line;
+}
+}
+if (section->fields_header) {
 len = strlen(section->fields_header);
 if (!strncmp(buf, section->fields_header, len) && buf[len] == ':') 
{
 uint8_t *ptr, *struct_ptr = realloc_section_array(ctx);
@@ -286,7 +304,7 @@ static const char *ass_split_section(ASSSplitContext *ctx, 
const char *buf)
 
 /* No format header line found so far, assume default */
 if (!order) {
-order = get_default_field_orders(section);
+order = get_default_field_orders(section, number);
 if (!order)
 return NULL;
 ctx->field_order[ctx->current_section] = order;
-- 
2.10.0

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


[FFmpeg-devel] [PATCH 2/2] ass_split: reindent

2016-09-09 Thread Rodger Combs
---
 libavcodec/ass_split.c | 34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/libavcodec/ass_split.c b/libavcodec/ass_split.c
index cdb1aa2..d3e8a8d 100644
--- a/libavcodec/ass_split.c
+++ b/libavcodec/ass_split.c
@@ -276,23 +276,23 @@ static const char *ass_split_section(ASSSplitContext 
*ctx, const char *buf)
 if (section->format_header && !order) {
 len = strlen(section->format_header);
 if (buf[len] == ':' && !strncmp(buf, section->format_header, len)) 
{
-buf += len + 1;
-while (!is_eol(*buf)) {
-buf = skip_space(buf);
-len = strcspn(buf, ", \r\n");
-if (!(tmp = av_realloc_array(order, (*number + 1), 
sizeof(*order
-return NULL;
-order = tmp;
-order[*number] = -1;
-for (i=0; section->fields[i].name; i++)
-if (!strncmp(buf, section->fields[i].name, len)) {
-order[*number] = i;
-break;
-}
-(*number)++;
-buf = skip_space(buf + len + (buf[len] == ','));
-}
-ctx->field_order[ctx->current_section] = order;
+buf += len + 1;
+while (!is_eol(*buf)) {
+buf = skip_space(buf);
+len = strcspn(buf, ", \r\n");
+if (!(tmp = av_realloc_array(order, (*number + 1), 
sizeof(*order
+return NULL;
+order = tmp;
+order[*number] = -1;
+for (i=0; section->fields[i].name; i++)
+if (!strncmp(buf, section->fields[i].name, len)) {
+order[*number] = i;
+break;
+}
+(*number)++;
+buf = skip_space(buf + len + (buf[len] == ','));
+}
+ctx->field_order[ctx->current_section] = order;
 goto next_line;
 }
 }
-- 
2.10.0

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


Re: [FFmpeg-devel] [PATCH] avformat/segment: fix the duration error of use output_ts_offset

2016-09-09 Thread Aman Gupta
I confirmed your latest patch fixes the issue and is working as expected
now.

Thank you!

Aman

On Sat, Sep 10, 2016 at 7:00 AM, Steven Liu  wrote:

>
> Steven Liu 于2016年9月9日 周五下午7:59写道:
>
>> 2016-09-09 16:33 GMT+08:00 Steven Liu :
>>
>>>
>>>
>>> 2016-09-09 16:10 GMT+08:00 Steven Liu :
>>>


 2016-09-09 15:33 GMT+08:00 Steven Liu :

>
>
> 2016-09-09 15:28 GMT+08:00 Aman Gupta :
>
>> I tried your patch and TARGETDURATION is fixed, but it is still
>> creating some segments which are only 0.2s instead of 2s.
>>
>> Aman
>>
>> On Thu, Sep 8, 2016 at 8:14 PM, Steven Liu 
>> wrote:
>>
>>> This patch can merge with 1da00be009aa74400042bf470b9a5ffbd82a1c5e
>>> i have checked this modify:
>>>
>>> ./ffmpeg -i ~/facebook.mp4 -c copy -f segment -segment_time 2
>>> -output_ts_offset 80 -segment_list output-test.m3u8 -v debug
>>> output-test-%03d.ts
>>>
>>> #EXTM3U
>>> #EXT-X-VERSION:3
>>> #EXT-X-MEDIA-SEQUENCE:0
>>> #EXT-X-ALLOW-CACHE:YES
>>> #EXT-X-TARGETDURATION:10
>>> #EXTINF:4.12,
>>> output-test-000.ts
>>> #EXTINF:7.84,
>>> output-test-001.ts
>>> #EXTINF:4.20,
>>> output-test-002.ts
>>> #EXTINF:2.92,
>>> output-test-003.ts
>>> #EXTINF:1.84,
>>> output-test-004.ts
>>> #EXTINF:2.24,
>>> output-test-005.ts
>>> #EXTINF:2.00,
>>> output-test-006.ts
>>> #EXTINF:3.56,
>>>
>>>
>>> [root@localhost linux]# ffmpeg -i output-test.m3u8
>>> ffmpeg version N-80917-ga1a240b Copyright (c) 2000-2016 the FFmpeg
>>> developers
>>>   built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
>>>   configuration: --prefix=/usr/ --libdir=/usr/lib64 --enable-libx264
>>> --enable-libfaac --enable-gpl --enable-nonfree
>>>   libavutil  55. 28.100 / 55. 28.100
>>>   libavcodec 57. 48.102 / 57. 48.102
>>>   libavformat57. 41.100 / 57. 41.100
>>>   libavdevice57.  0.102 / 57.  0.102
>>>   libavfilter 6. 47.100 /  6. 47.100
>>>   libswscale  4.  1.100 /  4.  1.100
>>>   libswresample   2.  1.100 /  2.  1.100
>>>   libpostproc54.  0.100 / 54.  0.100
>>> Input #0, hls,applehttp, from 'output-test.m3u8':
>>>   Duration: 00:03:21.04, start: 81.40, bitrate: 0 kb/s
>>>   Program 0
>>> Metadata:
>>>   variant_bitrate : 0
>>> Stream #0:0: Video: h264 (High) ([27][0][0][0] / 0x001B),
>>> yuv420p, 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
>>> Stream #0:1: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz,
>>> 5.1(side), fltp, 384 kb/s
>>> At least one output file must be specified
>>>
>>>
>>>
>>> [root@localhost linux]# ffmpeg -i output-test-000.ts -i
>>> output-test-001.ts
>>> ffmpeg version N-80917-ga1a240b Copyright (c) 2000-2016 the FFmpeg
>>> developers
>>>   built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
>>>   configuration: --prefix=/usr/ --libdir=/usr/lib64 --enable-libx264
>>> --enable-libfaac --enable-gpl --enable-nonfree
>>>   libavutil  55. 28.100 / 55. 28.100
>>>   libavcodec 57. 48.102 / 57. 48.102
>>>   libavformat57. 41.100 / 57. 41.100
>>>   libavdevice57.  0.102 / 57.  0.102
>>>   libavfilter 6. 47.100 /  6. 47.100
>>>   libswscale  4.  1.100 /  4.  1.100
>>>   libswresample   2.  1.100 /  2.  1.100
>>>   libpostproc54.  0.100 / 54.  0.100
>>> Input #0, mpegts, from 'output-test-000.ts':
>>>   Duration: 00:00:04.12, start: 81.40, bitrate: 1299 kb/s
>>>   Program 1
>>> Metadata:
>>>   service_name: Service01
>>>   service_provider: FFmpeg
>>> Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
>>> yuv420p, 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
>>> Stream #0:1[0x101](und): Audio: ac3 ([129][0][0][0] / 0x0081),
>>> 48000 Hz, 5.1(side), fltp, 384 kb/s
>>> Input #1, mpegts, from 'output-test-001.ts':
>>>   Duration: 00:00:07.90, start: 85.464000, bitrate: 1679 kb/s
>>>   Program 1
>>> Metadata:
>>>   service_name: Service01
>>>   service_provider: FFmpeg
>>> Stream #1:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B),
>>> yuv420p, 720x528 [SAR 1:1 DAR 15:11], 25 fps, 25 tbr, 90k tbn, 50 tbc
>>> Stream #1:1[0x101](und): Audio: ac3 ([129][0][0][0] / 0x0081),
>>> 48000 Hz, 5.1(side), fltp, 384 kb/s
>>> At least one output file must be specified
>>> [root@localhost linux]#
>>>
>>>
>>>
>>>
>>> this commit is used for fix commit 1da00be009aa74400042bf470b9a5f
>>> fbd82a1c5e
>>> because the option initial_offset will deprecated
>>>
>>> Signed-off-by: Steven Liu 
>>> ---
>>>  libavformat/segment.c |5 +
>>>  1 files changed, 5 insertions(+), 0 deletion

[FFmpeg-devel] [PATCH] lavf/hlsenc: add -hls_start_time to emit EXT-X-START:TIME-OFFSET

2016-09-09 Thread Aman Gupta
From: Aman Gupta 

---
 doc/muxers.texi  | 3 +++
 libavformat/hlsenc.c | 5 +
 2 files changed, 8 insertions(+)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index ccf8ea1..e179c5a 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -533,6 +533,9 @@ Emit @code{#EXT-X-PLAYLIST-TYPE:EVENT} in the m3u8 header. 
Forces
 Emit @code{#EXT-X-PLAYLIST-TYPE:VOD} in the m3u8 header. Forces
 @option{hls_list_size} to 0; the playlist must not change.
 
+@item hls_start_time @var{offset}
+Emit @code{#EXT-X-START:TIME-OFFSET} in the m3u8 header.
+
 @item method
 Use the given HTTP method to create the hls files.
 @example
diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index a376312..1344613d 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -79,6 +79,7 @@ typedef struct HLSContext {
 unsigned number;
 int64_t sequence;
 int64_t start_sequence;
+float start_offset;
 AVOutputFormat *oformat;
 AVOutputFormat *vtt_oformat;
 
@@ -511,6 +512,9 @@ static int hls_window(AVFormatContext *s, int last)
 } else if (hls->pl_type == PLAYLIST_TYPE_VOD) {
 avio_printf(out, "#EXT-X-PLAYLIST-TYPE:VOD\n");
 }
+if (hls->start_offset >= 0) {
+avio_printf(out, "#EXT-X-START:TIME-OFFSET=%f\n", hls->start_offset);
+}
 
 av_log(s, AV_LOG_VERBOSE, "EXT-X-MEDIA-SEQUENCE:%"PRId64"\n",
sequence);
@@ -1013,6 +1017,7 @@ static const AVOption options[] = {
 {"hls_list_size", "set maximum number of playlist entries",  
OFFSET(max_nb_segments),AV_OPT_TYPE_INT,{.i64 = 5}, 0, INT_MAX, E},
 {"hls_ts_options","set hls mpegts list of options for the container format 
used for hls", OFFSET(format_options_str), AV_OPT_TYPE_STRING, {.str = NULL},  
0, 0,E},
 {"hls_vtt_options","set hls vtt list of options for the container format 
used for hls", OFFSET(vtt_format_options_str), AV_OPT_TYPE_STRING, {.str = 
NULL},  0, 0,E},
+{"hls_start_time", "set EXT-X-START:TIME-OFFSET",   
OFFSET(start_offset),AV_OPT_TYPE_FLOAT,  {.dbl = -1}, -1, FLT_MAX, E},
 {"hls_wrap",  "set number after which the index wraps",  OFFSET(wrap), 
   AV_OPT_TYPE_INT,{.i64 = 0}, 0, INT_MAX, E},
 {"hls_allow_cache", "explicitly set whether the client MAY (1) or MUST NOT 
(0) cache media segments", OFFSET(allowcache), AV_OPT_TYPE_INT, {.i64 = -1}, 
INT_MIN, INT_MAX, E},
 {"hls_base_url",  "url to prepend to each playlist entry",   
OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL},  0, 0,   E},
-- 
2.8.1

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


Re: [FFmpeg-devel] [PATCH] avcodec/aaccoder: Limit sf_idx difference for all cases

2016-09-09 Thread Claudio Freire
On Thu, Aug 25, 2016 at 8:57 AM, Rostislav Pehlivanov
 wrote:
>> 64ed96a710787ba5d0666746a8562e7d.dee
>>
>> Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
>> Signed-off-by: Michael Niedermayer 
>> ---
>>  libavcodec/aaccoder.c | 8 +++-
>>  1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
>> index 284b401..995724b 100644
>> --- a/libavcodec/aaccoder.c
>> +++ b/libavcodec/aaccoder.c
>> @@ -196,7 +196,7 @@ typedef struct TrellisPath {
>>  static void set_special_band_scalefactors(AACEncContext *s,
>> SingleChannelElement *sce)
>>  {
>>  int w, g;
>> -int prevscaler_n = -255, prevscaler_i = 0;
>> +int prevscaler_n = -255, prevscaler_i = 0, prevscaler_d = -255;
>>  int bands = 0;
>>
>>  for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
>> @@ -211,6 +211,10 @@ static void set_special_band_scalefactors(AACEncContext
>> *s, SingleChannelElement
>>  if (prevscaler_n == -255)
>>  prevscaler_n = sce->sf_idx[w*16+g];
>>  bands++;
>> +} else {
>> +if (prevscaler_d == -255)
>> +prevscaler_d = sce->sf_idx[w*16+g];
>> +bands++;
>>  }
>>  }
>>  }
>> @@ -227,6 +231,8 @@ static void set_special_band_scalefactors(AACEncContext
>> *s, SingleChannelElement
>>  sce->sf_idx[w*16+g] = prevscaler_i =
>> av_clip(sce->sf_idx[w*16+g], prevscaler_i - SCALE_MAX_DIFF, prevscaler_i +
>> SCALE_MAX_DIFF);
>>  } else if (sce->band_type[w*16+g] == NOISE_BT) {
>>  sce->sf_idx[w*16+g] = prevscaler_n =
>> av_clip(sce->sf_idx[w*16+g], prevscaler_n - SCALE_MAX_DIFF, prevscaler_n +
>> SCALE_MAX_DIFF);
>> +} else {
>> +sce->sf_idx[w*16+g] = prevscaler_d =
>> av_clip(sce->sf_idx[w*16+g], prevscaler_d - SCALE_MAX_DIFF, prevscaler_d +
>> SCALE_MAX_DIFF);
>>  }
>>  }
>>  }
>> --
>> 2.9.3
>>
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>
>
> That fuzzed sample seems to be causing the algorithm which does SF
> difference normalization between normal and PNS bands to fail. This commit
> masks the problem downstream. IMO that's not the correct way to solve this,
> as there's no guarantee that another sample won't trigger the same assert
> even when limiting all scalefactors. Fixing a single fuzzed sample with a
> hack which doesn't stop other fuzzed samples from triggering the same bug
> isn't justified.
> I have the time right now and I'll try to fix this properly, but it might
> take me a day or two. I think the problem is that when the twoloop coder
> does the the normalization it doesn't take into account the fact that IS
> and PNS have their scalefactors modified by set_special_band_scalefactors()
> later on before encoding.

It seems the root of the issue is that the two stages of PNS don't
agree on when they can apply PNS or not.

I have a WIP that eliminates the issue by just making the two agree,
but I've got unrelated changes so I'll try to distill the patch to the
minimum necessary to fix this during the weekend.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel