Re: [FFmpeg-devel] [PATCH] aacenc_utils: unroll loops to allow compiler to use SIMD.

2016-03-07 Thread Reimar Döffinger
On 08.03.2016, at 04:50, Ganesh Ajjanagadde  wrote:

> On Mon, Mar 7, 2016 at 2:54 AM, Reimar Döffinger
>  wrote:
>> 
>>> Can you be more specific, and are you sure about this?
>> 
>> Just run your favourite performance analysis tool and you'll see.
>> As it is non-inlined libc code I'm fairly sure the numbers are accurate 
>> enough.
> 
> I am still puzzled by the remarks; and hence asked for specific
> examples. In aac code, cosf is only called for table generation, same
> with cos, so still don't see why cos is relevant.

Well I can see it using 5% of CPU but that's it for now. Someone will need to 
e.g. use a debugger or use profiling with call stack if it's not clear where it 
comes from.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] Add tests for functions in hash.c

2016-03-07 Thread NagaChaitanya Vellanki
---
 libavutil/Makefile   |  1 +
 libavutil/hash.c | 42 ++
 tests/fate/libavutil.mak |  4 
 tests/ref/fate/hash  | 45 +
 4 files changed, 92 insertions(+)
 create mode 100644 tests/ref/fate/hash

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 934564f..58df75a 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -186,6 +186,7 @@ TESTPROGS = adler32 
\
 file\
 fifo\
 float_dsp   \
+hash\
 hmac\
 lfg \
 lls \
diff --git a/libavutil/hash.c b/libavutil/hash.c
index 7037b0d..e5452ba 100644
--- a/libavutil/hash.c
+++ b/libavutil/hash.c
@@ -237,3 +237,45 @@ void av_hash_freep(AVHashContext **ctx)
 av_freep(&(*ctx)->ctx);
 av_freep(ctx);
 }
+
+#ifdef TEST
+// LCOV_EXCL_START
+#define SRC_BUF_SIZE 64
+#define DST_BUF_SIZE (AV_HASH_MAX_SIZE * 8)
+
+int main(void)
+{
+   struct AVHashContext *ctx = NULL;
+   int i, j;
+   static const uint8_t src[SRC_BUF_SIZE] = { 0 };
+   uint8_t dst[DST_BUF_SIZE];
+   for (i = 0; i < NUM_HASHES; i++) {
+   if (av_hash_alloc(, av_hash_names(i)) < 0)
+   return 1;
+
+   av_hash_init(ctx);
+   av_hash_update(ctx, src, SRC_BUF_SIZE);
+   memset(dst, 0, DST_BUF_SIZE);
+   av_hash_final_hex(ctx, dst, DST_BUF_SIZE);
+   printf("%s hex: %s\n", av_hash_get_name(ctx), dst);
+
+   av_hash_init(ctx);
+   av_hash_update(ctx, src, SRC_BUF_SIZE);
+   av_hash_final_bin(ctx, dst, DST_BUF_SIZE);
+   printf("%s bin: ", av_hash_get_name(ctx));
+   for (j = 0; j < av_hash_get_size(ctx); j++) {
+   printf("%#x ", dst[j]);
+   }
+   printf("\n");
+
+   av_hash_init(ctx);
+   av_hash_update(ctx, src, SRC_BUF_SIZE);
+   av_hash_final_b64(ctx, dst, DST_BUF_SIZE);
+   printf("%s b64: %s\n", av_hash_get_name(ctx), dst);
+   av_hash_freep();
+   }
+   return 0;
+}
+
+// LCOV_EXCL_STOP
+#endif
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index a89bc1d..5d8e0e2 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -75,6 +75,10 @@ fate-float-dsp: CMD = run libavutil/float_dsp-test 
$(CPUFLAGS:%=-c%)
 fate-float-dsp: CMP = null
 fate-float-dsp: REF = /dev/null
 
+FATE_LIBAVUTIL += fate-hash
+fate-hash: libavutil/hash-test$(EXESUF)
+fate-hash: CMD = run libavutil/hash-test
+
 FATE_LIBAVUTIL += fate-hmac
 fate-hmac: libavutil/hmac-test$(EXESUF)
 fate-hmac: CMD = run libavutil/hmac-test
diff --git a/tests/ref/fate/hash b/tests/ref/fate/hash
new file mode 100644
index 000..6e5a580
--- /dev/null
+++ b/tests/ref/fate/hash
@@ -0,0 +1,45 @@
+MD5 hex: 3b5d3c7d207e37dceeedd301e35e2e58
+MD5 bin: 0x3b 0x5d 0x3c 0x7d 0x20 0x7e 0x37 0xdc 0xee 0xed 0xd3 0x1 0xe3 0x5e 
0x2e 0x58
+MD5 b64: O108fSB+N9zu7dMB414uWA==
+murmur3 hex: 6e484695e1d7b4e37d838791cc263395
+murmur3 bin: 0x6e 0x48 0x46 0x95 0xe1 0xd7 0xb4 0xe3 0x7d 0x83 0x87 0x91 0xcc 
0x26 0x33 0x95
+murmur3 b64: bkhGleHXtON9g4eRzCYzlQ==
+RIPEMD128 hex: 082bfa9b829ef3a9e220dcc54e4c6383
+RIPEMD128 bin: 0x8 0x2b 0xfa 0x9b 0x82 0x9e 0xf3 0xa9 0xe2 0x20 0xdc 0xc5 0x4e 
0x4c 0x63 0x83
+RIPEMD128 b64: CCv6m4Ke86niINzFTkxjgw==
+RIPEMD160 hex: 9b8ccc2f374ae313a914763cc9cdfb47bfe1c229
+RIPEMD160 bin: 0x9b 0x8c 0xcc 0x2f 0x37 0x4a 0xe3 0x13 0xa9 0x14 0x76 0x3c 
0xc9 0xcd 0xfb 0x47 0xbf 0xe1 0xc2 0x29
+RIPEMD160 b64: m4zMLzdK4xOpFHY8yc37R7/hwik=
+RIPEMD256 hex: 26ba693759787f275f47dd5ab16e78c2fcd763b004fd05fc554e354223d6eab5
+RIPEMD256 bin: 0x26 0xba 0x69 0x37 0x59 0x78 0x7f 0x27 0x5f 0x47 0xdd 0x5a 
0xb1 0x6e 0x78 0xc2 0xfc 0xd7 0x63 0xb0 0x4 0xfd 0x5 0xfc 0x55 0x4e 0x35 0x42 
0x23 0xd6 0xea 0xb5
+RIPEMD256 b64: JrppN1l4fydfR91asW54wvzXY7AE/QX8VU41QiPW6rU=
+RIPEMD320 hex: 
409a3111ffd3d4c8058ff5c231401c1d47210a5d22e6c90bf95d45c1c95c528463c69ce4bff3b884
+RIPEMD320 bin: 0x40 0x9a 0x31 0x11 0xff 0xd3 0xd4 0xc8 0x5 0x8f 0xf5 0xc2 0x31 
0x40 0x1c 0x1d 0x47 0x21 0xa 0x5d 0x22 0xe6 0xc9 0xb 0xf9 0x5d 0x45 0xc1 0xc9 
0x5c 0x52 0x84 0x63 0xc6 0x9c 0xe4 0xbf 0xf3 0xb8 0x84
+RIPEMD320 b64: QJoxEf/T1MgFj/XCMUAcHUchCl0i5skL+V1FwclcUoRjxpzkv/O4hA==
+SHA160 hex: c8d7d0ef0eedfa82d2ea1aa592845b9a6d4b02b7
+SHA160 bin: 0xc8 0xd7 0xd0 0xef 0xe 0xed 0xfa 0x82 0xd2 0xea 0x1a 0xa5 0x92 
0x84 0x5b 0x9a 0x6d 0x4b 0x2 0xb7
+SHA160 b64: yNfQ7w7t+oLS6hqlkoRbmm1LArc=
+SHA224 hex: 750d81a39c18d3ce27ff3e5ece30b0088f12d8fd0450fe435326294b
+SHA224 bin: 0x75 0xd 0x81 0xa3 0x9c 0x18 0xd3 0xce 0x27 0xff 0x3e 0x5e 0xce 
0x30 0xb0 0x8 0x8f 0x12 0xd8 0xfd 

Re: [FFmpeg-devel] [PATCH] lavf/avienc: New AVOption write_keyframe_palette

2016-03-07 Thread Mats Peterson

On 03/08/2016 02:59 AM, Mats Peterson wrote:

On 03/07/2016 07:48 PM, Mats Peterson wrote:

On 03/07/2016 07:43 PM, Mats Peterson wrote:

Here's a somewhat experimental patch with a new AVOption
write_keyframe_palette that allows you to write the palette to every
keyframe. It is disabled by default, but it is needed for any file that
contains palette changes.



It is needed in order to switch palette properly when seeking, that is.



It's interesting to note that Windows Media Player doesn't need xxpc
chunks at keyframes in order to seek properly in the following original
file from Sierra's King's Quest VI. I have of course no idea how they
solve that.

This original file doesn't work properly in FFplay for some reason. It
generates "stream_ptr out of bounds" messages at the locations of the
xxpc chunks.

File:
https://drive.google.com/open?id=0B3_pEBoLs0faaFY0ME92SDA1VEU

Mats



It seems it has something to do with the index, since if I copy it to a 
new file with the last part cut off (incorrect but it will play at 
least), those "stream_ptr out of bounds" messages will disappear, and 
the palette changes will occur as expected.


Mats

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


Re: [FFmpeg-devel] [PATCH 1/3] tests/gapless: add gapless aac tests

2016-03-07 Thread Michael Niedermayer
On Tue, Mar 08, 2016 at 01:49:43AM +0100, Marton Balint wrote:
> Signed-off-by: Marton Balint 
> ---
>  tests/fate-run.sh | 30 +
>  tests/fate/gapless.mak| 20 -
>  tests/ref/fate/gapless2-ipod-aac1 | 88 
> +++
>  tests/ref/fate/gapless2-ipod-aac2 | 88 
> +++
>  tests/ref/fate/gapless2-mov-aac   | 88 
> +++
>  5 files changed, 313 insertions(+), 1 deletion(-)
>  create mode 100644 tests/ref/fate/gapless2-ipod-aac1
>  create mode 100644 tests/ref/fate/gapless2-ipod-aac2
>  create mode 100644 tests/ref/fate/gapless2-mov-aac

seems not to pass here, or is there some other patch needed before?

frext-hpcanl_brcm_c
TESTh264-conformance-frext-hpcaq2lq_brcm_b
TESTh264-conformance-frext-hpcv_brcm_a
TESTh264-conformance-frext-hpcvfl_bcrm_a
--- ./tests/ref/fate/gapless2-ipod-aac1 2016-03-08 04:34:35.287260970 +0100
+++ tests/data/fate/gapless2-ipod-aac1  2016-03-08 04:54:03.275285577 +0100
@@ -52,7 +52,7 @@
 target|format_name=mov,mp4,m4a,3gp,3g2,mj2
 target|start_time=0.023991
 target|duration=29.326000
-target|size=490335
+target|size=490245
 target|[/FORMAT]
 target|1|packet|pts=1058|dts=1058|duration=1024
 target|2|packet|pts=2082|dts=2082|duration=1024
Test gapless2-ipod-aac1 failed. Look at tests/data/fate/gapless2-ipod-aac1.err 
for details.
make: *** [fate-gapless2-ipod-aac1] Error 1
TESTh264-conformance-frext-hpcvflnl_bcrm_a
TESTh264-conformance-frext-hpcvmolq_brcm_b
TESTh264-conformance-frext-hpcvnl_brcm_a
TESTh264-conformance-frext-pph10i1_panasonic_a
TESTh264-conformance-frext-pph10i2_panasonic_a
TESTh264-conformance-frext-pph10i3_panasonic_a
TESTh264-conformance-frext-pph10i4_panasonic_a
TESTh264-conformance-frext-pph10i5_panasonic_a
TESTh264-conformance-frext-pph

on x86-32:
--- ffmpeg/tests/ref/fate/gapless2-ipod-aac2   2016-03-08 04:34:35.287260970 
+0100
+++ tests/data/fate/gapless2-ipod-aac2  2016-03-08 04:59:42.407292721 +0100
@@ -52,7 +52,7 @@
 target|format_name=mov,mp4,m4a,3gp,3g2,mj2
 target|start_time=0.023991
 target|duration=2.367000
-target|size=39025
+target|size=39013
 target|[/FORMAT]
 target|1|packet|pts=1058|dts=1058|duration=1024
 target|2|packet|pts=2082|dts=2082|duration=1024
Test gapless2-ipod-aac2 failed. Look at tests/data/fate/gapless2-ipod-aac2.err 
for details.
make: *** [fate-gapless2-ipod-aac2] Error 1

--- ffmpeg/tests/ref/fate/gapless2-ipod-aac1   2016-03-08 04:34:35.287260970 
+0100
+++ tests/data/fate/gapless2-ipod-aac1  2016-03-08 04:59:45.019292777 +0100
@@ -52,7 +52,7 @@
 target|format_name=mov,mp4,m4a,3gp,3g2,mj2
 target|start_time=0.023991
 target|duration=29.326000
-target|size=490335
+target|size=490315
 target|[/FORMAT]
 target|1|packet|pts=1058|dts=1058|duration=1024
 target|2|packet|pts=2082|dts=2082|duration=1024
Test gapless2-ipod-aac1 failed. Look at tests/data/fate/gapless2-ipod-aac1.err 
for details.
make: *** [fate-gapless2-ipod-aac1] Error 1
TESTh264-conformance-caba2_sony_e
TESTh264-conformance-caba2_sva_b
TESTh264-conformance-caba3_sony_c
TESTh264-conformance-caba3_sva_b
TESTlavf-ast
--- ffmpeg/tests/ref/fate/gapless2-mov-aac 2016-03-08 04:32:34.327258422 
+0100
+++ tests/data/fate/gapless2-mov-aac2016-03-08 05:01:15.051294673 +0100
@@ -52,7 +52,7 @@
 target|format_name=mov,mp4,m4a,3gp,3g2,mj2
 target|start_time=-0.023220
 target|duration=12.024000
-target|size=106973
+target|size=106946
 target|[/FORMAT]
 target|1|packet|pts=-1024|dts=-1024|duration=1024
 target|2|packet|pts=0|dts=0|duration=1024
Test gapless2-mov-aac failed. Look at tests/data/fate/gapless2-mov-aac.err for 
details.
make: *** [fate-gapless2-mov-aac] Error 1
TESTlavf-au
TESTlavf-avi


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

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes


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


Re: [FFmpeg-devel] [PATCH] aacenc_utils: unroll loops to allow compiler to use SIMD.

2016-03-07 Thread Ganesh Ajjanagadde
On Mon, Mar 7, 2016 at 2:54 AM, Reimar Döffinger
 wrote:
> On 07.03.2016, at 04:04, Ganesh Ajjanagadde  wrote:
>> On Sun, Mar 6, 2016 at 1:43 PM, Reimar Döffinger
>>  wrote:
>>> On Sun, Mar 06, 2016 at 07:35:58PM +0100, Reimar Döffinger wrote:
 Approximately 10% faster transcode from mp3 to aac
 with default settings.
>>>
>>> Note to anyone wanting to optimize it further:
>>> There is almost 25% on the table if you can replace
>>> the pow() and cos() function uses by something more
>>> efficient.
>>
>> So I did try one thing, namely in lavc/aacenc_utils, replace powf in
>> find_form_factor by a conditional checking for 2.0f, squaring if it
>> is, powf otherwise (see lavc/aaccoder_twoloop for the calls, one is
>> with 2.0f, other without), but it yields essentially nothing.
>>
>> Likewise, an even more trivial one is line 125 of aaccoder_twoloop:
>> powf can be replaced here by sqrtf(sqrtf()), but this also yields
>> nothing.
>
> Probably those cases are already optimized by the implementation.

The first one is indeed optimized, find_form_factor is inlined so it
can use integer exponent optimizations (something gcc does). However,
I have a patch that gives ~ 7% boost by replacing powf by
expf(logf()). There are slight differences in floating point value,
but FATE still passes.

The second one is not possible for an environment to optimize, but is
of purely academic interest anyway since it is called only once.
Concretely, this saves ~ 300 cycles out of an ~ 700,000 cycle function
search_for_quantizers_twoloop.

>
>> Can you be more specific, and are you sure about this?
>
> Just run your favourite performance analysis tool and you'll see.
> As it is non-inlined libc code I'm fairly sure the numbers are accurate 
> enough.

I am still puzzled by the remarks; and hence asked for specific
examples. In aac code, cosf is only called for table generation, same
with cos, so still don't see why cos is relevant.

> ___
> 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] lavc/aacenc_utils: replace powf(x, y) by expf(logf(x), y)

2016-03-07 Thread Ganesh Ajjanagadde
This is ~2x faster for y not an integer on Haswell+GCC, and should
generally be faster due to the fact that anyway powf essentially does
this under the hood.

Note that there are some accuracy differences, that should generally be
negligible. In particular, FATE still passes on this platform.

Results in ~ 7% speedup in aac encoding with -march=native, Haswell+GCC.
before:
ffmpeg -i sin.flac -acodec aac -y sin_new.aac  6.05s user 0.06s system 104% cpu 
5.821 total

after:
ffmpeg -i sin.flac -acodec aac -y sin_new.aac  5.67s user 0.03s system 105% cpu 
5.416 total

This is also faster than an alternative approach that pulls in powf, gets rid of
the crufty NaN checks and other special cases, exploits knowledge about the 
intervals, etc.
This of course does not exclude smarter approaches; just suggests that
there would need to be significant work on this front of lower utility than
searches for hotspots elsewhere.

Signed-off-by: Ganesh Ajjanagadde 
---
 libavcodec/aacenc_utils.h | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/aacenc_utils.h b/libavcodec/aacenc_utils.h
index 56e3462..b7f80c6 100644
--- a/libavcodec/aacenc_utils.h
+++ b/libavcodec/aacenc_utils.h
@@ -121,7 +121,10 @@ static inline float find_form_factor(int group_len, int 
swb_size, float thresh,
 if (s >= ethresh) {
 nzl += 1.0f;
 } else {
-nzl += powf(s / ethresh, nzslope);
+if (nzslope == 2.f)
+nzl += (s / ethresh) * (s / ethresh);
+else
+nzl += expf(logf(s / ethresh) * nzslope);
 }
 }
 if (e2 > thresh) {
-- 
2.7.2

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


Re: [FFmpeg-devel] [PATCH] lavf/avienc: New AVOption write_keyframe_palette

2016-03-07 Thread Mats Peterson

On 03/07/2016 07:48 PM, Mats Peterson wrote:

On 03/07/2016 07:43 PM, Mats Peterson wrote:

Here's a somewhat experimental patch with a new AVOption
write_keyframe_palette that allows you to write the palette to every
keyframe. It is disabled by default, but it is needed for any file that
contains palette changes.



It is needed in order to switch palette properly when seeking, that is.



It's interesting to note that Windows Media Player doesn't need xxpc 
chunks at keyframes in order to seek properly in the following original 
file from Sierra's King's Quest VI. I have of course no idea how they 
solve that.


This original file doesn't work properly in FFplay for some reason. It 
generates "stream_ptr out of bounds" messages at the locations of the 
xxpc chunks.


File:
https://drive.google.com/open?id=0B3_pEBoLs0faaFY0ME92SDA1VEU

Mats

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


Re: [FFmpeg-devel] [PATCH] lavc/psymodel: check for av_malloc failure

2016-03-07 Thread Ganesh Ajjanagadde
On Thu, Mar 3, 2016 at 10:06 PM, Ganesh Ajjanagadde  wrote:
> No idea why in commit 01ecb7172b684f1c4b3e748f95c5a9a494ca36ec the
> checks were removed; this can lead to NULL pointer dereferences. This
> effectively reverts that portion of the commit.
>
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  libavcodec/psymodel.c | 6 +-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/psymodel.c b/libavcodec/psymodel.c
> index 6274a49..edc5ac8 100644
> --- a/libavcodec/psymodel.c
> +++ b/libavcodec/psymodel.c
> @@ -120,7 +120,11 @@ av_cold struct FFPsyPreprocessContext* 
> ff_psy_preprocess_init(AVCodecContext *av
>   FF_FILTER_MODE_LOWPASS, 
> FILT_ORDER,
>   cutoff_coeff, 0.0, 0.0);
>  if (ctx->fcoeffs) {
> -ctx->fstate = av_mallocz(sizeof(ctx->fstate[0]) * 
> avctx->channels);
> +ctx->fstate = av_mallocz_array(sizeof(ctx->fstate[0]), 
> avctx->channels);
> +if (!ctx->fstate) {
> +av_free(ctx);
> +return NULL;
> +}
>  for (i = 0; i < avctx->channels; i++)
>  ctx->fstate[i] = ff_iir_filter_init_state(FILT_ORDER);
>  }
> --
> 2.7.2
>

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


[FFmpeg-devel] [PATCH 3/3] avformat/mov: read start_pad from edit list start time if codec is aac

2016-03-07 Thread Marton Balint
Related to ticket #2324, #2325.

Stream duration still need to be fixed...

Signed-off-by: Marton Balint 
---
 libavformat/mov.c |  3 +++
 tests/ref/fate/gapless2-ipod-aac1 | 36 ++--
 tests/ref/fate/gapless2-ipod-aac2 | 36 ++--
 tests/ref/fate/gapless2-mov-aac   | 36 ++--
 4 files changed, 57 insertions(+), 54 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 752bc12..73e3f30 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -2688,6 +2688,9 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
 st->codec->has_b_frames = 1;
 }
 }
+
+if (!unsupported && st->codec->codec_id == AV_CODEC_ID_AAC && 
start_time > 0)
+sc->start_pad = start_time;
 }
 
 /* only use old uncompressed audio chunk demuxing when stts specifies it */
diff --git a/tests/ref/fate/gapless2-ipod-aac1 
b/tests/ref/fate/gapless2-ipod-aac1
index 15e599b..426107a 100644
--- a/tests/ref/fate/gapless2-ipod-aac1
+++ b/tests/ref/fate/gapless2-ipod-aac1
@@ -45,12 +45,12 @@ 
source|1262|frame|pkt_pts=1293312|pkt_dts=1293312|best_effort_timestamp=1293312|
 target|[STREAM]
 target|index=0
 target|codec_name=aac
-target|start_pts=-1024
+target|start_pts=0
 target|duration_ts=1293248
 target|[/STREAM]
 target|[FORMAT]
 target|format_name=mov,mp4,m4a,3gp,3g2,mj2
-target|start_time=-0.023220
+target|start_time=0.00
 target|duration=29.326000
 target|size=490323
 target|[/FORMAT]
@@ -70,19 +70,19 @@ target|1260|packet|pts=1288192|dts=1288192|duration=1024
 target|1261|packet|pts=1289216|dts=1289216|duration=1024
 target|1262|packet|pts=1290240|dts=1290240|duration=1024
 target|1263|packet|pts=1291264|dts=1291264|duration=1984
-target|1|frame|pkt_pts=-1024|pkt_dts=-1024|best_effort_timestamp=-1024|pkt_duration=1024|nb_samples=1024
-target|2|frame|pkt_pts=0|pkt_dts=0|best_effort_timestamp=0|pkt_duration=1024|nb_samples=1024
-target|3|frame|pkt_pts=1024|pkt_dts=1024|best_effort_timestamp=1024|pkt_duration=1024|nb_samples=1024
-target|4|frame|pkt_pts=2048|pkt_dts=2048|best_effort_timestamp=2048|pkt_duration=1024|nb_samples=1024
-target|5|frame|pkt_pts=3072|pkt_dts=3072|best_effort_timestamp=3072|pkt_duration=1024|nb_samples=1024
-target|6|frame|pkt_pts=4096|pkt_dts=4096|best_effort_timestamp=4096|pkt_duration=1024|nb_samples=1024
-target|7|frame|pkt_pts=5120|pkt_dts=5120|best_effort_timestamp=5120|pkt_duration=1024|nb_samples=1024
-target|8|frame|pkt_pts=6144|pkt_dts=6144|best_effort_timestamp=6144|pkt_duration=1024|nb_samples=1024
-target|1256|frame|pkt_pts=1284096|pkt_dts=1284096|best_effort_timestamp=1284096|pkt_duration=1024|nb_samples=1024
-target|1257|frame|pkt_pts=1285120|pkt_dts=1285120|best_effort_timestamp=1285120|pkt_duration=1024|nb_samples=1024
-target|1258|frame|pkt_pts=1286144|pkt_dts=1286144|best_effort_timestamp=1286144|pkt_duration=1024|nb_samples=1024
-target|1259|frame|pkt_pts=1287168|pkt_dts=1287168|best_effort_timestamp=1287168|pkt_duration=1024|nb_samples=1024
-target|1260|frame|pkt_pts=1288192|pkt_dts=1288192|best_effort_timestamp=1288192|pkt_duration=1024|nb_samples=1024
-target|1261|frame|pkt_pts=1289216|pkt_dts=1289216|best_effort_timestamp=1289216|pkt_duration=1024|nb_samples=1024
-target|1262|frame|pkt_pts=1290240|pkt_dts=1290240|best_effort_timestamp=1290240|pkt_duration=1024|nb_samples=1024
-target|1263|frame|pkt_pts=1291264|pkt_dts=1291264|best_effort_timestamp=1291264|pkt_duration=1984|nb_samples=1024
+target|1|frame|pkt_pts=0|pkt_dts=0|best_effort_timestamp=0|pkt_duration=1024|nb_samples=1024
+target|2|frame|pkt_pts=1024|pkt_dts=1024|best_effort_timestamp=1024|pkt_duration=1024|nb_samples=1024
+target|3|frame|pkt_pts=2048|pkt_dts=2048|best_effort_timestamp=2048|pkt_duration=1024|nb_samples=1024
+target|4|frame|pkt_pts=3072|pkt_dts=3072|best_effort_timestamp=3072|pkt_duration=1024|nb_samples=1024
+target|5|frame|pkt_pts=4096|pkt_dts=4096|best_effort_timestamp=4096|pkt_duration=1024|nb_samples=1024
+target|6|frame|pkt_pts=5120|pkt_dts=5120|best_effort_timestamp=5120|pkt_duration=1024|nb_samples=1024
+target|7|frame|pkt_pts=6144|pkt_dts=6144|best_effort_timestamp=6144|pkt_duration=1024|nb_samples=1024
+target|8|frame|pkt_pts=7168|pkt_dts=7168|best_effort_timestamp=7168|pkt_duration=1024|nb_samples=1024
+target|1255|frame|pkt_pts=1284096|pkt_dts=1284096|best_effort_timestamp=1284096|pkt_duration=1024|nb_samples=1024
+target|1256|frame|pkt_pts=1285120|pkt_dts=1285120|best_effort_timestamp=1285120|pkt_duration=1024|nb_samples=1024
+target|1257|frame|pkt_pts=1286144|pkt_dts=1286144|best_effort_timestamp=1286144|pkt_duration=1024|nb_samples=1024
+target|1258|frame|pkt_pts=1287168|pkt_dts=1287168|best_effort_timestamp=1287168|pkt_duration=1024|nb_samples=1024
+target|1259|frame|pkt_pts=1288192|pkt_dts=1288192|best_effort_timestamp=1288192|pkt_duration=1024|nb_samples=1024

[FFmpeg-devel] [PATCH 2/3] avformat/utils: increase detected start_time with skip_samples

2016-03-07 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/utils.c   | 10 --
 tests/ref/fate/gapless2-ipod-aac1 | 74 +++
 tests/ref/fate/gapless2-ipod-aac2 | 74 +++
 3 files changed, 82 insertions(+), 76 deletions(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 5f48de1..ca2dd09 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -971,8 +971,11 @@ static void update_initial_timestamps(AVFormatContext *s, 
int stream_index,
 if (is_relative(pktl->pkt.dts))
 pktl->pkt.dts += shift;
 
-if (st->start_time == AV_NOPTS_VALUE && pktl->pkt.pts != 
AV_NOPTS_VALUE)
+if (st->start_time == AV_NOPTS_VALUE && pktl->pkt.pts != 
AV_NOPTS_VALUE) {
 st->start_time = pktl->pkt.pts;
+if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && 
st->codec->sample_rate)
+st->start_time += av_rescale_q(st->skip_samples, 
(AVRational){1, st->codec->sample_rate}, st->time_base);
+}
 
 if (pktl->pkt.pts != AV_NOPTS_VALUE && delay <= MAX_REORDER_DELAY && 
has_decode_delay_been_guessed(st)) {
 pts_buffer[0] = pktl->pkt.pts;
@@ -983,8 +986,11 @@ static void update_initial_timestamps(AVFormatContext *s, 
int stream_index,
 }
 }
 
-if (st->start_time == AV_NOPTS_VALUE)
+if (st->start_time == AV_NOPTS_VALUE) {
 st->start_time = pts;
+if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && 
st->codec->sample_rate)
+st->start_time += av_rescale_q(st->skip_samples, (AVRational){1, 
st->codec->sample_rate}, st->time_base);
+}
 }
 
 static void update_initial_durations(AVFormatContext *s, AVStream *st,
diff --git a/tests/ref/fate/gapless2-ipod-aac1 
b/tests/ref/fate/gapless2-ipod-aac1
index 9a35d5f..15e599b 100644
--- a/tests/ref/fate/gapless2-ipod-aac1
+++ b/tests/ref/fate/gapless2-ipod-aac1
@@ -1,12 +1,12 @@
 source|[STREAM]
 source|index=0
 source|codec_name=aac
-source|start_pts=0
+source|start_pts=2112
 source|duration_ts=1294336
 source|[/STREAM]
 source|[FORMAT]
 source|format_name=mov,mp4,m4a,3gp,3g2,mj2
-source|start_time=0.00
+source|start_time=0.047889
 source|duration=29.350023
 source|size=982382
 source|[/FORMAT]
@@ -45,44 +45,44 @@ 
source|1262|frame|pkt_pts=1293312|pkt_dts=1293312|best_effort_timestamp=1293312|
 target|[STREAM]
 target|index=0
 target|codec_name=aac
-target|start_pts=1058
+target|start_pts=-1024
 target|duration_ts=1293248
 target|[/STREAM]
 target|[FORMAT]
 target|format_name=mov,mp4,m4a,3gp,3g2,mj2
-target|start_time=0.023991
+target|start_time=-0.023220
 target|duration=29.326000
-target|size=490335
+target|size=490323
 target|[/FORMAT]
-target|1|packet|pts=1058|dts=1058|duration=1024
-target|2|packet|pts=2082|dts=2082|duration=1024
-target|3|packet|pts=3106|dts=3106|duration=1024
-target|4|packet|pts=4130|dts=4130|duration=1024
-target|5|packet|pts=5154|dts=5154|duration=1024
-target|6|packet|pts=6178|dts=6178|duration=1024
-target|7|packet|pts=7202|dts=7202|duration=1024
-target|8|packet|pts=8226|dts=8226|duration=1024
-target|1256|packet|pts=1286178|dts=1286178|duration=1024
-target|1257|packet|pts=1287202|dts=1287202|duration=1024
-target|1258|packet|pts=1288226|dts=1288226|duration=1024
-target|1259|packet|pts=1289250|dts=1289250|duration=1024
-target|1260|packet|pts=1290274|dts=1290274|duration=1024
-target|1261|packet|pts=1291298|dts=1291298|duration=1024
-target|1262|packet|pts=1292322|dts=1292322|duration=1024
-target|1263|packet|pts=1293346|dts=1293346|duration=-98
-target|1|frame|pkt_pts=1058|pkt_dts=1058|best_effort_timestamp=1058|pkt_duration=1024|nb_samples=1024
-target|2|frame|pkt_pts=2082|pkt_dts=2082|best_effort_timestamp=2082|pkt_duration=1024|nb_samples=1024
-target|3|frame|pkt_pts=3106|pkt_dts=3106|best_effort_timestamp=3106|pkt_duration=1024|nb_samples=1024
-target|4|frame|pkt_pts=4130|pkt_dts=4130|best_effort_timestamp=4130|pkt_duration=1024|nb_samples=1024
-target|5|frame|pkt_pts=5154|pkt_dts=5154|best_effort_timestamp=5154|pkt_duration=1024|nb_samples=1024
-target|6|frame|pkt_pts=6178|pkt_dts=6178|best_effort_timestamp=6178|pkt_duration=1024|nb_samples=1024
-target|7|frame|pkt_pts=7202|pkt_dts=7202|best_effort_timestamp=7202|pkt_duration=1024|nb_samples=1024
-target|8|frame|pkt_pts=8226|pkt_dts=8226|best_effort_timestamp=8226|pkt_duration=1024|nb_samples=1024
-target|1256|frame|pkt_pts=1286178|pkt_dts=1286178|best_effort_timestamp=1286178|pkt_duration=1024|nb_samples=1024
-target|1257|frame|pkt_pts=1287202|pkt_dts=1287202|best_effort_timestamp=1287202|pkt_duration=1024|nb_samples=1024
-target|1258|frame|pkt_pts=1288226|pkt_dts=1288226|best_effort_timestamp=1288226|pkt_duration=1024|nb_samples=1024
-target|1259|frame|pkt_pts=1289250|pkt_dts=1289250|best_effort_timestamp=1289250|pkt_duration=1024|nb_samples=1024
-target|1260|frame|pkt_pts=1290274|pkt_dts=1290274|best_effort_timestamp=1290274|pkt_duration=1024|nb_samples=1024

[FFmpeg-devel] [PATCH 1/3] tests/gapless: add gapless aac tests

2016-03-07 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 tests/fate-run.sh | 30 +
 tests/fate/gapless.mak| 20 -
 tests/ref/fate/gapless2-ipod-aac1 | 88 +++
 tests/ref/fate/gapless2-ipod-aac2 | 88 +++
 tests/ref/fate/gapless2-mov-aac   | 88 +++
 5 files changed, 313 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/fate/gapless2-ipod-aac1
 create mode 100644 tests/ref/fate/gapless2-ipod-aac2
 create mode 100644 tests/ref/fate/gapless2-mov-aac

diff --git a/tests/fate-run.sh b/tests/fate-run.sh
index 16087cb..d8a469b 100755
--- a/tests/fate-run.sh
+++ b/tests/fate-run.sh
@@ -96,6 +96,21 @@ probeframes(){
 run ffprobe${PROGSUF} -show_frames -v 0 "$@"
 }
 
+probegaplessinfo(){
+filename=$1
+shift
+run ffprobe${PROGSUF} -bitexact -select_streams a -show_entries 
format=format_name,size,start_time,duration:stream=index,codec_name,start_pts,duration_ts
 -v 0 "$filename" "$@"
+pktfile1="${filename}.pkts"
+framefile1="${filename}.frames"
+cleanfiles="$cleanfiles $pktfile1 $framefile1"
+run ffprobe${PROGSUF} -bitexact -select_streams a -of compact 
-show_entries packet=pts,dts,duration -v 0 "$filename" "$@" | nl -w 1 -s '|' > 
$pktfile1
+head -n 8 $pktfile1
+tail -n 8 $pktfile1
+run ffprobe${PROGSUF} -bitexact -select_streams a -of compact 
-show_entries 
frame=pkt_pts,pkt_dts,best_effort_timestamp,pkt_duration,nb_samples -v 0 
"$filename" "$@" | nl -w 1 -s '|' > $framefile1
+head -n 8 $framefile1
+tail -n 8 $framefile1
+}
+
 ffmpeg(){
 dec_opts="-hwaccel $hwaccel -threads $threads -thread_type $thread_type"
 ffmpeg_args="-nostdin -nostats -cpuflags $cpuflags"
@@ -249,6 +264,21 @@ gapless(){
 do_md5sum $decfile3
 }
 
+gapless2(){
+sample=$(target_path $1)
+format=$2
+codec=$3
+
+file1="${outdir}/${test}.out-1"
+cleanfiles="$cleanfiles $file1"
+
+# test source data
+probegaplessinfo "$sample" | sed 's/^/source|/'
+# test data after reencoding
+ffmpeg -i "$sample" -flags +bitexact -fflags +bitexact -map 0:a -c:a 
$codec -f $format -y $file1
+probegaplessinfo "$file1" | sed 's/^/target|/'
+}
+
 concat(){
 template=$1
 sample=$2
diff --git a/tests/fate/gapless.mak b/tests/fate/gapless.mak
index 2fb005f..8d819bd 100644
--- a/tests/fate/gapless.mak
+++ b/tests/fate/gapless.mak
@@ -3,5 +3,23 @@ fate-gapless-mp3: CMD = gapless 
$(TARGET_SAMPLES)/gapless/gapless.mp3
 
 FATE_GAPLESS = $(FATE_GAPLESS-yes)
 
+FATE_GAPLESS2_PROBE-$(call ENCDEC, AAC, MOV) += fate-gapless2-ipod-aac1
+fate-gapless2-ipod-aac1: ffprobe$(PROGSSUF)$(EXESUF)
+fate-gapless2-ipod-aac1: CMD = gapless2 
$(TARGET_SAMPLES)/cover_art/Owner-iTunes_9.0.3.15.m4a ipod aac
+
+FATE_GAPLESS2_PROBE-$(call ENCDEC, AAC, MOV) += fate-gapless2-ipod-aac2
+fate-gapless2-ipod-aac2: ffprobe$(PROGSSUF)$(EXESUF)
+fate-gapless2-ipod-aac2: CMD = gapless2 
$(TARGET_SAMPLES)/gapless/102400samples_qt-lc-aac.m4a ipod aac
+
+FATE_GAPLESS2_PROBE-$(call ENCDEC, AAC, MOV) += fate-gapless2-mov-aac
+fate-gapless2-mov-aac: $(AREF)
+fate-gapless2-mov-aac: ffprobe$(PROGSSUF)$(EXESUF)
+fate-gapless2-mov-aac: CMD = gapless2 $(AREF) mov aac
+
+FATE_GAPLESS2-$(CONFIG_FFPROBE) = $(FATE_GAPLESS2_PROBE-yes)
+FATE_GAPLESS2 = $(FATE_GAPLESS2-yes)
+
 FATE_SAMPLES_AVCONV += $(FATE_GAPLESS)
-fate-gapless: $(FATE_GAPLESS)
+FATE_SAMPLES_AVCONV += $(FATE_GAPLESS2)
+
+fate-gapless: $(FATE_GAPLESS) $(FATE_GAPLESS2)
diff --git a/tests/ref/fate/gapless2-ipod-aac1 
b/tests/ref/fate/gapless2-ipod-aac1
new file mode 100644
index 000..9a35d5f
--- /dev/null
+++ b/tests/ref/fate/gapless2-ipod-aac1
@@ -0,0 +1,88 @@
+source|[STREAM]
+source|index=0
+source|codec_name=aac
+source|start_pts=0
+source|duration_ts=1294336
+source|[/STREAM]
+source|[FORMAT]
+source|format_name=mov,mp4,m4a,3gp,3g2,mj2
+source|start_time=0.00
+source|duration=29.350023
+source|size=982382
+source|[/FORMAT]
+source|1|packet|pts=0|dts=0|duration=1024
+source|2|packet|pts=1024|dts=1024|duration=1024
+source|3|packet|pts=2048|dts=2048|duration=1024
+source|4|packet|pts=3072|dts=3072|duration=1024
+source|5|packet|pts=4096|dts=4096|duration=1024
+source|6|packet|pts=5120|dts=5120|duration=1024
+source|7|packet|pts=6144|dts=6144|duration=1024
+source|8|packet|pts=7168|dts=7168|duration=1024
+source|1257|packet|pts=1286144|dts=1286144|duration=1024
+source|1258|packet|pts=1287168|dts=1287168|duration=1024
+source|1259|packet|pts=1288192|dts=1288192|duration=1024
+source|1260|packet|pts=1289216|dts=1289216|duration=1024
+source|1261|packet|pts=1290240|dts=1290240|duration=1024
+source|1262|packet|pts=1291264|dts=1291264|duration=1024
+source|1263|packet|pts=1292288|dts=1292288|duration=1024
+source|1264|packet|pts=1293312|dts=1293312|duration=1024
+source|1|frame|pkt_pts=2112|pkt_dts=2112|best_effort_timestamp=2048|pkt_duration=960|nb_samples=960

[FFmpeg-devel] [PATCH] Add encoder stats to the NVENC codec.

2016-03-07 Thread Lucas Cooper
---
 libavcodec/nvenc.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index a3b02fa..5489610 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1167,6 +1167,8 @@ static int process_output_surface(AVCodecContext *avctx, 
AVPacket *pkt, NvencOut
 NVENCSTATUS nv_status;
 int res = 0;
 
+enum AVPictureType pict_type;
+
 switch (avctx->codec->id) {
 case AV_CODEC_ID_H264:
   slice_mode_data = 
ctx->encode_config.encodeCodecConfig.h264Config.sliceModeData;
@@ -1211,28 +1213,31 @@ static int process_output_surface(AVCodecContext 
*avctx, AVPacket *pkt, NvencOut
 switch (lock_params.pictureType) {
 case NV_ENC_PIC_TYPE_IDR:
 pkt->flags |= AV_PKT_FLAG_KEY;
-#if FF_API_CODED_FRAME
-FF_DISABLE_DEPRECATION_WARNINGS
 case NV_ENC_PIC_TYPE_I:
-avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+pict_type = AV_PICTURE_TYPE_I;
 break;
 case NV_ENC_PIC_TYPE_P:
-avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
+pict_type = AV_PICTURE_TYPE_P;
 break;
 case NV_ENC_PIC_TYPE_B:
-avctx->coded_frame->pict_type = AV_PICTURE_TYPE_B;
+pict_type = AV_PICTURE_TYPE_B;
 break;
 case NV_ENC_PIC_TYPE_BI:
-avctx->coded_frame->pict_type = AV_PICTURE_TYPE_BI;
+pict_type = AV_PICTURE_TYPE_BI;
 break;
 default:
 av_log(avctx, AV_LOG_ERROR, "Unknown picture type encountered, expect 
the output to be broken.\n");
 av_log(avctx, AV_LOG_ERROR, "Please report this error and include as 
much information on how to reproduce it as possible.\n");
 res = AVERROR_EXTERNAL;
 goto error;
+}
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
+avctx->coded_frame->pict_type = pict_type;
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
-}
+ff_side_data_set_encoder_stats(pkt, (lock_params.frameAvgQP - 1)
+* FF_QP2LAMBDA, NULL, 0, pict_type);
 
 pkt->pts = lock_params.outputTimeStamp;
 pkt->dts = timestamp_queue_dequeue(>timestamp_list);
-- 
2.7.0.rc3.207.g0ac5344

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


[FFmpeg-devel] [PATCH] lavf/matroskaenc.c: add early support for colour elements

2016-03-07 Thread Neil Birkbeck
Adding early support for a subset of the proposed colour elements
according to the latest version of spec:
https://mailarchive.ietf.org/arch/search/?email_list=cellar=1=hIKLhMdgTMTEwUTeA4ct38h0tmE

Like matroskadec, I've left out elements for pix_fmt related things
 as there still seems to be some discussion around these.

The new elements are exposed under strict experimental mode.

Signed-off-by: Neil Birkbeck 
---
 libavformat/matroskaenc.c | 63 ++-
 1 file changed, 62 insertions(+), 1 deletion(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index f42434b..ce5c605 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -41,6 +41,7 @@
 #include "libavutil/intfloat.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/lfg.h"
+#include "libavutil/mastering_display_metadata.h"
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
 #include "libavutil/random_seed.h"
@@ -730,6 +731,64 @@ static int mkv_write_codecprivate(AVFormatContext *s, 
AVIOContext *pb,
 return ret;
 }
 
+static int mkv_write_video_color(AVIOContext *pb, AVCodecContext *codec, 
AVStream *st) {
+int side_data_size = 0;
+const uint8_t *side_data = av_stream_get_side_data(
+st, AV_PKT_DATA_MASTERING_DISPLAY_METADATA, _data_size);
+ebml_master colorinfo = start_ebml_master(pb, MATROSKA_ID_VIDEOCOLOR, 0);
+
+if (codec->color_trc != AVCOL_TRC_UNSPECIFIED &&
+codec->color_trc < AVCOL_TRC_NB) {
+put_ebml_uint(pb, MATROSKA_ID_VIDEOCOLORTRANSFERCHARACTERISTICS,
+  codec->color_trc);
+}
+if (codec->colorspace != AVCOL_SPC_UNSPECIFIED &&
+codec->colorspace < AVCOL_SPC_NB) {
+put_ebml_uint(pb, MATROSKA_ID_VIDEOCOLORMATRIXCOEFF, 
codec->colorspace);
+}
+if (codec->color_primaries != AVCOL_PRI_UNSPECIFIED &&
+codec->color_primaries < AVCOL_PRI_NB) {
+put_ebml_uint(pb, MATROSKA_ID_VIDEOCOLORPRIMARIES, 
codec->color_primaries);
+}
+if (codec->color_range != AVCOL_RANGE_UNSPECIFIED &&
+codec->color_range < AVCOL_RANGE_NB) {
+put_ebml_uint(pb, MATROSKA_ID_VIDEOCOLORRANGE, codec->color_range);
+}
+if (side_data_size == sizeof(AVMasteringDisplayMetadata)) {
+ebml_master meta_element = start_ebml_master(
+pb, MATROSKA_ID_VIDEOCOLORMASTERINGMETA, 0);
+const AVMasteringDisplayMetadata *metadata =
+(const AVMasteringDisplayMetadata*)side_data;
+if (metadata->has_primaries) {
+put_ebml_float(pb, MATROSKA_ID_VIDEOCOLOR_RX,
+   av_q2d(metadata->display_primaries[0][0]));
+put_ebml_float(pb, MATROSKA_ID_VIDEOCOLOR_RY,
+   av_q2d(metadata->display_primaries[0][1]));
+put_ebml_float(pb, MATROSKA_ID_VIDEOCOLOR_GX,
+   av_q2d(metadata->display_primaries[1][0]));
+put_ebml_float(pb, MATROSKA_ID_VIDEOCOLOR_GY,
+   av_q2d(metadata->display_primaries[1][1]));
+put_ebml_float(pb, MATROSKA_ID_VIDEOCOLOR_BX,
+   av_q2d(metadata->display_primaries[2][0]));
+put_ebml_float(pb, MATROSKA_ID_VIDEOCOLOR_BY,
+   av_q2d(metadata->display_primaries[2][1]));
+put_ebml_float(pb, MATROSKA_ID_VIDEOCOLOR_WHITEX,
+   av_q2d(metadata->white_point[0]));
+put_ebml_float(pb, MATROSKA_ID_VIDEOCOLOR_WHITEY,
+   av_q2d(metadata->white_point[1]));
+}
+if (metadata->has_luminance) {
+put_ebml_float(pb, MATROSKA_ID_VIDEOCOLOR_LUMINANCEMAX,
+   av_q2d(metadata->max_luminance));
+put_ebml_float(pb, MATROSKA_ID_VIDEOCOLOR_LUMINANCEMIN,
+   av_q2d(metadata->min_luminance));
+}
+end_ebml_master(pb, meta_element);
+}
+end_ebml_master(pb, colorinfo);
+return 0;
+}
+
 
 static int mkv_write_stereo_mode(AVFormatContext *s, AVIOContext *pb,
  AVStream *st, int mode, int *h_width, int 
*h_height)
@@ -1015,7 +1074,9 @@ static int mkv_write_track(AVFormatContext *s, 
MatroskaMuxContext *mkv,
 uint32_t color_space = av_le2ne32(codec->codec_tag);
 put_ebml_binary(pb, MATROSKA_ID_VIDEOCOLORSPACE, _space, 
sizeof(color_space));
 }
-
+if (s->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) {
+mkv_write_video_color(pb, codec, st);
+}
 end_ebml_master(pb, subinfo);
 break;
 
-- 
2.7.0.rc3.207.g0ac5344

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


Re: [FFmpeg-devel] [PATCH] avcodec: try to document timebase and framerate a bit more

2016-03-07 Thread Michael Niedermayer
On Sat, Mar 05, 2016 at 07:55:47PM +0100, Reimar Döffinger wrote:
> On Sat, Mar 05, 2016 at 06:56:30PM +0100, Michael Niedermayer wrote:
> > On Sat, Mar 05, 2016 at 06:01:11PM +0100, Reimar Döffinger wrote:
> > > On Sat, Mar 05, 2016 at 01:41:32PM +0100, Michael Niedermayer wrote:
> > > > + * Note, for variable framerate material this has undefined 
> > > > meaning currently
> > > > + * and is not set to the actual framerate nor {0,1} but can be set 
> > > > to
> > > > + * 1/timebase (FIXME) the code in some parts assumes framerate == 
> > > > 1/timebase
> > > > + * which is generally not true but these parts need to be fixed 
> > > > before framerate
> > > > + * can be fixed.
> > > 
> > > This is too complex, maybe it can be split in multiple sentences.
> > > Suggestion (but I took a lot of liberty and it might not say what you
> > > meant!):
> > > 
> > > Note: meaning is not yet defined for variable frame rate content.
> > > Ideally it should be set to either the current frame rate or {0,1}
> > > for that case.
> > > However for this some code assuming framerate == 1/timebase needs to
> > > be fixed first - until then this field may incorrectly be set
> > > to 1/timebase.
> > 
> > there are 2 cases
> > 1. encoding where the users sets it
> > 2. deoding where lavc sets it
> > 
> > my comment was about decoding "issues"/"bugs"
> 
> I understood that, but I admit my description did not capture that,
> so maybe clearer with adding "when decoding" and "libavcodec sets"
> 
> > > Note: when decoding meaning is not yet defined for variable frame
> > > rate content.
> > > Ideally libavcodec should set it to either the current frame rate or {0,1}
> > > for that case.
> > > However for this some code assuming framerate == 1/timebase needs to
> > > be fixed first - until then libavcodec may incorrectly set this field
> > > to 1/timebase.
> 
> But as said it's just a suggestion. Even your original one is better
> than nothing. I just thought it quite tough to read.

i realized that, the framerate dox is really more or less a bug
description, it doesnt exactly fit in the public header where the patch
would put it.
It was more intended as a note for ffmpeg developers and less for
application developers, iam not sure where to put it or how to word
it exactly
not sure i should apply it (patch 2 of 2) or not ? or how to word it

the other patch (about timebase 1 of 2) ive applied

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

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- 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] lavf/utils: has_decode_delay_been_guessed - return true if nb_decoded_frames >= 2, when there are no B-frames.

2016-03-07 Thread Michael Niedermayer
On Mon, Mar 07, 2016 at 11:10:16AM -0800, Sasi Inguva wrote:
> Fixes DTS detection for any H264 file of less than 7 frames length. Without 
> this DTS is N/A.
> 
> Signed-off-by: Sasi Inguva 
> ---
>  libavformat/utils.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 5f48de1..5017937 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -877,7 +877,9 @@ static int has_decode_delay_been_guessed(AVStream *st)
> avpriv_h264_has_num_reorder_frames(st->codec) == 
> st->codec->has_b_frames)
>  return 1;
>  #endif
> -if (st->codec->has_b_frames<3)
> +if (st->codec->has_b_frames == 0)
> +return st->nb_decoded_frames >= 2;
> +else if (st->codec->has_b_frames<3)
>  return st->nb_decoded_frames >= 7;
>  else if (st->codec->has_b_frames<4)
>  return st->nb_decoded_frames >= 18;

this looks wrong
also it breaks for example
tickets/1242/sample.mkv
try
./ffmpeg -i sample.mkv -c:v copy -an -t 1 -f framecrc -
the DTS are wrong after this patch and there are error messages

[framecrc @ 0x2a52ce0] Invalid DTS: 291 PTS: 209 in output stream 0:0, 
replacing by guess
0,251,251,   41, 4197, 0x3b9f74ad, F=0x0
[framecrc @ 0x2a52ce0] Non-monotonous DTS in output stream 0:0; previous: 251, 
current: 209; changing to 251. This may result in incorrect timestamps in the 
output file.

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope


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


Re: [FFmpeg-devel] [PATCH] Opus in MP4 support

2016-03-07 Thread James Almer
On 3/7/2016 1:29 AM, Matthew Gregan wrote:
> Hi,
> 
> The attached patch adds basic mux/demux support for the Opus audio codec in 
> MP4.
> 
> Mozilla have expressed interest in shipping support for this in:
> https://groups.google.com/d/msg/mozilla.dev.platform/mdDZ-nBr_jM/MaLi2BDOAgAJ
> 
> Comments welcome!
> 
> 
> Opus-in-MP4.patch
> 
> 
> Basic Opus in MP4 mux/demux support based on the draft spec.
> 
> Draft spec: https://www.opus-codec.org/docs/opus_in_isobmff.html

Check section 4.3.4 and use AV_PKT_DATA_SKIP_SAMPLES in the demuxer to export
the amount of samples that need to be discarded from the last packet.
Take a look at Matroska and OggOpus for two examples of this.

> 
> Signed-off-by: Matthew Gregan 
> ---
>  libavformat/isom.c   |  2 ++
>  libavformat/mov.c| 38 
>  libavformat/movenc.c | 82 
> ++--
>  3 files changed, 119 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/isom.c b/libavformat/isom.c
> index 2ca1265..6d92a93 100644
> --- a/libavformat/isom.c
> +++ b/libavformat/isom.c
> @@ -61,6 +61,7 @@ const AVCodecTag ff_mp4_obj_type[] = {
>  { AV_CODEC_ID_DTS , 0xA9 }, /* mp4ra.org */
>  { AV_CODEC_ID_TSCC2   , 0xD0 }, /* non standard, camtasia uses it */
>  { AV_CODEC_ID_VORBIS  , 0xDD }, /* non standard, gpac uses it */
> +{ AV_CODEC_ID_OPUS, 0xDE }, /* non standard */
>  { AV_CODEC_ID_DVD_SUBTITLE, 0xE0 }, /* non standard, see 
> unsupported-embedded-subs-2.mp4 */
>  { AV_CODEC_ID_QCELP   , 0xE1 },
>  { AV_CODEC_ID_MPEG4SYSTEMS, 0x01 },
> @@ -323,6 +324,7 @@ const AVCodecTag ff_codec_movaudio_tags[] = {
>  { AV_CODEC_ID_WMAV2,   MKTAG('W', 'M', 'A', '2') },
>  { AV_CODEC_ID_EVRC,MKTAG('s', 'e', 'v', 'c') }, /* 3GPP2 */
>  { AV_CODEC_ID_SMV, MKTAG('s', 's', 'm', 'v') }, /* 3GPP2 */
> +{ AV_CODEC_ID_OPUS,MKTAG('O', 'p', 'u', 's') }, /* 
> non-standard */
>  { AV_CODEC_ID_NONE, 0 },
>  };
>  
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 752bc12..a6b896e 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -1534,6 +1534,43 @@ static int mov_read_svq3(MOVContext *c, AVIOContext 
> *pb, MOVAtom atom)
>  return mov_read_extradata(c, pb, atom, AV_CODEC_ID_SVQ3);
>  }
>  
> +static int mov_read_dops(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> +{
> +AVStream *st;
> +size_t size;
> +
> +if (c->fc->nb_streams < 1)
> +return 0;
> +st = c->fc->streams[c->fc->nb_streams-1];
> +
> +if ((uint64_t)atom.size > (1<<30) || atom.size < 11)
> +return AVERROR_INVALIDDATA;
> +
> +// Check OpusSpecificBox version.
> +if (avio_r8(pb) != 0)
> +return AVERROR_INVALIDDATA;
> +
> +// OpusSpecificBox size plus magic header for OggOpus header.
> +size = atom.size + 16;
> +
> +st->codec->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);
> +if (!st->codec->extradata)
> +return AVERROR(ENOMEM);
> +st->codec->extradata_size = size;

Use ff_alloc_extradata(st->codec, size).

> +
> +AV_WL32(st->codec->extradata, MKTAG('O','p','u','s'));
> +AV_WL32(st->codec->extradata + 4, MKTAG('H','e','a','d'));
> +AV_WB8(st->codec->extradata + 8, 1); // OggOpus version
> +avio_read(pb, st->codec->extradata + 9, size - 17);
> +
> +// OpusSpecificBox is stored in big-endian, but OpusHead is
> +// little-endian; they're otherwise identical.
> +AV_WL16(st->codec->extradata + 10, AV_RB16(st->codec->extradata + 10));

Shouldn't you fill st->codec->delay with this value as well?

> +AV_WL32(st->codec->extradata + 12, AV_RB32(st->codec->extradata + 12));
> +AV_WL16(st->codec->extradata + 16, AV_RB16(st->codec->extradata + 16));
> +return 0;
> +}
> +
>  static int mov_read_wave(MOVContext *c, AVIOContext *pb, MOVAtom atom)
>  {
>  AVStream *st;
> @@ -4308,6 +4345,7 @@ static const MOVParseTableEntry 
> mov_default_parse_table[] = {
>  { MKTAG('f','r','m','a'), mov_read_frma },
>  { MKTAG('s','e','n','c'), mov_read_senc },
>  { MKTAG('s','a','i','z'), mov_read_saiz },
> +{ MKTAG('d','O','p','s'), mov_read_dops },
>  { 0, NULL }
>  };
>  
> diff --git a/libavformat/movenc.c b/libavformat/movenc.c
> index cb125d8..e5698b4 100644
> --- a/libavformat/movenc.c
> +++ b/libavformat/movenc.c
> @@ -649,6 +649,25 @@ static int mov_write_wfex_tag(AVIOContext *pb, MOVTrack 
> *track)
>  return update_size(pb, pos);
>  }
>  
> +static int mov_write_dops_tag(AVIOContext *pb, MOVTrack *track)
> +{
> +int64_t pos = avio_tell(pb);
> +avio_wb32(pb, 0);
> +ffio_wfourcc(pb, "dOps");
> +avio_w8(pb, 0); // OpusSpecificBox version.
> +if (track->enc->extradata_size < 19)
> +  return AVERROR_INVALIDDATA;
> +// Write the part of a OggOpus header matching the OpusSpecificBox 
> layout.
> +// Skipping OggOpus magic (8 bytes) and version (1 byte).
> +   

Re: [FFmpeg-devel] [PATCH] lavf/utils: has_decode_delay_been_guessed - always return true if there are no B-frames at all.

2016-03-07 Thread Sasi Inguva
Please ignore this patch as the commit message is incorrect. Sent a new
patch with corrected commit message.

On Mon, Mar 7, 2016 at 11:02 AM, Sasi Inguva  wrote:

> Fixes DTS detection for any H264 file of less than 7 frames length.
> Without this DTS is N/A.
>
> Signed-off-by: Sasi Inguva 
> ---
>  libavformat/utils.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 5f48de1..5017937 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -877,7 +877,9 @@ static int has_decode_delay_been_guessed(AVStream *st)
> avpriv_h264_has_num_reorder_frames(st->codec) ==
> st->codec->has_b_frames)
>  return 1;
>  #endif
> -if (st->codec->has_b_frames<3)
> +if (st->codec->has_b_frames == 0)
> +return st->nb_decoded_frames >= 2;
> +else if (st->codec->has_b_frames<3)
>  return st->nb_decoded_frames >= 7;
>  else if (st->codec->has_b_frames<4)
>  return st->nb_decoded_frames >= 18;
> --
> 2.7.0.rc3.207.g0ac5344
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavf/utils: has_decode_delay_been_guessed - return true if nb_decoded_frames >= 2, when there are no B-frames.

2016-03-07 Thread Sasi Inguva
Fixes DTS detection for any H264 file of less than 7 frames length. Without 
this DTS is N/A.

Signed-off-by: Sasi Inguva 
---
 libavformat/utils.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 5f48de1..5017937 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -877,7 +877,9 @@ static int has_decode_delay_been_guessed(AVStream *st)
avpriv_h264_has_num_reorder_frames(st->codec) == 
st->codec->has_b_frames)
 return 1;
 #endif
-if (st->codec->has_b_frames<3)
+if (st->codec->has_b_frames == 0)
+return st->nb_decoded_frames >= 2;
+else if (st->codec->has_b_frames<3)
 return st->nb_decoded_frames >= 7;
 else if (st->codec->has_b_frames<4)
 return st->nb_decoded_frames >= 18;
-- 
2.7.0.rc3.207.g0ac5344

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


[FFmpeg-devel] [PATCH] lavf/utils: has_decode_delay_been_guessed - always return true if there are no B-frames at all.

2016-03-07 Thread Sasi Inguva
Fixes DTS detection for any H264 file of less than 7 frames length. Without 
this DTS is N/A.

Signed-off-by: Sasi Inguva 
---
 libavformat/utils.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 5f48de1..5017937 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -877,7 +877,9 @@ static int has_decode_delay_been_guessed(AVStream *st)
avpriv_h264_has_num_reorder_frames(st->codec) == 
st->codec->has_b_frames)
 return 1;
 #endif
-if (st->codec->has_b_frames<3)
+if (st->codec->has_b_frames == 0)
+return st->nb_decoded_frames >= 2;
+else if (st->codec->has_b_frames<3)
 return st->nb_decoded_frames >= 7;
 else if (st->codec->has_b_frames<4)
 return st->nb_decoded_frames >= 18;
-- 
2.7.0.rc3.207.g0ac5344

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


Re: [FFmpeg-devel] [PATCH] lavf/avienc: New AVOption write_keyframe_palette

2016-03-07 Thread Mats Peterson

On 03/07/2016 07:43 PM, Mats Peterson wrote:

Here's a somewhat experimental patch with a new AVOption
write_keyframe_palette that allows you to write the palette to every
keyframe. It is disabled by default, but it is needed for any file that
contains palette changes.



It is needed in order to switch palette properly when seeking, that is.

Mats

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


[FFmpeg-devel] [PATCH] lavf/avienc: New AVOption write_keyframe_palette

2016-03-07 Thread Mats Peterson
Here's a somewhat experimental patch with a new AVOption 
write_keyframe_palette that allows you to write the palette to every 
keyframe. It is disabled by default, but it is needed for any file that 
contains palette changes.


This patch has to be applied after the previous 2-part patch set.

Mats

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 582f36e474ac96adaf0f00739a6c22a9da3601c3 Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Mon, 7 Mar 2016 19:38:38 +0100
Subject: [PATCH] lavf/avienc: New AVOption write_keyframe_palette

---
 libavformat/avienc.c |   10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index fe4dc7e..aaa396c 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -66,6 +66,7 @@ typedef struct AVIContext {
 int64_t frames_hdr_all;
 int riff_id;
 int write_channel_mask;
+int write_keyframe_palette;
 } AVIContext;
 
 typedef struct AVIStream {
@@ -680,6 +681,7 @@ static int avi_write_xxpc(AVFormatContext *s, int stream_index, uint32_t *palett
 static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
 const int stream_index = pkt->stream_index;
+AVIContext *avi = s->priv_data;
 AVIOContext *pb = s->pb;
 AVCodecContext *enc = s->streams[stream_index]->codec;
 AVIStream *avist= s->streams[stream_index]->priv_data;
@@ -711,13 +713,13 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 int ret2 = ff_get_packet_palette(s, opkt, ret, avist->palette);
 if (ret2 < 0)
 return ret2;
-if (ret2) {
+if (ret2 || (avi->write_keyframe_palette && (pkt->flags & AV_PKT_FLAG_KEY))) {
 int pal_size = 1 << enc->bits_per_coded_sample;
 int i;
 
 av_assert0(enc->bits_per_coded_sample >= 0 && enc->bits_per_coded_sample <= 8);
 
-if (pb->seekable && avist->pal_offset) {
+if (ret2 && pb->seekable && avist->pal_offset) {
 int64_t cur_offset = avio_tell(pb);
 avio_seek(pb, avist->pal_offset, SEEK_SET);
 for (i = 0; i < pal_size; i++) {
@@ -728,7 +730,8 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 memcpy(avist->old_palette, avist->palette, pal_size * 4);
 avist->pal_offset = 0;
 }
-if (memcmp(avist->palette, avist->old_palette, pal_size * 4)) {
+if (memcmp(avist->palette, avist->old_palette, pal_size * 4) ||
+(avi->write_keyframe_palette && (pkt->flags & AV_PKT_FLAG_KEY))) {
 avi_write_xxpc(s, stream_index, avist->palette);
 memcpy(avist->old_palette, avist->palette, pal_size * 4);
 if (pb->seekable && avist->strh_flags_offset) {
@@ -887,6 +890,7 @@ static int avi_write_trailer(AVFormatContext *s)
 #define ENC AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
 { "write_channel_mask", "write channel mask into wave format header", OFFSET(write_channel_mask), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, ENC },
+{ "write_keyframe_palette", "write palette at keyframes", OFFSET(write_keyframe_palette), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, ENC },
 { NULL },
 };
 
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH] Add encoder stats to the NVENC codec.

2016-03-07 Thread Timo Rothenpieler
> ---
>  libavcodec/nvenc.c | 18 +++---
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
> index a3b02fa..67232c7 100644
> --- a/libavcodec/nvenc.c
> +++ b/libavcodec/nvenc.c
> @@ -1208,31 +1208,35 @@ static int process_output_surface(AVCodecContext 
> *avctx, AVPacket *pkt, NvencOut
>  if (nv_status != NV_ENC_SUCCESS)
>  av_log(avctx, AV_LOG_ERROR, "Failed unlocking bitstream buffer, 
> expect the gates of mordor to open\n");
>  
> +enum AVPictureType pict_type;
> +

Mixed code and declaration

>  switch (lock_params.pictureType) {
>  case NV_ENC_PIC_TYPE_IDR:
>  pkt->flags |= AV_PKT_FLAG_KEY;
> -#if FF_API_CODED_FRAME
> -FF_DISABLE_DEPRECATION_WARNINGS
>  case NV_ENC_PIC_TYPE_I:
> -avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
> +pict_type = AV_PICTURE_TYPE_I;
>  break;
>  case NV_ENC_PIC_TYPE_P:
> -avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
> +pict_type = AV_PICTURE_TYPE_P;
>  break;
>  case NV_ENC_PIC_TYPE_B:
> -avctx->coded_frame->pict_type = AV_PICTURE_TYPE_B;
> +pict_type = AV_PICTURE_TYPE_B;
>  break;
>  case NV_ENC_PIC_TYPE_BI:
> -avctx->coded_frame->pict_type = AV_PICTURE_TYPE_BI;
> +pict_type = AV_PICTURE_TYPE_BI;
>  break;
>  default:
>  av_log(avctx, AV_LOG_ERROR, "Unknown picture type encountered, 
> expect the output to be broken.\n");
>  av_log(avctx, AV_LOG_ERROR, "Please report this error and include as 
> much information on how to reproduce it as possible.\n");
>  res = AVERROR_EXTERNAL;
>  goto error;
> +}
> +#if FF_API_CODED_FRAME
> +FF_DISABLE_DEPRECATION_WARNINGS
> +avctx->coded_frame->pict_type = pict_type;
>  FF_ENABLE_DEPRECATION_WARNINGS
>  #endif
> -}
> +ff_side_data_set_encoder_stats(pkt, (lock_params.frameAvgQP - 1) * 
> FF_QP2LAMBDA, NULL, 0, pict_type);
>  
>  pkt->pts = lock_params.outputTimeStamp;
>  pkt->dts = timestamp_queue_dequeue(>timestamp_list);
> 

Fine otherwise, or does anything still depend on the stuff in
coded_frame being set somewhat correctly, so that this would break it?



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


Re: [FFmpeg-devel] [PATCH] Add encoder stats to the NVENC codec.

2016-03-07 Thread philipl

On 2016-03-02 15:21, Lucas Cooper wrote:

---
 libavcodec/nvenc.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
index a3b02fa..67232c7 100644
--- a/libavcodec/nvenc.c
+++ b/libavcodec/nvenc.c
@@ -1208,31 +1208,35 @@ static int
process_output_surface(AVCodecContext *avctx, AVPacket *pkt, NvencOut
 if (nv_status != NV_ENC_SUCCESS)
 av_log(avctx, AV_LOG_ERROR, "Failed unlocking bitstream
buffer, expect the gates of mordor to open\n");

+enum AVPictureType pict_type;
+
 switch (lock_params.pictureType) {
 case NV_ENC_PIC_TYPE_IDR:
 pkt->flags |= AV_PKT_FLAG_KEY;
-#if FF_API_CODED_FRAME
-FF_DISABLE_DEPRECATION_WARNINGS
 case NV_ENC_PIC_TYPE_I:
-avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
+pict_type = AV_PICTURE_TYPE_I;
 break;
 case NV_ENC_PIC_TYPE_P:
-avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
+pict_type = AV_PICTURE_TYPE_P;
 break;
 case NV_ENC_PIC_TYPE_B:
-avctx->coded_frame->pict_type = AV_PICTURE_TYPE_B;
+pict_type = AV_PICTURE_TYPE_B;
 break;
 case NV_ENC_PIC_TYPE_BI:
-avctx->coded_frame->pict_type = AV_PICTURE_TYPE_BI;
+pict_type = AV_PICTURE_TYPE_BI;
 break;
 default:
 av_log(avctx, AV_LOG_ERROR, "Unknown picture type
encountered, expect the output to be broken.\n");
 av_log(avctx, AV_LOG_ERROR, "Please report this error and
include as much information on how to reproduce it as possible.\n");
 res = AVERROR_EXTERNAL;
 goto error;
+}
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
+avctx->coded_frame->pict_type = pict_type;
 FF_ENABLE_DEPRECATION_WARNINGS
 #endif
-}
+ff_side_data_set_encoder_stats(pkt, (lock_params.frameAvgQP - 1)
* FF_QP2LAMBDA, NULL, 0, pict_type);


Wrap the line.



 pkt->pts = lock_params.outputTimeStamp;
 pkt->dts = timestamp_queue_dequeue(>timestamp_list);


Looks fine otherwise.

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


Re: [FFmpeg-devel] [PATCH] Add encoder stats to the NVENC codec.

2016-03-07 Thread Lucas Cooper
Ping.

On 2 March 2016 at 15:21, Lucas Cooper  wrote:

> ---
>  libavcodec/nvenc.c | 18 +++---
>  1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/libavcodec/nvenc.c b/libavcodec/nvenc.c
> index a3b02fa..67232c7 100644
> --- a/libavcodec/nvenc.c
> +++ b/libavcodec/nvenc.c
> @@ -1208,31 +1208,35 @@ static int process_output_surface(AVCodecContext
> *avctx, AVPacket *pkt, NvencOut
>  if (nv_status != NV_ENC_SUCCESS)
>  av_log(avctx, AV_LOG_ERROR, "Failed unlocking bitstream buffer,
> expect the gates of mordor to open\n");
>
> +enum AVPictureType pict_type;
> +
>  switch (lock_params.pictureType) {
>  case NV_ENC_PIC_TYPE_IDR:
>  pkt->flags |= AV_PKT_FLAG_KEY;
> -#if FF_API_CODED_FRAME
> -FF_DISABLE_DEPRECATION_WARNINGS
>  case NV_ENC_PIC_TYPE_I:
> -avctx->coded_frame->pict_type = AV_PICTURE_TYPE_I;
> +pict_type = AV_PICTURE_TYPE_I;
>  break;
>  case NV_ENC_PIC_TYPE_P:
> -avctx->coded_frame->pict_type = AV_PICTURE_TYPE_P;
> +pict_type = AV_PICTURE_TYPE_P;
>  break;
>  case NV_ENC_PIC_TYPE_B:
> -avctx->coded_frame->pict_type = AV_PICTURE_TYPE_B;
> +pict_type = AV_PICTURE_TYPE_B;
>  break;
>  case NV_ENC_PIC_TYPE_BI:
> -avctx->coded_frame->pict_type = AV_PICTURE_TYPE_BI;
> +pict_type = AV_PICTURE_TYPE_BI;
>  break;
>  default:
>  av_log(avctx, AV_LOG_ERROR, "Unknown picture type encountered,
> expect the output to be broken.\n");
>  av_log(avctx, AV_LOG_ERROR, "Please report this error and include
> as much information on how to reproduce it as possible.\n");
>  res = AVERROR_EXTERNAL;
>  goto error;
> +}
> +#if FF_API_CODED_FRAME
> +FF_DISABLE_DEPRECATION_WARNINGS
> +avctx->coded_frame->pict_type = pict_type;
>  FF_ENABLE_DEPRECATION_WARNINGS
>  #endif
> -}
> +ff_side_data_set_encoder_stats(pkt, (lock_params.frameAvgQP - 1) *
> FF_QP2LAMBDA, NULL, 0, pict_type);
>
>  pkt->pts = lock_params.outputTimeStamp;
>  pkt->dts = timestamp_queue_dequeue(>timestamp_list);
> --
> 2.7.0.rc3.207.g0ac5344
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] lavf/avienc: Palette handling code only concerns AV_PIX_FMT_PAL8

2016-03-07 Thread Mats Peterson
Mats Peterson  skrev: (7 mars 2016 18:04:34 
CET)
>Mats Peterson  skrev: (7 mars 2016
>17:49:41 CET)
>>Mats Peterson  skrev: (7 mars 2016
>>15:00:29 CET)
>>>Forget the separate patch posted before, and my previous experimental
>
>>>variants of your patch, Michael. And if we're going to use keyframe
>>>xxpc 
>>>chunks, we'll have to invent something really good. Here is some
>>useful
>>>
>>>stuff added in the meantime.
>>>
>>>Mats
>>
>>I've come to the conclusion that for any file with a palette change
>>somewhere in it, you have to add xxpc chunks to *every* keyframe in
>the
>>file, not only the ones following the palette change like your patch
>is
>>currently doing, as far as I can tell.
>>
>>Mats
>>-- 
>>Mats Peterson
>>http://matsp888.no-ip.org/~mats/
>>___
>>ffmpeg-devel mailing list
>>ffmpeg-devel@ffmpeg.org
>>http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>One could perhaps arrange to detect the AVISF_VIDEO_PALCHANGES flag in
>the source file (if AVI, of course), and, if set, add xxpc chunks to
>every keyframe in the destination file.
>
>Mats
>-- 
>Mats Peterson
>http://matsp888.no-ip.org/~mats/
>___
>ffmpeg-devel mailing list
>ffmpeg-devel@ffmpeg.org
>http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Or detect if there is any palette change regardless of that flag. For AVI it 
would be easy, since they come as xxpc chunks as usual, but for nut it would 
take a different logic. End of monologue.

Mats
-- 
Mats Peterson
http://matsp888.no-ip.org/~mats/
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavc/libopenh264enc: document cabac option, and change its type to boolean

2016-03-07 Thread Stefano Sabatini
---
 doc/encoders.texi   | 3 +++
 libavcodec/libopenh264enc.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index dfab007..76dd53c 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1425,6 +1425,9 @@ Set number of MBs per slice. This is only used when
 
 @item allow_skip_frames
 Allow skipping frames to hit the target bitrate if set to 1.
+
+@item cabac
+Enable CABAC (entropy encoding) if set to 1. Default value is 0.
 @end table
 
 @section jpeg2000
diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index ec78b12..67c0a60 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -57,7 +57,7 @@ static const AVOption options[] = {
 { "slice_size", "set maximum NAL size in bytes", OFFSET(max_nal_size), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
 { "slice_mbs", "set number of MBs per slice", OFFSET(slice_mbs), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, VE },
 { "allow_skip_frames", "allow skipping frames to hit the target bitrate", 
OFFSET(skip_frames), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE },
-{ "cabac", "Enable cabac", OFFSET(cabac), AV_OPT_TYPE_INT, { .i64 = 0 }, 
0, 1, VE },
+{ "cabac", "enable CABAC encoding", OFFSET(cabac), AV_OPT_TYPE_BOOL, { 
.i64 = 0 }, 0, 1, VE },
 { NULL }
 };
 
-- 
1.9.1

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


[FFmpeg-devel] [PATCH] lavc/libopenh264enc: update to openh264 1.6

2016-03-07 Thread Stefano Sabatini
In particular, the slice mode API was changed in commit:

commit 33c378f7b791310e4cb64b53e2bb8f3f3bded105
Author: sijchen 
Date:   Tue Nov 10 09:50:06 2015 -0800

change API for slicing part for easier usage (the UseLoadBalancing flag is 
still under working)

This fixes compilation with latest version of openh264.
---
 configure   |  2 +-
 doc/encoders.texi   | 25 ++-
 libavcodec/libopenh264enc.c | 48 ++---
 libavcodec/version.h|  2 +-
 4 files changed, 42 insertions(+), 35 deletions(-)

diff --git a/configure b/configure
index f28aa8f..4bffd0f 100755
--- a/configure
+++ b/configure
@@ -5569,7 +5569,7 @@ enabled libopencv && { check_header 
opencv2/core/core_c.h &&
{ use_pkg_config opencv opencv2/core/core_c.h 
cvCreateImageHeader ||
  require opencv opencv2/core/core_c.h 
cvCreateImageHeader -lopencv_core -lopencv_imgproc; } ||
require_pkg_config opencv opencv/cxcore.h 
cvCreateImageHeader; }
-enabled libopenh264   && require_pkg_config openh264 wels/codec_api.h 
WelsGetCodecVersion
+enabled libopenh264   && require_pkg_config "openh264 >= 1.6" 
wels/codec_api.h WelsGetCodecVersion
 enabled libopenjpeg   && { check_lib openjpeg-2.1/openjpeg.h opj_version 
-lopenjp2 -DOPJ_STATIC ||
check_lib openjpeg-2.0/openjpeg.h opj_version 
-lopenjp2 -DOPJ_STATIC ||
check_lib openjpeg-1.5/openjpeg.h opj_version 
-lopenjpeg -DOPJ_STATIC ||
diff --git a/doc/encoders.texi b/doc/encoders.texi
index f38cad3..dfab007 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1394,16 +1394,18 @@ Set slice mode. Can assume one of the follwing possible 
values:
 
 @table @samp
 @item fixed
-a fixed number of slices
-@item rowmb
-one slice per row of macroblocks
-@item auto
-automatic number of slices according to number of threads
-@item dyn
-dynamic slicing
+use a fixed numer of slices, depending on the value of
+@option{slices}. If set to 0, the number of slices is automatically
+selected.
+@item raster
+use a fixed number of macro-blocks per slice. The number of MBs is set
+through @option{slice_mbs}.
+@item sizelimited
+set slicing according to size. The slice size is set through
+@option{max_nal_size}.
 @end table
 
-Default value is @samp{auto}.
+Default value is @samp{fixed}.
 
 @item loopfilter
 Enable loop filter, if set to 1 (automatically enabled). To disable
@@ -1414,7 +1416,12 @@ Set profile restrictions. If set to the value of 
@samp{main} enable
 CABAC (set the @code{SEncParamExt.iEntropyCodingModeFlag} flag to 1).
 
 @item max_nal_size
-Set maximum NAL size in bytes.
+Set maximum nal size in bytes. This is only used when
+@option{slice_mode} is set to @samp{sizelimited}.
+
+@item slice_mbs
+Set number of MBs per slice. This is only used when
+@option{slice_mode} is set to @samp{raster}.
 
 @item allow_skip_frames
 Allow skipping frames to hit the target bitrate if set to 1.
diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 6850568..0c1b1b8 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -39,6 +39,7 @@ typedef struct SVCContext {
 int loopfilter;
 char *profile;
 int max_nal_size;
+int slice_mbs;
 int skip_frames;
 int skipped;
 int cabac;
@@ -51,14 +52,14 @@ typedef struct SVCContext {
 #define OFFSET(x) offsetof(SVCContext, x)
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
-{ "slice_mode", "set slice mode", OFFSET(slice_mode), AV_OPT_TYPE_INT, { 
.i64 = SM_AUTO_SLICE }, SM_SINGLE_SLICE, SM_RESERVED, VE, "slice_mode" },
-{ "fixed", "a fixed number of slices", 0, AV_OPT_TYPE_CONST, { .i64 = 
SM_FIXEDSLCNUM_SLICE }, 0, 0, VE, "slice_mode" },
-{ "rowmb", "one slice per row of macroblocks", 0, AV_OPT_TYPE_CONST, { 
.i64 = SM_ROWMB_SLICE }, 0, 0, VE, "slice_mode" },
-{ "auto", "automatic number of slices according to number of threads", 
0, AV_OPT_TYPE_CONST, { .i64 = SM_AUTO_SLICE }, 0, 0, VE, "slice_mode" },
-{ "dyn", "Dynamic slicing", 0, AV_OPT_TYPE_CONST, { .i64 = 
SM_DYN_SLICE }, 0, 0, VE, "slice_mode" },
+{ "slice_mode", "set slice mode", OFFSET(slice_mode), AV_OPT_TYPE_INT, { 
.i64 = SM_FIXEDSLCNUM_SLICE }, SM_FIXEDSLCNUM_SLICE, SM_RESERVED, VE, 
"slice_mode" },
+{ "fixed", "set a fixed number of slices, depending on slices option", 
0, AV_OPT_TYPE_CONST, { .i64 = SM_FIXEDSLCNUM_SLICE }, 0, 0, VE, "slice_mode" },
+{ "raster", "set a fixed number of MB per slice, depending on slice_mb 
option", 0, AV_OPT_TYPE_CONST, { .i64 = SM_RASTER_SLICE }, 0, 0, VE, 
"slice_mode" },
+{ "sizelimited", "set slice according to size", 0, AV_OPT_TYPE_CONST, 
{ .i64 = SM_SIZELIMITED_SLICE }, 0, 0, VE, "slice_mode" },
 { "loopfilter", 

[FFmpeg-devel] [PATCH] lavc/libopenh264enc: drop OPENH264_VER_AT_LEAST usage

2016-03-07 Thread Stefano Sabatini
Now FFmpeg requires openh264 at least at version 1.6.
---
 libavcodec/libopenh264enc.c | 8 
 1 file changed, 8 deletions(-)

diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 0c1b1b8..ec78b12 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -45,10 +45,6 @@ typedef struct SVCContext {
 int cabac;
 } SVCContext;
 
-#define OPENH264_VER_AT_LEAST(maj, min) \
-((OPENH264_MAJOR  > (maj)) || \
- (OPENH264_MAJOR == (maj) && OPENH264_MINOR >= (min)))
-
 #define OFFSET(x) offsetof(SVCContext, x)
 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 static const AVOption options[] = {
@@ -165,11 +161,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 param.bEnableLongTermReference   = 0;
 param.iLtrMarkPeriod = 30;
 param.uiIntraPeriod  = avctx->gop_size;
-#if OPENH264_VER_AT_LEAST(1, 4)
 param.eSpsPpsIdStrategy  = CONSTANT_ID;
-#else
-param.bEnableSpsPpsIdAddition= 0;
-#endif
 param.bPrefixNalAddingCtrl   = 0;
 param.iLoopFilterDisableIdc  = !s->loopfilter;
 param.iEntropyCodingModeFlag = 0;
-- 
1.9.1

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


Re: [FFmpeg-devel] [PATCH 1/2] lavf/avienc: Palette handling code only concerns AV_PIX_FMT_PAL8

2016-03-07 Thread Mats Peterson
Mats Peterson  skrev: (7 mars 2016 17:49:41 
CET)
>Mats Peterson  skrev: (7 mars 2016
>15:00:29 CET)
>>Forget the separate patch posted before, and my previous experimental 
>>variants of your patch, Michael. And if we're going to use keyframe
>>xxpc 
>>chunks, we'll have to invent something really good. Here is some
>useful
>>
>>stuff added in the meantime.
>>
>>Mats
>
>I've come to the conclusion that for any file with a palette change
>somewhere in it, you have to add xxpc chunks to *every* keyframe in the
>file, not only the ones following the palette change like your patch is
>currently doing, as far as I can tell.
>
>Mats
>-- 
>Mats Peterson
>http://matsp888.no-ip.org/~mats/
>___
>ffmpeg-devel mailing list
>ffmpeg-devel@ffmpeg.org
>http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

One could perhaps arrange to detect the AVISF_VIDEO_PALCHANGES flag in the 
source file (if AVI, of course), and, if set, add xxpc chunks to every keyframe 
in the destination file.

Mats
-- 
Mats Peterson
http://matsp888.no-ip.org/~mats/
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] lavf/avienc: Palette handling code only concerns AV_PIX_FMT_PAL8

2016-03-07 Thread Mats Peterson
Mats Peterson  skrev: (7 mars 2016 15:00:29 
CET)
>Forget the separate patch posted before, and my previous experimental 
>variants of your patch, Michael. And if we're going to use keyframe
>xxpc 
>chunks, we'll have to invent something really good. Here is some useful
>
>stuff added in the meantime.
>
>Mats

I've come to the conclusion that for any file with a palette change somewhere 
in it, you have to add xxpc chunks to *every* keyframe in the file, not only 
the ones following the palette change like your patch is currently doing, as 
far as I can tell.

Mats
-- 
Mats Peterson
http://matsp888.no-ip.org/~mats/
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Opus in MP4 support

2016-03-07 Thread Derek Buitenhuis
On 3/7/2016 4:29 AM, Matthew Gregan wrote:
> Hi,
> 
> The attached patch adds basic mux/demux support for the Opus audio codec in 
> MP4.
> 
> Mozilla have expressed interest in shipping support for this in:
> https://groups.google.com/d/msg/mozilla.dev.platform/mdDZ-nBr_jM/MaLi2BDOAgAJ

Hi,

Why have you not used the correct Object Type? Opus is registered with MP4RA.
Similar question regarding why you have marked the tag as non-standard.

See: http://www.mp4ra.org/codecs.html

- Derek

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


[FFmpeg-devel] [PATCH] configure: build fix for P5600 with mips code restructuring

2016-03-07 Thread shivraj.patil
From: Shivraj Patil 

Signed-off-by: Shivraj Patil 
---
 configure |  312 +++--
 1 file changed, 117 insertions(+), 195 deletions(-)

diff --git a/configure b/configure
index 3299b1b..81ec105 100755
--- a/configure
+++ b/configure
@@ -918,6 +918,25 @@ void foo(void){ __asm__ volatile($code); }
 EOF
 }
 
+check_inline_asm_flags(){
+log check_inline_asm_flags "$@"
+name="$1"
+code="$2"
+flags=''
+shift 2
+while [ "$1" != "" ]; do
+  append flags $1
+  shift
+done;
+disable $name
+cat > $TMPC 

[FFmpeg-devel] [PATCH 2/2] lavf/avienc: New static function avi_write_xxpc()

2016-03-07 Thread Mats Peterson


--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 0b38769f175ceafff8150a97be06b1a2fbf0bc3d Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Mon, 7 Mar 2016 14:54:26 +0100
Subject: [PATCH 2/2] lavf/avienc: New static function avi_write_xxpc()

---
 libavformat/avienc.c |   38 +-
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index b7fd12a..fe4dc7e 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -654,9 +654,31 @@ static int write_skip_frames(AVFormatContext *s, int stream_index, int64_t dts)
 return 0;
 }
 
-static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
+static int avi_write_xxpc(AVFormatContext *s, int stream_index, uint32_t *palette)
 {
+AVIOContext *pb = s->pb;
+AVCodecContext *enc = s->streams[stream_index]->codec;
+int pal_size= 1 << enc->bits_per_coded_sample;
 unsigned char tag[5];
+int pc_tag, i;
+
+avi_stream2fourcc(tag, stream_index, enc->codec_type);
+tag[2] = 'p'; tag[3] = 'c';
+pc_tag = ff_start_tag(pb, tag);
+avio_w8(pb, 0);
+avio_w8(pb, pal_size & 0xFF);
+avio_wl16(pb, 0); // reserved
+for (i = 0; i < pal_size; i++) {
+uint32_t v = palette[i];
+avio_wb32(pb, v<<8);
+}
+ff_end_tag(pb, pc_tag);
+
+return 0;
+}
+
+static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
+{
 const int stream_index = pkt->stream_index;
 AVIOContext *pb = s->pb;
 AVCodecContext *enc = s->streams[stream_index]->codec;
@@ -691,7 +713,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 return ret2;
 if (ret2) {
 int pal_size = 1 << enc->bits_per_coded_sample;
-int pc_tag, i;
+int i;
 
 av_assert0(enc->bits_per_coded_sample >= 0 && enc->bits_per_coded_sample <= 8);
 
@@ -707,17 +729,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 avist->pal_offset = 0;
 }
 if (memcmp(avist->palette, avist->old_palette, pal_size * 4)) {
-avi_stream2fourcc(tag, stream_index, enc->codec_type);
-tag[2] = 'p'; tag[3] = 'c';
-pc_tag = ff_start_tag(pb, tag);
-avio_w8(pb, 0);
-avio_w8(pb, pal_size & 0xFF);
-avio_wl16(pb, 0); // reserved
-for (i = 0; i < pal_size; i++) {
-uint32_t v = avist->palette[i];
-avio_wb32(pb, v<<8);
-}
-ff_end_tag(pb, pc_tag);
+avi_write_xxpc(s, stream_index, avist->palette);
 memcpy(avist->old_palette, avist->palette, pal_size * 4);
 if (pb->seekable && avist->strh_flags_offset) {
 int64_t cur_offset = avio_tell(pb);
-- 
1.7.10.4

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


[FFmpeg-devel] [PATCH 1/2] lavf/avienc: Palette handling code only concerns AV_PIX_FMT_PAL8

2016-03-07 Thread Mats Peterson
Forget the separate patch posted before, and my previous experimental 
variants of your patch, Michael. And if we're going to use keyframe xxpc 
chunks, we'll have to invent something really good. Here is some useful 
stuff added in the meantime.


Mats
--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From df58a34fd3a99002a7161e60c75b8bec5c5f9814 Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Mon, 7 Mar 2016 14:40:15 +0100
Subject: [PATCH 1/2] lavf/avienc: Palette handling code only concerns AV_PIX_FMT_PAL8

---
 libavformat/avienc.c |7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 357dd34..b7fd12a 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -662,7 +662,6 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 AVCodecContext *enc = s->streams[stream_index]->codec;
 AVIStream *avist= s->streams[stream_index]->priv_data;
 AVPacket *opkt = pkt;
-enum AVPixelFormat pix_fmt = enc->pix_fmt;
 int ret;
 
 if (enc->codec_id == AV_CODEC_ID_H264 && enc->codec_tag == MKTAG('H','2','6','4') && pkt->size) {
@@ -686,11 +685,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 return ret;
 } else
 ret = 0;
-if (pix_fmt == AV_PIX_FMT_NONE && enc->bits_per_coded_sample == 1)
-pix_fmt = AV_PIX_FMT_MONOWHITE;
-if (pix_fmt == AV_PIX_FMT_PAL8 ||
-pix_fmt == AV_PIX_FMT_MONOWHITE ||
-pix_fmt == AV_PIX_FMT_MONOBLACK) {
+if (enc->pix_fmt == AV_PIX_FMT_PAL8) {
 int ret2 = ff_get_packet_palette(s, opkt, ret, avist->palette);
 if (ret2 < 0)
 return ret2;
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH] lavf/img2dec: disable parsing if frame_size is specified

2016-03-07 Thread Carl Eugen Hoyos
Matthieu Bouron  gmail.com> writes:

>  else {
>  s->is_pipe   = 1;
> -st->need_parsing = AVSTREAM_PARSE_FULL;
> +st->need_parsing = s->frame_size > 0 ? AVSTREAM_PARSE_NONE 
> : AVSTREAM_PARSE_FULL;

Makes sense imo.

Carl Eugen

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


[FFmpeg-devel] [PATCH] lavf/img2dec: disable parsing if frame_size is specified

2016-03-07 Thread Matthieu Bouron
From: Matthieu Bouron 

---

Hello,

The following patch disable parsing if the frame_size option is specified. The
main purpose here is to disable the use of parsers (which have a huge
performance cost on embedded platforms) for single images when
their size is known in advance.

The patch sounds hackish to me though, but others might consider it OK (or not).

The performance of the jpeg parser still need to be addressed at some point.

Matthieu

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

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index fe0e346..9aa6dd7 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -206,7 +206,7 @@ int ff_img_read_header(AVFormatContext *s1)
 s->is_pipe = 0;
 else {
 s->is_pipe   = 1;
-st->need_parsing = AVSTREAM_PARSE_FULL;
+st->need_parsing = s->frame_size > 0 ? AVSTREAM_PARSE_NONE : 
AVSTREAM_PARSE_FULL;
 }
 
 if (s->ts_from_file == 2) {
-- 
2.7.2

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


Re: [FFmpeg-devel] [PATCH] lavc/mjpegdec: avoid unneeded allocation if the frame is to be skipped

2016-03-07 Thread Matthieu Bouron
On Tue, Mar 01, 2016 at 08:53:33PM +0100, Paul B Mahol wrote:
> On 3/1/16, Matthieu Bouron  wrote:
> > From: Matthieu Bouron 
> >
> > ---
> >  libavcodec/mjpegdec.c | 7 +++
> >  1 file changed, 7 insertions(+)
> >
> 
> probbably ok

Pushed. Thanks.

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


Re: [FFmpeg-devel] [PATCH]lavfi/extractplanes: Fix in_pixfmts

2016-03-07 Thread Carl Eugen Hoyos
Paul B Mahol  gmail.com> writes:

> OK, then push.

Patch applied.

Thank you, Carl Eugen

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


Re: [FFmpeg-devel] [PATCH v2 5/9] lavc/ccaption_dec: implement tab offset commands

2016-03-07 Thread Michael Niedermayer
On Tue, Jan 12, 2016 at 05:42:56PM -0800, Aman Gupta wrote:
> From: Aman Gupta 
> 
> ---
>  libavcodec/ccaption_dec.c | 5 +
>  1 file changed, 5 insertions(+)

do you have a testcase / sample that shows the problem this fixes ?

i think this patch wasnt applied yet

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

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin


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/2] lavc: add h264 mediacodec decoder

2016-03-07 Thread Matthieu Bouron
On Thu, Mar 03, 2016 at 02:03:01PM +0100, Matthieu Bouron wrote:

[...]

> 
> Patch updated with the following differences:
>   * ff_set_dimensions return code is now used
>   * add missing exception when trying to call the MediaCodec object 
> constructor
>   * remove leftover avctx_internal field from MediaCodecH264DecContext
>   * add ff_AMediaCodec_getName function
> 
> The dev branch can be found here:
> https://github.com/mbouron/FFmpeg/tree/feature/mediacodec-support-v7
> 
> If nobody objects I would like to push the patchset in 3 days.
> 

Pushed.

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


Re: [FFmpeg-devel] [PATCH]lavfi/extractplanes: Fix in_pixfmts

2016-03-07 Thread Paul B Mahol
On 3/7/16, Carl Eugen Hoyos  wrote:
> Paul B Mahol  gmail.com> writes:
>
>> > LGTM
>>
>> Wait, have you checked this doesn't break previously working cases?
>
> No.
>
> What cases could this be?
> After the patch, for le original formats, 16bit be input
> formats are not supported anymore, for be original formats,
> 16bit le input formats are not supported anymore.
> If the scaling system provided be input for le original or
> le input for be original, the output of extractplanes was
> broken because it signals the original endianness but
> the actual plane has the endianness of the actual input
> format.

OK, then push.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavfi/extractplanes: Fix in_pixfmts

2016-03-07 Thread Carl Eugen Hoyos
Paul B Mahol  gmail.com> writes:

> > LGTM
> 
> Wait, have you checked this doesn't break previously working cases?

No.

What cases could this be?
After the patch, for le original formats, 16bit be input 
formats are not supported anymore, for be original formats, 
16bit le input formats are not supported anymore.
If the scaling system provided be input for le original or 
le input for be original, the output of extractplanes was 
broken because it signals the original endianness but 
the actual plane has the endianness of the actual input 
format.

Carl Eugen

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


Re: [FFmpeg-devel] [PATCH 1/2] lavc: add JNI support

2016-03-07 Thread Matthieu Bouron
On Thu, Mar 03, 2016 at 01:56:16PM +0100, Matthieu Bouron wrote:
[...]
> 
> New patch attached with the following differences:
>   * added myself as a maintainer of jni* and ffjni*
> 

Pushed.

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


Re: [FFmpeg-devel] [PATCH]lavfi/extractplanes: Fix in_pixfmts

2016-03-07 Thread Paul B Mahol
On 3/7/16, Paul B Mahol  wrote:
> On 3/5/16, Carl Eugen Hoyos  wrote:
>> Hi!
>>
>> I see the following issue here with extractplanes:
>> If the input file has a 16bit little endian pix_fmt not supported by
>> extractplanes (gbra12le), the filter system has to choose a compatible
>> pix_fmt supported by the filter and chooses rgba64be here.
>> The extractplanes filter returns gray16le as output pix_fmt because the
>> original pix_fmt was le but produces visually broken output because the
>> actual filter input is be.
>> Attached patch works around this issue by always providing compatible
>> input and output formats.
>> I am happy if this can be fixed differently.
>>
>> Please comment, Carl Eugen
>
> LGTM
>

Wait, have you checked this doesn't break previously working cases?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavfi/extractplanes: Fix in_pixfmts

2016-03-07 Thread Paul B Mahol
On 3/5/16, Carl Eugen Hoyos  wrote:
> Hi!
>
> I see the following issue here with extractplanes:
> If the input file has a 16bit little endian pix_fmt not supported by
> extractplanes (gbra12le), the filter system has to choose a compatible
> pix_fmt supported by the filter and chooses rgba64be here.
> The extractplanes filter returns gray16le as output pix_fmt because the
> original pix_fmt was le but produces visually broken output because the
> actual filter input is be.
> Attached patch works around this issue by always providing compatible
> input and output formats.
> I am happy if this can be fixed differently.
>
> Please comment, Carl Eugen

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


Re: [FFmpeg-devel] [PATCH] lavf/avienc: Palette handling code only concerns AV_PIX_FMT_PAL8

2016-03-07 Thread Mats Peterson

On 03/07/2016 09:17 AM, Mats Peterson wrote:

On 03/07/2016 08:59 AM, Mats Peterson wrote:




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



Interestingly enough, on stream copy of 1 bpp raw video, the pixel
format will be AV_PIX_FMT_PAL8, but bits_per_coded_sample will be 1 (as
expected).

Mats



Forget my previous experimental variants of your patch, Michael. And if 
we're going to use keyframe xxpc chunks, we'll have to invent something 
really good.


Mats

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 0/2] New versioning (was: version.sh: Always use latest tag for generated version number)

2016-03-07 Thread Hendrik Leppkes
On Sun, Mar 6, 2016 at 2:50 AM, Timothy Gu  wrote:
> This patch set implements the versioning algorithm I recently proposed.
> The first patch addresses an already existing problem with version.sh.
> The second is the one actually implementing the change.
>
> To Michael and all release makers: after this patchset when making a
> release in a release branch, please do ALL of the following in the
> following order.
>
> 1. cp RELEASE VERSION
> 2. git add VERSION
> 3. Update doc/Doxyfile and Changelog
> 4. git commit -a -m "Update for $(cat VERSION)"
> 5. git tag -a -m "Release $(cat VERSION)"
> 6. Edit RELEASE to make it contain next version
> 7. git rm VERSION
> 8. git commit -a -m "Next release is $(cat RELEASE)"
>

This process seems rather convoluted, with adding and removing files
and whatnot. Easy to screw up and impossible to remedy later.
Can't we simplify that somehow to only use the tag, and not any
temporary VERSION file?

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


Re: [FFmpeg-devel] [PATCH 0/2] New versioning (was: version.sh: Always use latest tag for generated version number)

2016-03-07 Thread Carl Eugen Hoyos
Timothy Gu  gmail.com> writes:

> Timothy Gu (2):
>   version.sh: Fix Git directory
>   version.sh: Add next release to the version

Without these patches applied, I get the following:
$ ./version.sh
N-78949-g6f5048f

With your patches applied, I see:
$ ./version.sh
cat: /RELEASE: No such file or directory
-dev
$ cat RELEASE
n3.1-master

So I believe this is not correct yet.

Carl Eugen

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


Re: [FFmpeg-devel] [PATCH]lavfi/extractplanes: Fix in_pixfmts

2016-03-07 Thread Carl Eugen Hoyos
Carl Eugen Hoyos  ag.or.at> writes:

> If the input file has a 16bit little endian pix_fmt not supported 
> by extractplanes (gbra12le), the filter system has to choose a 
> compatible pix_fmt supported by the filter and chooses rgba64be 
> here. The extractplanes filter returns gray16le as output pix_fmt 
> because the original pix_fmt was le but produces visually broken 
> output because the actual filter input is be.
> Attached patch works around this issue by always providing 
> compatible input and output formats.
> I am happy if this can be fixed differently.

Ping.

I don't know if this is a general bug in libavfilter or just a 
specific one in extractplanes but it can't be expected behaviour.

Is there a possibility to set the input pix_fmts in 
query_formats() but the output pix_fmt later?

Carl Eugen

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


Re: [FFmpeg-devel] [PATCH] lavf/avienc: Palette handling code only concerns AV_PIX_FMT_PAL8

2016-03-07 Thread Mats Peterson

On 03/07/2016 08:59 AM, Mats Peterson wrote:




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



Interestingly enough, on stream copy of 1 bpp raw video, the pixel 
format will be AV_PIX_FMT_PAL8, but bits_per_coded_sample will be 1 (as 
expected).


Mats

--
Mats Peterson
http://matsp888.no-ip.org/~mats/
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavf/avienc: Palette handling code only concerns AV_PIX_FMT_PAL8

2016-03-07 Thread Mats Peterson


--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From ceaee5adb51c68bd35794f6c6165cd8c3f3b6619 Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Mon, 7 Mar 2016 08:58:30 +0100
Subject: [PATCH] lavf/avienc: Palette handling code only concerns AV_PIX_FMT_PAL8

---
 libavformat/avienc.c |7 +--
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 357dd34..b7fd12a 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -662,7 +662,6 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 AVCodecContext *enc = s->streams[stream_index]->codec;
 AVIStream *avist= s->streams[stream_index]->priv_data;
 AVPacket *opkt = pkt;
-enum AVPixelFormat pix_fmt = enc->pix_fmt;
 int ret;
 
 if (enc->codec_id == AV_CODEC_ID_H264 && enc->codec_tag == MKTAG('H','2','6','4') && pkt->size) {
@@ -686,11 +685,7 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 return ret;
 } else
 ret = 0;
-if (pix_fmt == AV_PIX_FMT_NONE && enc->bits_per_coded_sample == 1)
-pix_fmt = AV_PIX_FMT_MONOWHITE;
-if (pix_fmt == AV_PIX_FMT_PAL8 ||
-pix_fmt == AV_PIX_FMT_MONOWHITE ||
-pix_fmt == AV_PIX_FMT_MONOBLACK) {
+if (enc->pix_fmt == AV_PIX_FMT_PAL8) {
 int ret2 = ff_get_packet_palette(s, opkt, ret, avist->palette);
 if (ret2 < 0)
 return ret2;
-- 
1.7.10.4

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