[FFmpeg-devel] [PATCH v3] Add support for Audible AAX (and AAX+) files

2015-07-11 Thread Vesselin Bontchev
Hi,

I have uploaded some Audible samples to the 
https://gitlab.com/vesselin.bontchev/audible-samples/ page.

Currently only .aax files are supported, see 
https://en.wikipedia.org/wiki/Audible.com#Quality page for more information.

$ export activation_bytes=62689101

# ffmpeg -i Audible_AAX_sample_62689101.aax -vn -c:a copy -v debug output.mp4

VesselinFrom affa4a9315209976ff15e6ccf79bcf3b76088c6f Mon Sep 17 00:00:00 2001
From: Vesselin Bontchev 
Date: Sat, 11 Jul 2015 18:02:47 +
Subject: [PATCH] Add support for Audible AAX (and AAX+) files

---
 libavformat/isom.h |   3 +
 libavformat/mov.c  | 163 +
 2 files changed, 166 insertions(+)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 5d48989..6a054e8 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -198,6 +198,9 @@ typedef struct MOVContext {
 MOVFragmentIndex** fragment_index_data;
 unsigned fragment_index_count;
 int atom_depth;
+unsigned int aax_mode;  ///< 'aax' file has been detected
+unsigned char file_key[20];
+unsigned char file_iv[20];
 } MOVContext;
 
 int ff_mp4_read_descr_len(AVIOContext *pb);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 6d59863..2d4f3e6 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "libavutil/attributes.h"
 #include "libavutil/channel_layout.h"
@@ -37,6 +38,8 @@
 #include "libavutil/dict.h"
 #include "libavutil/display.h"
 #include "libavutil/opt.h"
+#include "libavutil/aes.h"
+#include "libavutil/sha.h"
 #include "libavutil/timecode.h"
 #include "libavcodec/ac3tab.h"
 #include "avformat.h"
@@ -807,6 +810,126 @@ static int mov_read_mdat(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 return 0; /* now go for moov */
 }
 
+
+static int hexchar2int(char c) {
+if (c >= '0' && c <= '9') return c - '0';
+if (c >= 'a' && c <= 'f') return c - 'a' + 10;
+if (c >= 'A' && c <= 'F') return c - 'A' + 10;
+return -1;
+}
+
+static void hex_encode(unsigned char *s, int len, unsigned char *o)
+{
+char itoa16_private[16] = "0123456789abcdef";
+int i;
+for (i = 0; i < len; ++i) {
+o[0] = itoa16_private[s[i] >> 4];
+o[1] = itoa16_private[s[i] & 15];
+o += 2;
+}
+}
+
+#define DRM_BLOB_SIZE 56
+
+static int aax_parser(MOVContext *c, AVIOContext *pb)
+{
+unsigned char activation_bytes[4];
+
+// extracted from libAAX_SDK.so and AAXSDKWin.dll files!
+unsigned char fixed_key[] = { 0x77, 0x21, 0x4d, 0x4b, 0x19, 0x6a, 0x87, 0xcd,
+  0x52, 0x00, 0x45, 0xfd, 0x20, 0xa5, 0x1d, 0x67 };
+unsigned char intermediate_key[20] = {0};
+unsigned char intermediate_iv[20] = {0};
+unsigned char input[64] = {0};
+unsigned char output[64] = {0};
+unsigned char file_checksum[20] = {0};
+unsigned char file_checksum_encoded[41] = {0};
+unsigned char file_key_encoded[41] = {0};
+unsigned char file_iv_encoded[41] = {0};
+unsigned char calculated_checksum[20];
+struct AVSHA *ctx;
+struct AVAES *aes_decrypt;
+int a, b, i;
+const char *magic = "drm";
+char *s;
+
+ctx = av_sha_alloc();
+aes_decrypt = av_aes_alloc();
+if (!aes_decrypt) {
+return AVERROR(ENOMEM);
+}
+
+/* drm blob processing */
+avio_seek(pb, 0x246, 0);
+avio_read(pb, input, 3);
+if (strncmp(input, magic, 3)) {
+av_log(c->fc, AV_LOG_FATAL, "[aax] drm blob is missing from this file!\n");
+exit(-1);
+}
+avio_seek(pb, 0x251, 0);
+avio_read(pb, input, DRM_BLOB_SIZE);
+avio_seek(pb, 0x28d, 0);
+avio_read(pb, file_checksum, 20);
+hex_encode(file_checksum, 20, file_checksum_encoded);
+av_log(c->fc, AV_LOG_DEBUG, "[aax] file checksum == %s\n", file_checksum_encoded);
+
+/* extract activation data */
+s = getenv("activation_bytes");
+if (!s || strlen(s) < 8) {
+av_log(c->fc, AV_LOG_FATAL, "[aax] export activation_bytes= is missing!\n");
+exit(-1); // XXX exit more gracefully
+}
+av_log(c->fc, AV_LOG_DEBUG, "[aax] activation_bytes == %s!\n", s);
+for (i = 0; i < 4 && isxdigit(*s); i++) {
+a = hexchar2int(*s++);
+b = hexchar2int(*s++);
+activation_bytes[i] = (a << 4) | b;
+}
+
+/* AAX (and AAX+) key derivation */
+av_sha_init(ctx, 160);
+av_sha_update(ctx, fixed_key, 16);
+av_sha_update(ctx, activation_bytes, 4);
+av_sha_final(ctx, intermediate_key);
+av_sha_init(ctx, 160);
+av_sha_update(ctx, fixed_key, 16);
+av_sha_update(ctx, intermediate_key, 20);
+av_sha_update(ctx, activation_bytes, 4);
+av_sha_final(ctx, intermediate_iv);
+av_sha_init(ctx, 160);
+av_sha_update(ctx, intermediate_key, 16);
+av_sha_update(ctx, intermediate_iv, 16);
+av_sha_final(ctx, calculated_checksum);
+if (memcmp(calculated_checksum, file_checksum, 20)) {
+av_log(c->fc, AV_LOG_ERROR,

[FFmpeg-devel] [PATCH] avcodec/dcadec: silence request_channels deprecation warnings

2015-07-11 Thread James Almer
This also prevents an eventual compilation failure once request_channels
is removed.

Signed-off-by: James Almer 
---
 libavcodec/dcadec.c | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c
index 3ea1bcf..a1b389f 100644
--- a/libavcodec/dcadec.c
+++ b/libavcodec/dcadec.c
@@ -1669,11 +1669,18 @@ static int dca_decode_frame(AVCodecContext *avctx, void 
*data,
 
 /* If we have XXCH then the channel layout is managed differently */
 /* note that XLL will also have another way to do things */
+#if FF_API_REQUEST_CHANNELS
+FF_DISABLE_DEPRECATION_WARNINGS
 if (!(s->core_ext_mask & DCA_EXT_XXCH)
 || (s->core_ext_mask & DCA_EXT_XXCH && avctx->request_channels > 0
 && avctx->request_channels
 < num_core_channels + !!s->lfe + s->xxch_chset_nch[0]))
-{ /* xxx should also do MA extensions */
+{
+FF_ENABLE_DEPRECATION_WARNINGS
+#else
+if (!(s->core_ext_mask & DCA_EXT_XXCH)) {
+#endif
+/* xxx should also do MA extensions */
 if (s->amode < 16) {
 avctx->channel_layout = ff_dca_core_channel_layout[s->amode];
 
@@ -1750,6 +1757,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
 /* we only get here if an XXCH channel set can be added to the mix */
 channel_mask = s->xxch_core_spkmask;
 
+#if FF_API_REQUEST_CHANNELS
+FF_DISABLE_DEPRECATION_WARNINGS
 if (avctx->request_channels > 0
 && avctx->request_channels < s->prim_channels) {
 channels = num_core_channels + !!s->lfe;
@@ -1758,7 +1767,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
 channels += s->xxch_chset_nch[i];
 channel_mask |= s->xxch_spk_masks[i];
 }
-} else {
+FF_ENABLE_DEPRECATION_WARNINGS
+} else
+#endif
+{
 channels = s->prim_channels + !!s->lfe;
 for (i = 0; i < s->xxch_chset; i++) {
 channel_mask |= s->xxch_spk_masks[i];
-- 
2.4.5

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


Re: [FFmpeg-devel] [PATCH v2] Add support for Audible AAX (and AAX+) files

2015-07-11 Thread James Almer
On 11/07/15 11:38 PM, Vesselin Bontchev wrote:
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 6d59863..62495a8 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -26,6 +26,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  #include "libavutil/attributes.h"
>  #include "libavutil/channel_layout.h"
> @@ -37,6 +38,8 @@
>  #include "libavutil/dict.h"
>  #include "libavutil/display.h"
>  #include "libavutil/opt.h"
> +#include "libavutil/aes.h"
> +#include "libavutil/hash.h"
>  #include "libavutil/timecode.h"
>  #include "libavcodec/ac3tab.h"
>  #include "avformat.h"
> @@ -807,6 +810,126 @@ static int mov_read_mdat(MOVContext *c, AVIOContext 
> *pb, MOVAtom atom)
>  return 0; /* now go for moov */
>  }
>  
> +
> +static int hexchar2int(char c) {
> +if (c >= '0' && c <= '9') return c - '0';
> +if (c >= 'a' && c <= 'f') return c - 'a' + 10;
> +if (c >= 'A' && c <= 'F') return c - 'A' + 10;
> +return -1;
> +}
> +
> +static void hex_encode(unsigned char *s, int len, unsigned char *o)
> +{
> +char itoa16_private[16] = "0123456789abcdef";
> +int i;
> +for (i = 0; i < len; ++i) {
> +o[0] = itoa16_private[s[i] >> 4];
> +o[1] = itoa16_private[s[i] & 15];
> +o += 2;
> +}
> +}
> +
> +#define DRM_BLOB_SIZE 56
> +
> +static int aax_parser(MOVContext *c, AVIOContext *pb)
> +{
> +unsigned char activation_bytes[4];
> +
> +// extracted from libAAX_SDK.so and AAXSDKWin.dll files!
> +unsigned char fixed_key[] = { 0x77, 0x21, 0x4d, 0x4b, 0x19, 0x6a, 0x87, 
> 0xcd,
> +  0x52, 0x00, 0x45, 0xfd, 0x20, 0xa5, 0x1d, 
> 0x67 };
> +unsigned char intermediate_key[20] = {0};
> +unsigned char intermediate_iv[20] = {0};
> +unsigned char input[64] = {0};
> +unsigned char output[64] = {0};
> +unsigned char file_checksum[20] = {0};
> +unsigned char file_checksum_encoded[41] = {0};
> +unsigned char file_key_encoded[41] = {0};
> +unsigned char file_iv_encoded[41] = {0};
> +unsigned char calculated_checksum[20];
> +struct AVHashContext *ctx;
> +struct AVAES *aes_decrypt;
> +int a, b, i;
> +const char *magic = "drm";
> +char *s;
> +
> +av_hash_alloc(&ctx, "SHA160");

If you only need sha1 then it may be a better idea to use the sha functions 
directly,
rather than the hash API. The latter is mainly meant for cases where you might 
need
more than one type of hash algorithm.
Unless you plan to use the special final() functions (To get an hex, bin, or 
base64
digest), using it for a single algorithm just adds one more layer for no real 
gain.

See libavutil/sha.h

> +aes_decrypt = av_aes_alloc();
> +if (!aes_decrypt) {
> +return AVERROR(ENOMEM);
> +}
> +
> +/* drm blob processing */
> +avio_seek(pb, 0x246, 0);
> +avio_read(pb, input, 3);
> +if (strncmp(input, magic, 3)) {
> +av_log(c->fc, AV_LOG_FATAL, "[aax] drm blob is missing from this 
> file!\n");
> +exit(-1);
> +}
> +avio_seek(pb, 0x251, 0);
> +avio_read(pb, input, DRM_BLOB_SIZE);
> +avio_seek(pb, 0x28d, 0);
> +avio_read(pb, file_checksum, 20);
> +hex_encode(file_checksum, 20, file_checksum_encoded);
> +av_log(c->fc, AV_LOG_DEBUG, "[aax] file checksum == %s\n", 
> file_checksum_encoded);
> +
> +/* extract activation data */
> +s = getenv("activation_bytes");
> +if (!s || strlen(s) < 8) {
> +av_log(c->fc, AV_LOG_FATAL, "[aax] export activation_bytes= 
> is missing!\n");
> +exit(-1); // XXX exit more gracefully
> +}
> +av_log(c->fc, AV_LOG_DEBUG, "[aax] activation_bytes == %s!\n", s);
> +for (i = 0; i < 4 && isxdigit(*s); i++) {
> +a = hexchar2int(*s++);
> +b = hexchar2int(*s++);
> +activation_bytes[i] = (a << 4) | b;
> +}
> +
> +/* AAX (and AAX+) key derivation */
> +av_hash_init(ctx);
> +av_hash_update(ctx, fixed_key, 16);
> +av_hash_update(ctx, activation_bytes, 4);
> +av_hash_final(ctx, intermediate_key);
> +av_hash_init(ctx);
> +av_hash_update(ctx, fixed_key, 16);
> +av_hash_update(ctx, intermediate_key, 20);
> +av_hash_update(ctx, activation_bytes, 4);
> +av_hash_final(ctx, intermediate_iv);
> +av_hash_init(ctx);
> +av_hash_update(ctx, intermediate_key, 16);
> +av_hash_update(ctx, intermediate_iv, 16);
> +av_hash_final(ctx, calculated_checksum);
> +if (memcmp(calculated_checksum, file_checksum, 20)) {
> +av_log(c->fc, AV_LOG_ERROR, "[aax] mismatch in checksums, 
> terminating!\n");
> +exit(-1);
> +}
> +av_aes_init(aes_decrypt, intermediate_key, 128, 1);
> +av_aes_crypt(aes_decrypt, output, input, DRM_BLOB_SIZE >> 4, 
> intermediate_iv, 1);
> +for (i = 0; i < 4; i++) {
> +if (activation_bytes[i] != output[3 - i]) {
> +av_log(c->fc, AV_LOG_ERROR, "[aax] error in drm blob decryption, 
> terminating!\n");
> +exit(-1);
> +}

[FFmpeg-devel] [PATCH v2] Add support for Audible AAX (and AAX+) files

2015-07-11 Thread Vesselin Bontchev
Hi,

alglib1.cpp is a plugin for RainbowCrack 1.6.1 
(http://project-rainbowcrack.com/), and it enables offline attacks against 
Audible AAX files.

VesselinFrom 95a40310e0eecadc5b2c653609163ec8d2682d94 Mon Sep 17 00:00:00 2001
From: Vesselin Bontchev 
Date: Sat, 11 Jul 2015 18:02:47 +
Subject: [PATCH] Add support for Audible AAX (and AAX+) files

---
 libavformat/isom.h |3 +
 libavformat/mov.c  |  163 
 2 files changed, 166 insertions(+)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 5d48989..6a054e8 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -198,6 +198,9 @@ typedef struct MOVContext {
 MOVFragmentIndex** fragment_index_data;
 unsigned fragment_index_count;
 int atom_depth;
+unsigned int aax_mode;  ///< 'aax' file has been detected
+unsigned char file_key[20];
+unsigned char file_iv[20];
 } MOVContext;
 
 int ff_mp4_read_descr_len(AVIOContext *pb);
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 6d59863..62495a8 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "libavutil/attributes.h"
 #include "libavutil/channel_layout.h"
@@ -37,6 +38,8 @@
 #include "libavutil/dict.h"
 #include "libavutil/display.h"
 #include "libavutil/opt.h"
+#include "libavutil/aes.h"
+#include "libavutil/hash.h"
 #include "libavutil/timecode.h"
 #include "libavcodec/ac3tab.h"
 #include "avformat.h"
@@ -807,6 +810,126 @@ static int mov_read_mdat(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 return 0; /* now go for moov */
 }
 
+
+static int hexchar2int(char c) {
+if (c >= '0' && c <= '9') return c - '0';
+if (c >= 'a' && c <= 'f') return c - 'a' + 10;
+if (c >= 'A' && c <= 'F') return c - 'A' + 10;
+return -1;
+}
+
+static void hex_encode(unsigned char *s, int len, unsigned char *o)
+{
+char itoa16_private[16] = "0123456789abcdef";
+int i;
+for (i = 0; i < len; ++i) {
+o[0] = itoa16_private[s[i] >> 4];
+o[1] = itoa16_private[s[i] & 15];
+o += 2;
+}
+}
+
+#define DRM_BLOB_SIZE 56
+
+static int aax_parser(MOVContext *c, AVIOContext *pb)
+{
+unsigned char activation_bytes[4];
+
+// extracted from libAAX_SDK.so and AAXSDKWin.dll files!
+unsigned char fixed_key[] = { 0x77, 0x21, 0x4d, 0x4b, 0x19, 0x6a, 0x87, 0xcd,
+  0x52, 0x00, 0x45, 0xfd, 0x20, 0xa5, 0x1d, 0x67 };
+unsigned char intermediate_key[20] = {0};
+unsigned char intermediate_iv[20] = {0};
+unsigned char input[64] = {0};
+unsigned char output[64] = {0};
+unsigned char file_checksum[20] = {0};
+unsigned char file_checksum_encoded[41] = {0};
+unsigned char file_key_encoded[41] = {0};
+unsigned char file_iv_encoded[41] = {0};
+unsigned char calculated_checksum[20];
+struct AVHashContext *ctx;
+struct AVAES *aes_decrypt;
+int a, b, i;
+const char *magic = "drm";
+char *s;
+
+av_hash_alloc(&ctx, "SHA160");
+aes_decrypt = av_aes_alloc();
+if (!aes_decrypt) {
+return AVERROR(ENOMEM);
+}
+
+/* drm blob processing */
+avio_seek(pb, 0x246, 0);
+avio_read(pb, input, 3);
+if (strncmp(input, magic, 3)) {
+av_log(c->fc, AV_LOG_FATAL, "[aax] drm blob is missing from this file!\n");
+exit(-1);
+}
+avio_seek(pb, 0x251, 0);
+avio_read(pb, input, DRM_BLOB_SIZE);
+avio_seek(pb, 0x28d, 0);
+avio_read(pb, file_checksum, 20);
+hex_encode(file_checksum, 20, file_checksum_encoded);
+av_log(c->fc, AV_LOG_DEBUG, "[aax] file checksum == %s\n", file_checksum_encoded);
+
+/* extract activation data */
+s = getenv("activation_bytes");
+if (!s || strlen(s) < 8) {
+av_log(c->fc, AV_LOG_FATAL, "[aax] export activation_bytes= is missing!\n");
+exit(-1); // XXX exit more gracefully
+}
+av_log(c->fc, AV_LOG_DEBUG, "[aax] activation_bytes == %s!\n", s);
+for (i = 0; i < 4 && isxdigit(*s); i++) {
+a = hexchar2int(*s++);
+b = hexchar2int(*s++);
+activation_bytes[i] = (a << 4) | b;
+}
+
+/* AAX (and AAX+) key derivation */
+av_hash_init(ctx);
+av_hash_update(ctx, fixed_key, 16);
+av_hash_update(ctx, activation_bytes, 4);
+av_hash_final(ctx, intermediate_key);
+av_hash_init(ctx);
+av_hash_update(ctx, fixed_key, 16);
+av_hash_update(ctx, intermediate_key, 20);
+av_hash_update(ctx, activation_bytes, 4);
+av_hash_final(ctx, intermediate_iv);
+av_hash_init(ctx);
+av_hash_update(ctx, intermediate_key, 16);
+av_hash_update(ctx, intermediate_iv, 16);
+av_hash_final(ctx, calculated_checksum);
+if (memcmp(calculated_checksum, file_checksum, 20)) {
+av_log(c->fc, AV_LOG_ERROR, "[aax] mismatch in checksums, terminating!\n");
+exit(-1);
+}
+av_aes_init(aes_decrypt, intermediate_key, 128, 1);
+av_aes_crypt(aes_decrypt, output, input, DRM_BL

Re: [FFmpeg-devel] [PATCH v2] Add support for Audible AAX (and AAX+) files

2015-07-11 Thread compn
On Sun, 12 Jul 2015 05:38:37 +0300
Vesselin Bontchev  wrote:

> Hi,
> 
> alglib1.cpp is a plugin for RainbowCrack 1.6.1
> (http://project-rainbowcrack.com/), and it enables offline attacks
> against Audible AAX files.

does it work on our single audible sample?

http://samples.ffmpeg.org/audible/2004FirstPresidentialDebateBushvs.Kerry93004_acelp85_maihde.aa

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


Re: [FFmpeg-devel] GSoC Weely report (libswscale)

2015-07-11 Thread Michael Niedermayer
On Sat, Jul 11, 2015 at 04:57:22PM -0300, Pedro Arthur wrote:
> Here is the full patch rebased including all previous changes.

if you build ffmpeg with --assert-level=2

fails fate
for example in fate-vsynth1-cinepak

its probably best to always build with --assert-level=2
so you wont miss such failures

--- ./tests/ref/vsynth/vsynth1-cinepak  2015-07-11 12:25:01.268257903 +0200
+++ tests/data/fate/vsynth1-cinepak 2015-07-12 04:11:06.041453781 +0200
@@ -1,4 +0,0 @@
-546c7c1069f9e418aa787f469b693b94 *tests/data/fate/vsynth1-cinepak.mov
-99465 tests/data/fate/vsynth1-cinepak.mov
-bee091c200262be3427a233a2812388c *tests/data/fate/vsynth1-cinepak.out.rawvideo
-stddev:8.46 PSNR: 29.58 MAXDIFF:  105 bytes:  7603200/   456192

Assertion lumSrcPtr + vLumFilterSize - 1 < (const int16_t **)lumPixBuf + 
vLumBufSize * 2 failed at libswscale/swscale.c:694

there are also many other fate tests which fail with --assert-level=2

also it might make more sense to stash all these commits together
for submission,
if you like you could keep them seperate in your branch (could make
sense for debug/bisect)

but the commits showing the step wise development are rather hard to
review and would be impossible to push to master git
commits for master git should not introduce known issues that are
fixed in later commits and should be split in selfcontained changesets

a single stashed together patch should be fine and easy to generate

thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Avoid a single point of failure, be that a person or equipment.


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


Re: [FFmpeg-devel] [PATCH] avfilter/vf_stereo3d: implement slice threading

2015-07-11 Thread Michael Niedermayer
On Thu, Jul 09, 2015 at 07:19:16PM +, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/vf_stereo3d.c | 72 
> ---
>  1 file changed, 49 insertions(+), 23 deletions(-)

i removed the vframes limit from fate and updated checksums

time make THREADS=12 fate-filter-stereo3d

with patch:
real0m1.486s
user0m1.448s
sys 0m0.260s

without patch:
real0m1.653s
user0m1.288s
sys 0m0.220s


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

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle


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


[FFmpeg-devel] [PATCH] vf_ssim: x86 simd for ssim_4x4xN and ssim_endN.

2015-07-11 Thread Ronald S. Bultje
Both are 2-2.5x faster than their C counterpart.
---
 libavfilter/ssim.h |  36 
 libavfilter/vf_ssim.c  |  26 --
 libavfilter/x86/Makefile   |   2 +
 libavfilter/x86/vf_ssim.asm| 191 +
 libavfilter/x86/vf_ssim_init.c |  38 
 5 files changed, 284 insertions(+), 9 deletions(-)
 create mode 100644 libavfilter/ssim.h
 create mode 100644 libavfilter/x86/vf_ssim.asm
 create mode 100644 libavfilter/x86/vf_ssim_init.c

diff --git a/libavfilter/ssim.h b/libavfilter/ssim.h
new file mode 100644
index 000..cd3a6ee
--- /dev/null
+++ b/libavfilter/ssim.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2015 Ronald S. Bultje 
+ *
+ * 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
+ */
+
+#ifndef LIBAVFILTER_SSIM_H
+#define LIBAVFILTER_SSIM_H
+
+#include 
+#include 
+
+typedef struct SSIMDSPContext {
+void (*ssim_4x4_line)(const uint8_t *buf, ptrdiff_t buf_stride,
+  const uint8_t *ref, ptrdiff_t ref_stride,
+  int (*sums)[4], int w);
+float (*ssim_end_line)(const int (*sum0)[4], const int (*sum1)[4], int w);
+} SSIMDSPContext;
+
+void ff_ssim_init_x86(SSIMDSPContext *dsp);
+
+#endif /* LIBAVFILTER_SSIM_H */
diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c
index f7a259e..b5a61ee 100644
--- a/libavfilter/vf_ssim.c
+++ b/libavfilter/vf_ssim.c
@@ -42,6 +42,7 @@
 #include "drawutils.h"
 #include "formats.h"
 #include "internal.h"
+#include "ssim.h"
 #include "video.h"
 
 typedef struct SSIMContext {
@@ -59,6 +60,7 @@ typedef struct SSIMContext {
 int planeheight[4];
 int *temp;
 int is_rgb;
+SSIMDSPContext dsp;
 } SSIMContext;
 
 #define OFFSET(x) offsetof(SSIMContext, x)
@@ -85,8 +87,8 @@ static void set_meta(AVDictionary **metadata, const char 
*key, char comp, float
 }
 }
 
-static void ssim_4x4xn(const uint8_t *main, int main_stride,
-   const uint8_t *ref, int ref_stride,
+static void ssim_4x4xn(const uint8_t *main, ptrdiff_t main_stride,
+   const uint8_t *ref, ptrdiff_t ref_stride,
int (*sums)[4], int width)
 {
 int x, y, z;
@@ -132,7 +134,7 @@ static float ssim_end1(int s1, int s2, int ss, int s12)
  / ((float)(fs1 * fs1 + fs2 * fs2 + ssim_c1) * (float)(vars + 
ssim_c2));
 }
 
-static float ssim_endn(int (*sum0)[4], int (*sum1)[4], int width)
+static float ssim_endn(const int (*sum0)[4], const int (*sum1)[4], int width)
 {
 float ssim = 0.0;
 int i;
@@ -145,7 +147,8 @@ static float ssim_endn(int (*sum0)[4], int (*sum1)[4], int 
width)
 return ssim;
 }
 
-static float ssim_plane(uint8_t *main, int main_stride,
+static float ssim_plane(SSIMDSPContext *dsp,
+uint8_t *main, int main_stride,
 uint8_t *ref, int ref_stride,
 int width, int height, void *temp)
 {
@@ -160,12 +163,12 @@ static float ssim_plane(uint8_t *main, int main_stride,
 for (y = 1; y < height; y++) {
 for (; z <= y; z++) {
 FFSWAP(void*, sum0, sum1);
-ssim_4x4xn(&main[4 * z * main_stride], main_stride,
-   &ref[4 * z * ref_stride], ref_stride,
-   sum0, width);
+dsp->ssim_4x4_line(&main[4 * z * main_stride], main_stride,
+   &ref[4 * z * ref_stride], ref_stride,
+   sum0, width);
 }
 
-ssim += ssim_endn(sum0, sum1, width - 1);
+ssim += dsp->ssim_end_line(sum0, sum1, width - 1);
 }
 
 return ssim / ((height - 1) * (width - 1));
@@ -187,7 +190,7 @@ static AVFrame *do_ssim(AVFilterContext *ctx, AVFrame *main,
 s->nb_frames++;
 
 for (i = 0; i < s->nb_components; i++) {
-c[i] = ssim_plane(main->data[i], main->linesize[i],
+c[i] = ssim_plane(&s->dsp, main->data[i], main->linesize[i],
   ref->data[i], ref->linesize[i],
   s->planewidth[i], s->planeheight[i], s->temp);
 ssimv += s->coefs[i] * c[i];
@@ -294,6 +297,11 @@ static int config_input_ref(AVFilterLink *inlink)
 if (!s->temp)
 return AVERROR(ENOMEM);
 
+s->dsp.ssim_4x4_line = ssim_4x4xn;
+s->dsp.ssim_end_li

Re: [FFmpeg-devel] [PATCH] avformat/brstm: Remove unused variable

2015-07-11 Thread Michael Niedermayer
On Fri, Jul 10, 2015 at 04:35:44PM +0200, Michael Niedermayer wrote:
> From: Michael Niedermayer 
> 
> Fixes "libavformat/brstm.c:128:35: warning: variable info_size set but not 
> used"
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/brstm.c |4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

applied

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

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable


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


Re: [FFmpeg-devel] [PATCH] avcodec_free_context instead of close+av_free

2015-07-11 Thread Michael Niedermayer
On Sat, Jul 11, 2015 at 05:24:02PM +, Lectem wrote:
> If I understood the source and documentation correctly, avcodec_free_context 
> should now be used to free a context instead of avcodec_close + av_free.
> ---
>  doc/examples/decoding_encoding.c | 14 +-
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/doc/examples/decoding_encoding.c 
> b/doc/examples/decoding_encoding.c
> index f6643f6..e257501 100644
> --- a/doc/examples/decoding_encoding.c
> +++ b/doc/examples/decoding_encoding.c
> @@ -232,8 +232,7 @@ static void audio_encode_example(const char *filename)
>  
>  av_freep(&samples);
>  av_frame_free(&frame);
> -avcodec_close(c);
> -av_free(c);
> +avcodec_free_context(c);

avcodec_close takes a AVCodecContext pointer
avcodec_free_context takes a  AVCodecContext pointer to pointer

make sure you test code before submitting it, make sure you correct
every new compiler warning

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

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data


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


Re: [FFmpeg-devel] [PATCH] fate: add tests for stereo3d anaglyph modes

2015-07-11 Thread Michael Niedermayer
On Sat, Jul 11, 2015 at 11:08:28PM +, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  tests/fate/filter-video.mak  | 43 
> 
>  tests/ref/fate/filter-stereo3d-sbsl-agmc |  6 +
>  tests/ref/fate/filter-stereo3d-sbsl-agmd |  6 +
>  tests/ref/fate/filter-stereo3d-sbsl-agmg |  6 +
>  tests/ref/fate/filter-stereo3d-sbsl-agmh |  6 +
>  tests/ref/fate/filter-stereo3d-sbsl-arbg |  6 +
>  tests/ref/fate/filter-stereo3d-sbsl-arcc |  6 +
>  tests/ref/fate/filter-stereo3d-sbsl-arcd |  6 +
>  tests/ref/fate/filter-stereo3d-sbsl-arcg |  6 +
>  tests/ref/fate/filter-stereo3d-sbsl-arch |  6 +
>  tests/ref/fate/filter-stereo3d-sbsl-argg |  6 +
>  tests/ref/fate/filter-stereo3d-sbsl-aybc |  6 +
>  tests/ref/fate/filter-stereo3d-sbsl-aybd |  6 +
>  tests/ref/fate/filter-stereo3d-sbsl-aybg |  6 +
>  tests/ref/fate/filter-stereo3d-sbsl-aybh |  6 +
>  15 files changed, 127 insertions(+)
>  create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-agmc
>  create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-agmd
>  create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-agmg
>  create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-agmh
>  create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-arbg
>  create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-arcc
>  create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-arcd
>  create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-arcg
>  create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-arch
>  create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-argg
>  create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-aybc
>  create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-aybd
>  create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-aybg
>  create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-aybh

LGTM

thx

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

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 


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


[FFmpeg-devel] [PATCH 4/4] vf_ssim: x86 simd for ssim_4x4xN and ssim_endN.

2015-07-11 Thread Ronald S. Bultje
Both are 2-2.5x faster than their C counterpart.
---
 libavfilter/ssim.h |  36 
 libavfilter/vf_ssim.c  |  26 --
 libavfilter/x86/Makefile   |   2 +
 libavfilter/x86/vf_ssim.asm| 190 +
 libavfilter/x86/vf_ssim_init.c |  38 +
 5 files changed, 283 insertions(+), 9 deletions(-)
 create mode 100644 libavfilter/ssim.h
 create mode 100644 libavfilter/x86/vf_ssim.asm
 create mode 100644 libavfilter/x86/vf_ssim_init.c

diff --git a/libavfilter/ssim.h b/libavfilter/ssim.h
new file mode 100644
index 000..cd3a6ee
--- /dev/null
+++ b/libavfilter/ssim.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2015 Ronald S. Bultje 
+ *
+ * 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
+ */
+
+#ifndef LIBAVFILTER_SSIM_H
+#define LIBAVFILTER_SSIM_H
+
+#include 
+#include 
+
+typedef struct SSIMDSPContext {
+void (*ssim_4x4_line)(const uint8_t *buf, ptrdiff_t buf_stride,
+  const uint8_t *ref, ptrdiff_t ref_stride,
+  int (*sums)[4], int w);
+float (*ssim_end_line)(const int (*sum0)[4], const int (*sum1)[4], int w);
+} SSIMDSPContext;
+
+void ff_ssim_init_x86(SSIMDSPContext *dsp);
+
+#endif /* LIBAVFILTER_SSIM_H */
diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c
index f7a259e..b5a61ee 100644
--- a/libavfilter/vf_ssim.c
+++ b/libavfilter/vf_ssim.c
@@ -42,6 +42,7 @@
 #include "drawutils.h"
 #include "formats.h"
 #include "internal.h"
+#include "ssim.h"
 #include "video.h"
 
 typedef struct SSIMContext {
@@ -59,6 +60,7 @@ typedef struct SSIMContext {
 int planeheight[4];
 int *temp;
 int is_rgb;
+SSIMDSPContext dsp;
 } SSIMContext;
 
 #define OFFSET(x) offsetof(SSIMContext, x)
@@ -85,8 +87,8 @@ static void set_meta(AVDictionary **metadata, const char 
*key, char comp, float
 }
 }
 
-static void ssim_4x4xn(const uint8_t *main, int main_stride,
-   const uint8_t *ref, int ref_stride,
+static void ssim_4x4xn(const uint8_t *main, ptrdiff_t main_stride,
+   const uint8_t *ref, ptrdiff_t ref_stride,
int (*sums)[4], int width)
 {
 int x, y, z;
@@ -132,7 +134,7 @@ static float ssim_end1(int s1, int s2, int ss, int s12)
  / ((float)(fs1 * fs1 + fs2 * fs2 + ssim_c1) * (float)(vars + 
ssim_c2));
 }
 
-static float ssim_endn(int (*sum0)[4], int (*sum1)[4], int width)
+static float ssim_endn(const int (*sum0)[4], const int (*sum1)[4], int width)
 {
 float ssim = 0.0;
 int i;
@@ -145,7 +147,8 @@ static float ssim_endn(int (*sum0)[4], int (*sum1)[4], int 
width)
 return ssim;
 }
 
-static float ssim_plane(uint8_t *main, int main_stride,
+static float ssim_plane(SSIMDSPContext *dsp,
+uint8_t *main, int main_stride,
 uint8_t *ref, int ref_stride,
 int width, int height, void *temp)
 {
@@ -160,12 +163,12 @@ static float ssim_plane(uint8_t *main, int main_stride,
 for (y = 1; y < height; y++) {
 for (; z <= y; z++) {
 FFSWAP(void*, sum0, sum1);
-ssim_4x4xn(&main[4 * z * main_stride], main_stride,
-   &ref[4 * z * ref_stride], ref_stride,
-   sum0, width);
+dsp->ssim_4x4_line(&main[4 * z * main_stride], main_stride,
+   &ref[4 * z * ref_stride], ref_stride,
+   sum0, width);
 }
 
-ssim += ssim_endn(sum0, sum1, width - 1);
+ssim += dsp->ssim_end_line(sum0, sum1, width - 1);
 }
 
 return ssim / ((height - 1) * (width - 1));
@@ -187,7 +190,7 @@ static AVFrame *do_ssim(AVFilterContext *ctx, AVFrame *main,
 s->nb_frames++;
 
 for (i = 0; i < s->nb_components; i++) {
-c[i] = ssim_plane(main->data[i], main->linesize[i],
+c[i] = ssim_plane(&s->dsp, main->data[i], main->linesize[i],
   ref->data[i], ref->linesize[i],
   s->planewidth[i], s->planeheight[i], s->temp);
 ssimv += s->coefs[i] * c[i];
@@ -294,6 +297,11 @@ static int config_input_ref(AVFilterLink *inlink)
 if (!s->temp)
 return AVERROR(ENOMEM);
 
+s->dsp.ssim_4x4_line = ssim_4x4xn;
+s->dsp.ssim_end_l

[FFmpeg-devel] [PATCH 3/4] vf_ssim: remove another obscure double loop.

2015-07-11 Thread Ronald S. Bultje
---
 libavfilter/vf_ssim.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c
index b1c3368..f7a259e 100644
--- a/libavfilter/vf_ssim.c
+++ b/libavfilter/vf_ssim.c
@@ -85,13 +85,13 @@ static void set_meta(AVDictionary **metadata, const char 
*key, char comp, float
 }
 }
 
-static void ssim_4x4x2_core(const uint8_t *main, int main_stride,
-const uint8_t *ref, int ref_stride,
-int sums[2][4])
+static void ssim_4x4xn(const uint8_t *main, int main_stride,
+   const uint8_t *ref, int ref_stride,
+   int (*sums)[4], int width)
 {
 int x, y, z;
 
-for (z = 0; z < 2; z++) {
+for (z = 0; z < width; z++) {
 uint32_t s1 = 0, s2 = 0, ss = 0, s12 = 0;
 
 for (y = 0; y < 4; y++) {
@@ -149,8 +149,7 @@ static float ssim_plane(uint8_t *main, int main_stride,
 uint8_t *ref, int ref_stride,
 int width, int height, void *temp)
 {
-int z = 0;
-int x, y;
+int z = 0, y;
 float ssim = 0.0;
 int (*sum0)[4] = temp;
 int (*sum1)[4] = sum0 + (width >> 2) + 3;
@@ -161,10 +160,9 @@ static float ssim_plane(uint8_t *main, int main_stride,
 for (y = 1; y < height; y++) {
 for (; z <= y; z++) {
 FFSWAP(void*, sum0, sum1);
-for (x = 0; x < width; x+=2)
-ssim_4x4x2_core(&main[4 * (x + z * main_stride)], main_stride,
-&ref[4 * (x + z * ref_stride)], ref_stride,
-&sum0[x]);
+ssim_4x4xn(&main[4 * z * main_stride], main_stride,
+   &ref[4 * z * ref_stride], ref_stride,
+   sum0, width);
 }
 
 ssim += ssim_endn(sum0, sum1, width - 1);
-- 
2.1.2

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


[FFmpeg-devel] [PATCH 2/4] vf_ssim: fix s->coefs for yuv with non-4:2:0 subsampling.

2015-07-11 Thread Ronald S. Bultje
---
 libavfilter/vf_ssim.c | 81 +++
 1 file changed, 37 insertions(+), 44 deletions(-)

diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c
index 3ef122f..b1c3368 100644
--- a/libavfilter/vf_ssim.c
+++ b/libavfilter/vf_ssim.c
@@ -34,6 +34,7 @@
  * Caculate the SSIM between two input videos.
  */
 
+#include "libavutil/avstring.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
@@ -50,13 +51,14 @@ typedef struct SSIMContext {
 char *stats_file_str;
 int nb_components;
 uint64_t nb_frames;
-double ssim[4];
+double ssim[4], ssim_total;
 char comps[4];
-int *coefs;
+float coefs[4];
 uint8_t rgba_map[4];
 int planewidth[4];
 int planeheight[4];
 int *temp;
+int is_rgb;
 } SSIMContext;
 
 #define OFFSET(x) offsetof(SSIMContext, x)
@@ -70,10 +72,6 @@ static const AVOption ssim_options[] = {
 
 AVFILTER_DEFINE_CLASS(ssim);
 
-static const int rgb_coefs[4]  = { 1, 1, 1, 3};
-static const int yuv_coefs[4]  = { 4, 1, 1, 6};
-static const int gray_coefs[4] = { 1, 0, 0, 1};
-
 static void set_meta(AVDictionary **metadata, const char *key, char comp, 
float d)
 {
 char value[128];
@@ -185,37 +183,38 @@ static AVFrame *do_ssim(AVFilterContext *ctx, AVFrame 
*main,
 {
 AVDictionary **metadata = avpriv_frame_get_metadatap(main);
 SSIMContext *s = ctx->priv;
-float c[4], ssimv;
+float c[4], ssimv = 0.0;
 int i;
 
 s->nb_frames++;
 
-for (i = 0; i < s->nb_components; i++)
+for (i = 0; i < s->nb_components; i++) {
 c[i] = ssim_plane(main->data[i], main->linesize[i],
   ref->data[i], ref->linesize[i],
   s->planewidth[i], s->planeheight[i], s->temp);
-
-ssimv = (c[0] * s->coefs[0] + c[1] * s->coefs[1] + c[2] * s->coefs[2]) / 
s->coefs[3];
-
-for (i = 0; i < s->nb_components; i++)
-set_meta(metadata, "lavfi.ssim.", s->comps[i], c[i]);
+ssimv += s->coefs[i] * c[i];
+s->ssim[i] += c[i];
+}
+for (i = 0; i < s->nb_components; i++) {
+int cidx = s->is_rgb ? s->rgba_map[i] : i;
+set_meta(metadata, "lavfi.ssim.", s->comps[i], c[cidx]);
+}
+s->ssim_total += ssimv;
 
 set_meta(metadata, "lavfi.ssim.All", 0, ssimv);
-set_meta(metadata, "lavfi.ssim.dB", 0, ssim_db(c[0] * s->coefs[0] + c[1] * 
s->coefs[1] + c[2] * s->coefs[2], s->coefs[3]));
+set_meta(metadata, "lavfi.ssim.dB", 0, ssim_db(ssimv, 1.0));
 
 if (s->stats_file) {
 fprintf(s->stats_file, "n:%"PRId64" ", s->nb_frames);
 
-for (i = 0; i < s->nb_components; i++)
-fprintf(s->stats_file, "%c:%f ", s->comps[i], c[i]);
+for (i = 0; i < s->nb_components; i++) {
+int cidx = s->is_rgb ? s->rgba_map[i] : i;
+fprintf(s->stats_file, "%c:%f ", s->comps[i], c[cidx]);
+}
 
-fprintf(s->stats_file, "All:%f (%f)\n", ssimv, ssim_db(c[0] * 
s->coefs[0] + c[1] * s->coefs[1] + c[2] * s->coefs[2], s->coefs[3]));
+fprintf(s->stats_file, "All:%f (%f)\n", ssimv, ssim_db(ssimv, 1.0));
 }
 
-s->ssim[0] += c[0];
-s->ssim[1] += c[1];
-s->ssim[2] += c[2];
-
 return main;
 }
 
@@ -264,7 +263,7 @@ static int config_input_ref(AVFilterLink *inlink)
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
 AVFilterContext *ctx  = inlink->dst;
 SSIMContext *s = ctx->priv;
-int is_rgb;
+int sum = 0, i;
 
 s->nb_components = desc->nb_components;
 
@@ -278,24 +277,20 @@ static int config_input_ref(AVFilterLink *inlink)
 return AVERROR(EINVAL);
 }
 
-is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0;
-s->comps[0] = is_rgb ? 'R' : 'Y';
-s->comps[1] = is_rgb ? 'G' : 'U';
-s->comps[2] = is_rgb ? 'B' : 'V';
+s->is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0;
+s->comps[0] = s->is_rgb ? 'R' : 'Y';
+s->comps[1] = s->is_rgb ? 'G' : 'U';
+s->comps[2] = s->is_rgb ? 'B' : 'V';
 s->comps[3] = 'A';
 
-if (is_rgb) {
-s->coefs = rgb_coefs;
-} else if (s->nb_components == 1) {
-s->coefs = gray_coefs;
-} else {
-s->coefs = yuv_coefs;
-}
-
 s->planeheight[1] = s->planeheight[2] = FF_CEIL_RSHIFT(inlink->h, 
desc->log2_chroma_h);
 s->planeheight[0] = s->planeheight[3] = inlink->h;
 s->planewidth[1]  = s->planewidth[2]  = FF_CEIL_RSHIFT(inlink->w, 
desc->log2_chroma_w);
 s->planewidth[0]  = s->planewidth[3]  = inlink->w;
+for (i = 0; i < s->nb_components; i++)
+sum += s->planeheight[i] * s->planewidth[i];
+for (i = 0; i < s->nb_components; i++)
+s->coefs[i] = (double) s->planeheight[i] * s->planewidth[i] / sum;
 
 s->temp = av_malloc((2 * inlink->w + 12) * sizeof(*s->temp));
 if (!s->temp)
@@ -340,17 +335,15 @@ static av_cold void uninit(AVFilterContext *ctx)
 SSIMContext *s = ctx->priv;
 
 if (s->nb_frames > 0) {
-if (s

[FFmpeg-devel] [PATCH 1/4] ssim: refactor a weird double loop.

2015-07-11 Thread Ronald S. Bultje
---
 libavfilter/vf_ssim.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_ssim.c b/libavfilter/vf_ssim.c
index 0721ddd..3ef122f 100644
--- a/libavfilter/vf_ssim.c
+++ b/libavfilter/vf_ssim.c
@@ -134,7 +134,7 @@ static float ssim_end1(int s1, int s2, int ss, int s12)
  / ((float)(fs1 * fs1 + fs2 * fs2 + ssim_c1) * (float)(vars + 
ssim_c2));
 }
 
-static float ssim_end4(int sum0[5][4], int sum1[5][4], int width)
+static float ssim_endn(int (*sum0)[4], int (*sum1)[4], int width)
 {
 float ssim = 0.0;
 int i;
@@ -169,8 +169,7 @@ static float ssim_plane(uint8_t *main, int main_stride,
 &sum0[x]);
 }
 
-for (x = 0; x < width - 1; x += 4)
-ssim += ssim_end4(sum0 + x, sum1 + x, FFMIN(4, width - x - 1));
+ssim += ssim_endn(sum0, sum1, width - 1);
 }
 
 return ssim / ((height - 1) * (width - 1));
-- 
2.1.2

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


[FFmpeg-devel] [PATCH] fate: add tests for stereo3d anaglyph modes

2015-07-11 Thread Paul B Mahol
See attached.


0001-fate-add-tests-for-stereo3d-anaglyph-modes.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] fate: add tests for stereo3d anaglyph modes

2015-07-11 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 tests/fate/filter-video.mak  | 43 
 tests/ref/fate/filter-stereo3d-sbsl-agmc |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-agmd |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-agmg |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-agmh |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-arbg |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-arcc |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-arcd |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-arcg |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-arch |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-argg |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-aybc |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-aybd |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-aybg |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-aybh |  6 +
 15 files changed, 127 insertions(+)
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-agmc
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-agmd
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-agmg
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-agmh
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-arbg
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-arcc
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-arcd
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-arcg
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-arch
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-argg
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-aybc
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-aybd
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-aybg
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-aybh

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 76fa0f2..e8e9d78 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -393,6 +393,49 @@ fate-filter-stereo3d-sbsl-al: CMD = framecrc -c:v pgmyuv 
-i $(SRC) -vframes 5 -f
 FATE_STEREO3D += fate-filter-stereo3d-sbsl-sbsr
 fate-filter-stereo3d-sbsl-sbsr: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:sbsr
 
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-agmc
+fate-filter-stereo3d-sbsl-agmc: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:agmc
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-agmd
+fate-filter-stereo3d-sbsl-agmd: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:agmd
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-agmg
+fate-filter-stereo3d-sbsl-agmg: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:agmg
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-agmh
+fate-filter-stereo3d-sbsl-agmh: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:agmh
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-arbg
+fate-filter-stereo3d-sbsl-arbg: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:arbg
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-arcc
+fate-filter-stereo3d-sbsl-arcc: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:arcc
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-arcd
+fate-filter-stereo3d-sbsl-arcd: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:arcd
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-arcg
+fate-filter-stereo3d-sbsl-arcg: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:arcg
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-arch
+fate-filter-stereo3d-sbsl-arch: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:arch
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-argg
+fate-filter-stereo3d-sbsl-argg: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:argg
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-aybc
+fate-filter-stereo3d-sbsl-aybc: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:aybc
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-aybd
+fate-filter-stereo3d-sbsl-aybd: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:aybd
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-aybg
+fate-filter-stereo3d-sbsl-aybg: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:aybg
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-aybh
+fate-filter-stereo3d-sbsl-aybh: 

[FFmpeg-devel] [PATCH] fate: add tests for stereo3d anaglyph modes

2015-07-11 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 tests/fate/filter-video.mak  | 43 
 tests/ref/fate/filter-stereo3d-sbsl-agmc |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-agmd |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-agmg |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-agmh |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-arbg |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-arcc |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-arcd |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-arcg |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-arch |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-argg |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-aybc |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-aybd |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-aybg |  6 +
 tests/ref/fate/filter-stereo3d-sbsl-aybh |  6 +
 15 files changed, 127 insertions(+)
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-agmc
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-agmd
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-agmg
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-agmh
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-arbg
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-arcc
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-arcd
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-arcg
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-arch
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-argg
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-aybc
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-aybd
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-aybg
 create mode 100644 tests/ref/fate/filter-stereo3d-sbsl-aybh

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 76fa0f2..e8e9d78 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -393,6 +393,49 @@ fate-filter-stereo3d-sbsl-al: CMD = framecrc -c:v pgmyuv 
-i $(SRC) -vframes 5 -f
 FATE_STEREO3D += fate-filter-stereo3d-sbsl-sbsr
 fate-filter-stereo3d-sbsl-sbsr: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:sbsr
 
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-agmc
+fate-filter-stereo3d-sbsl-agmc: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:agmc
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-agmd
+fate-filter-stereo3d-sbsl-agmd: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:agmd
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-agmg
+fate-filter-stereo3d-sbsl-agmg: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:agmg
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-agmh
+fate-filter-stereo3d-sbsl-agmh: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:agmh
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-arbg
+fate-filter-stereo3d-sbsl-arbg: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:arbg
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-arcc
+fate-filter-stereo3d-sbsl-arcc: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:arcc
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-arcd
+fate-filter-stereo3d-sbsl-arcd: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:arcd
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-arcg
+fate-filter-stereo3d-sbsl-arcg: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:arcg
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-arch
+fate-filter-stereo3d-sbsl-arch: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:arch
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-argg
+fate-filter-stereo3d-sbsl-argg: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:argg
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-aybc
+fate-filter-stereo3d-sbsl-aybc: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:aybc
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-aybd
+fate-filter-stereo3d-sbsl-aybd: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:aybd
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-aybg
+fate-filter-stereo3d-sbsl-aybg: CMD = framecrc -c:v pgmyuv -i $(SRC) -vframes 
5 -flags +bitexact -sws_flags +accurate_rnd+bitexact -vf stereo3d=sbsl:aybg
+
+FATE_STEREO3D += fate-filter-stereo3d-sbsl-aybh
+fate-filter-stereo3d-sbsl-aybh: 

[FFmpeg-devel] [PATCH] Factor duplicated ff_fast_malloc() out into mem_internal.h

2015-07-11 Thread Michael Niedermayer
From: Michael Niedermayer 

internal.h is difficult to use due to circular dependancies
mem.h is a public header ff_* is not public
Alternative solutions probably are possible too

Signed-off-by: Michael Niedermayer 
---
 libavcodec/utils.c   |   20 +---
 libavutil/mem.c  |   18 ++
 libavutil/mem_internal.h |   42 ++
 3 files changed, 45 insertions(+), 35 deletions(-)
 create mode 100644 libavutil/mem_internal.h

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index fb5a72f..f3449031 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -36,6 +36,7 @@
 #include "libavutil/frame.h"
 #include "libavutil/internal.h"
 #include "libavutil/mathematics.h"
+#include "libavutil/mem_internal.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/samplefmt.h"
@@ -122,25 +123,6 @@ static int volatile entangled_thread_counter = 0;
 static void *codec_mutex;
 static void *avformat_mutex;
 
-static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t 
min_size, int zero_realloc)
-{
-void *val;
-
-memcpy(&val, ptr, sizeof(val));
-if (min_size <= *size) {
-av_assert0(val || !min_size);
-return 0;
-}
-min_size = FFMAX(min_size + min_size / 16 + 32, min_size);
-av_freep(ptr);
-val = zero_realloc ? av_mallocz(min_size) : av_malloc(min_size);
-memcpy(ptr, &val, sizeof(val));
-if (!val)
-min_size = 0;
-*size = min_size;
-return 1;
-}
-
 void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
 {
 uint8_t **p = ptr;
diff --git a/libavutil/mem.c b/libavutil/mem.c
index d828ccc..323b183 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -59,6 +59,8 @@ void  free(void *ptr);
 
 #endif /* MALLOC_PREFIX */
 
+#include "mem_internal.h"
+
 #define ALIGN (HAVE_AVX ? 32 : 16)
 
 /* NOTE: if you want to override these functions with your own
@@ -494,22 +496,6 @@ void *av_fast_realloc(void *ptr, unsigned int *size, 
size_t min_size)
 return ptr;
 }
 
-static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t 
min_size, int zero_realloc)
-{
-void *val;
-
-if (min_size < *size)
-return 0;
-min_size = FFMAX(min_size + min_size / 16 + 32, min_size);
-av_freep(ptr);
-val = zero_realloc ? av_mallocz(min_size) : av_malloc(min_size);
-memcpy(ptr, &val, sizeof(val));
-if (!val)
-min_size = 0;
-*size = min_size;
-return 1;
-}
-
 void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
 {
 ff_fast_malloc(ptr, size, min_size, 0);
diff --git a/libavutil/mem_internal.h b/libavutil/mem_internal.h
new file mode 100644
index 000..54e14ac
--- /dev/null
+++ b/libavutil/mem_internal.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2002 Fabrice Bellard
+ *
+ * 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
+ */
+
+#ifndef AVUTIL_MEM_INTERNAL_H
+#define AVUTIL_MEM_INTERNAL_H
+
+static inline int ff_fast_malloc(void *ptr, unsigned int *size, size_t 
min_size, int zero_realloc)
+{
+void *val;
+
+memcpy(&val, ptr, sizeof(val));
+if (min_size <= *size) {
+av_assert0(val || !min_size);
+return 0;
+}
+min_size = FFMAX(min_size + min_size / 16 + 32, min_size);
+av_freep(ptr);
+val = zero_realloc ? av_mallocz(min_size) : av_malloc(min_size);
+memcpy(ptr, &val, sizeof(val));
+if (!val)
+min_size = 0;
+*size = min_size;
+return 1;
+}
+#endif /* AVUTIL_MEM_INTERNAL_H */
-- 
1.7.9.5

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


Re: [FFmpeg-devel] [PATCH] Add support for Audible AAX (and AAX+) files

2015-07-11 Thread Carl Eugen Hoyos
Vesselin Bontchev  yandex.com> writes:

> +// AAX (and AAX+) support is licensed under GPLv3

I believe this is not acceptable inside an existing 
demuxer.
Please add your code under LGPL v2 or later.

+static unsigned int aax_mode = 0;
+static unsigned char file_key[20];
+static unsigned char file_iv[20];
+static struct AVAES *aes_decrypt;

You have to add this to the (mov) context.

Carl Eugen

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


Re: [FFmpeg-devel] [PATCH] Add support for Audible AAX (and AAX+) files

2015-07-11 Thread Paul B Mahol
On 7/11/15, Vesselin Bontchev  wrote:
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

You will need to add CONFIG_GPLV3 around your added code, which is ugly.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avfilter/vf_w3fdif: implement slice threading

2015-07-11 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/vf_w3fdif.c | 67 -
 1 file changed, 49 insertions(+), 18 deletions(-)

diff --git a/libavfilter/vf_w3fdif.c b/libavfilter/vf_w3fdif.c
index bb0316b..bbd8db0 100644
--- a/libavfilter/vf_w3fdif.c
+++ b/libavfilter/vf_w3fdif.c
@@ -40,7 +40,8 @@ typedef struct W3FDIFContext {
 int eof;
 int nb_planes;
 AVFrame *prev, *cur, *next;  ///< previous, current, next frames
-int32_t *work_line;   ///< line we are calculating
+int32_t **work_line;  ///< lines we are calculating
+int nb_threads;
 } W3FDIFContext;
 
 #define OFFSET(x) offsetof(W3FDIFContext, x)
@@ -82,9 +83,10 @@ static int query_formats(AVFilterContext *ctx)
 
 static int config_input(AVFilterLink *inlink)
 {
-W3FDIFContext *s = inlink->dst->priv;
+AVFilterContext *ctx = inlink->dst;
+W3FDIFContext *s = ctx->priv;
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
-int ret;
+int ret, i;
 
 if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, 
inlink->w)) < 0)
 return ret;
@@ -93,10 +95,17 @@ static int config_input(AVFilterLink *inlink)
 s->planeheight[0] = s->planeheight[3] = inlink->h;
 
 s->nb_planes = av_pix_fmt_count_planes(inlink->format);
-s->work_line = av_calloc(s->linesize[0], sizeof(*s->work_line));
+s->nb_threads = ctx->graph->nb_threads;
+s->work_line = av_calloc(s->nb_threads, sizeof(*s->work_line));
 if (!s->work_line)
 return AVERROR(ENOMEM);
 
+for (i = 0; i < s->nb_threads; i++) {
+s->work_line[i] = av_calloc(s->linesize[0], sizeof(*s->work_line[0]));
+if (!s->work_line[i])
+return AVERROR(ENOMEM);
+}
+
 return 0;
 }
 
@@ -128,11 +137,20 @@ static const int8_t   n_coef_hf[2] = { 3, 5 };
 static const int32_t coef_hf[2][5] = {{ -4096,  8192, -4096, 0, 0},
   {  2032, -7602, 11140, -7602,  2032}};
 
-static void deinterlace_plane(AVFilterContext *ctx, AVFrame *out,
-  const AVFrame *cur, const AVFrame *adj,
-  const int filter, const int plane)
+typedef struct ThreadData {
+AVFrame *out, *cur, *adj;
+int plane;
+} ThreadData;
+
+static int deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
 {
 W3FDIFContext *s = ctx->priv;
+ThreadData *td = arg;
+AVFrame *out = td->out;
+AVFrame *cur = td->cur;
+AVFrame *adj = td->adj;
+const int plane = td->plane;
+const int filter = s->filter;
 uint8_t *in_line, *in_lines_cur[5], *in_lines_adj[5];
 uint8_t *out_line, *out_pixel;
 int32_t *work_line, *work_pixel;
@@ -144,15 +162,17 @@ static void deinterlace_plane(AVFilterContext *ctx, 
AVFrame *out,
 const int cur_line_stride = cur->linesize[plane];
 const int adj_line_stride = adj->linesize[plane];
 const int dst_line_stride = out->linesize[plane];
+const int start = (height * jobnr) / nb_jobs;
+const int end = (height * (jobnr+1)) / nb_jobs;
 int i, j, y_in, y_out;
 
 /* copy unchanged the lines of the field */
-y_out = s->field == cur->top_field_first;
+y_out = start + (s->field == cur->top_field_first) - (start & 1);
 
 in_line  = cur_data + (y_out * cur_line_stride);
 out_line = dst_data + (y_out * dst_line_stride);
 
-while (y_out < height) {
+while (y_out < end) {
 memcpy(out_line, in_line, linesize);
 y_out += 2;
 in_line  += cur_line_stride * 2;
@@ -160,13 +180,13 @@ static void deinterlace_plane(AVFilterContext *ctx, 
AVFrame *out,
 }
 
 /* interpolate other lines of the field */
-y_out = s->field != cur->top_field_first;
+y_out = start + (s->field != cur->top_field_first) - (start & 1);
 
 out_line = dst_data + (y_out * dst_line_stride);
 
-while (y_out < height) {
+while (y_out < end) {
 /* clear workspace */
-memset(s->work_line, 0, sizeof(*s->work_line) * linesize);
+memset(s->work_line[jobnr], 0, sizeof(*s->work_line[jobnr]) * 
linesize);
 
 /* get low vertical frequencies from current field */
 for (j = 0; j < n_coef_lf[filter]; j++) {
@@ -180,7 +200,7 @@ static void deinterlace_plane(AVFilterContext *ctx, AVFrame 
*out,
 in_lines_cur[j] = cur_data + (y_in * cur_line_stride);
 }
 
-work_line = s->work_line;
+work_line = s->work_line[jobnr];
 switch (n_coef_lf[filter]) {
 case 2:
 for (i = 0; i < linesize; i++) {
@@ -210,7 +230,7 @@ static void deinterlace_plane(AVFilterContext *ctx, AVFrame 
*out,
 in_lines_adj[j] = adj_data + (y_in * adj_line_stride);
 }
 
-work_line = s->work_line;
+work_line = s->work_line[jobnr];
 switch (n_coef_hf[filter]) {
 case 3:
 for (i = 0; i < linesize; i++) {
@@ -238,7 +258,7 @@ static void deinterlace_plane(AVFilterCo

[FFmpeg-devel] [PATCH] Add support for Audible AAX (and AAX+) files

2015-07-11 Thread Vesselin Bontchev
From 52e1d041fa9181a3610734b99444899df2b49e49 Mon Sep 17 00:00:00 2001
From: Vesselin Bontchev 
Date: Sat, 11 Jul 2015 18:02:47 +
Subject: [PATCH] Add support for Audible AAX (and AAX+) files

---
 libavformat/mov.c |  158 +
 1 file changed, 158 insertions(+)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 6d59863..3055de9 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -26,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "libavutil/attributes.h"
 #include "libavutil/channel_layout.h"
@@ -37,6 +38,8 @@
 #include "libavutil/dict.h"
 #include "libavutil/display.h"
 #include "libavutil/opt.h"
+#include "libavutil/aes.h"
+#include "libavutil/hash.h"
 #include "libavutil/timecode.h"
 #include "libavcodec/ac3tab.h"
 #include "avformat.h"
@@ -807,6 +810,128 @@ static int mov_read_mdat(MOVContext *c, AVIOContext *pb, MOVAtom atom)
 return 0; /* now go for moov */
 }
 
+static unsigned int aax_mode = 0;
+static unsigned char file_key[20];
+static unsigned char file_iv[20];
+static struct AVAES *aes_decrypt;
+
+static int hexchar2int(char c) {
+if (c >= '0' && c <= '9') return c - '0';
+if (c >= 'a' && c <= 'f') return c - 'a' + 10;
+if (c >= 'A' && c <= 'F') return c - 'A' + 10;
+return -1;
+}
+
+static void hex_encode(unsigned char *s, int len, unsigned char *o)
+{
+char itoa16_private[16] = "0123456789abcdef";
+int i;
+for (i = 0; i < len; ++i) {
+o[0] = itoa16_private[s[i] >> 4];
+o[1] = itoa16_private[s[i] & 15];
+o += 2;
+}
+}
+
+#define DRM_BLOB_SIZE 56
+
+// AAX (and AAX+) support is licensed under GPLv3
+static int aax_parser(MOVContext *c, AVIOContext *pb)
+{
+unsigned char activation_bytes[4];
+
+// extracted from libAAX_SDK.so and AAXSDKWin.dll files!
+unsigned char fixed_key[] = { 0x77, 0x21, 0x4d, 0x4b, 0x19, 0x6a, 0x87, 0xcd,
+  0x52, 0x00, 0x45, 0xfd, 0x20, 0xa5, 0x1d, 0x67 };
+unsigned char intermediate_key[20] = {0};
+unsigned char intermediate_iv[20] = {0};
+unsigned char input[4096] = {0};
+unsigned char output[4096] = {0};
+unsigned char file_checksum[20] = {0};
+unsigned char file_checksum_encoded[41] = {0};
+unsigned char file_key_encoded[41] = {0};
+unsigned char file_iv_encoded[41] = {0};
+unsigned char calculated_checksum[20];
+struct AVHashContext *ctx;
+int a, b, i;
+const char *magic = "drm";
+char *s;
+
+av_hash_alloc(&ctx, "SHA160");
+
+aes_decrypt = av_aes_alloc();
+if (!aes_decrypt) {
+return AVERROR(ENOMEM);
+}
+
+/* extract activation data */
+s = getenv("activation_bytes");
+if (!s || strlen(s) < 8) {
+av_log(c->fc, AV_LOG_ERROR, "[aax] export activation_bytes= is missing!\n");
+exit(-1);
+}
+av_log(c->fc, AV_LOG_DEBUG, "[aax] activation_bytes == %s!\n", s);
+for (i = 0; i < 4 && isxdigit(*s); i++) {
+a = hexchar2int(*s++);
+b = hexchar2int(*s++);
+activation_bytes[i] = (a << 4) | b;
+}
+
+/* drm blob processing */
+avio_seek(pb, 0x246, 0);
+avio_read(pb, input, 3);
+if (strncmp(input, magic, 3)) {
+av_log(c->fc, AV_LOG_ERROR, "[aax] drm blob is missing from this file!\n");
+exit(-1);
+}
+avio_seek(pb, 0x251, 0);
+avio_read(pb, input, DRM_BLOB_SIZE);
+avio_seek(pb, 0x28d, 0);
+avio_read(pb, file_checksum, 20);
+hex_encode(file_checksum, 20, file_checksum_encoded);
+av_log(c->fc, AV_LOG_DEBUG, "[aax] file checksum == %s\n", file_checksum_encoded);
+
+/* AAX (and AAX+) key derivation */
+av_hash_init(ctx);
+av_hash_update(ctx, fixed_key, 16);
+av_hash_update(ctx, activation_bytes, 4);
+av_hash_final(ctx, intermediate_key);
+av_hash_init(ctx);
+av_hash_update(ctx, fixed_key, 16);
+av_hash_update(ctx, intermediate_key, 20);
+av_hash_update(ctx, activation_bytes, 4);
+av_hash_final(ctx, intermediate_iv);
+av_hash_init(ctx);
+av_hash_update(ctx, intermediate_key, 16);
+av_hash_update(ctx, intermediate_iv, 16);
+av_hash_final(ctx, calculated_checksum);
+if (memcmp(calculated_checksum, file_checksum, 20)) {
+av_log(c->fc, AV_LOG_ERROR, "[aax] mismatch in checksums, terminating!\n");
+exit(-1);
+}
+av_aes_init(aes_decrypt, intermediate_key, 128, 1);
+av_aes_crypt(aes_decrypt, output, input, DRM_BLOB_SIZE, intermediate_iv, 1);
+for (i = 0; i < 4; i++) {
+if (activation_bytes[i] != output[3 - i]) {
+av_log(c->fc, AV_LOG_ERROR, "[aax] error in drm blob decryption, terminating!\n");
+exit(-1);
+}
+}
+memcpy(file_key, output + 8, 16);
+memcpy(input, output + 26, 16);
+av_hash_init(ctx);
+av_hash_update(ctx, input, 16);
+av_hash_update(ctx, file_key, 16);
+av_hash_update(ctx, fixed_key, 16);
+av_hash_final(ctx, file_iv);
+hex_encode(fil

Re: [FFmpeg-devel] [PATCH 4/4] avcodec: loongson optimized h264pred with mmi

2015-07-11 Thread Michael Niedermayer
On Sat, Jul 11, 2015 at 09:02:51PM +0200, Michael Niedermayer wrote:
> On Sun, Jul 05, 2015 at 11:43:37PM +0200, Michael Niedermayer wrote:
> > On Sat, Jul 04, 2015 at 12:14:51PM +0800, 周晓勇 wrote:
> > > i will offer a download source of Fedora21 OS next Monday.
> > > i will run yum-builddep ffmpeg-xxx.src.rpm for preparing devel 
> > > environment.
> > >  what else do you need to install, because it maybe slow for downloading 
> > > other packages abroad.
> > > the new FC21 build with mips64el N64 API and mips64r2(-march=loongson3a) 
> > > isa, and enabled ARCH_MIPS64 after ffmpeg configure.
> > > the FC19-O32 was slow, so aborted.
> > 
> > other things hmm
> > ccache, dash, screen
> 
> with dash configure finished in 1minute instead of 4 with bash (on loongson)

fate no longer passes after installing Fedora21

with
dash ./configure --enable-gpl --cc='ccache gcc' --enable-pthreads 
--samples=/home/loongson/fate/ --enable-nonfree  --enable-version3 
--assert-level=2
i get failure due to illegal instructions

with
dash ./configure --enable-gpl --cc='ccache gcc' --enable-pthreads 
--samples=/home/loongson/fate/ --enable-nonfree  --enable-version3 
--assert-level=2  --cpu=loongson3a --enable-loongson3
it fails in dca tests:

TESTdca-core
TESTdca-xll
stddev:  853.28 PSNR: 37.71 MAXDIFF:11651 bytes:  1554432/   700416
MAXDIFF: |11651 - 0| >= 1
size: |1554432 - 700416| >= 0
Test dca-core failed. Look at tests/data/fate/dca-core.err for details.
tests/Makefile:202: recipe for target 'fate-dca-core' failed
make: *** [fate-dca-core] Error 1
make: *** Waiting for unfinished jobs
stddev:  219.18 PSNR: 49.51 MAXDIFF: 2483 bytes:  8994816/  1073152
MAXDIFF: |2483 - 0| >= 1
size: |8994816 - 1073152| >= 0
Test dca-xll failed. Look at tests/data/fate/dca-xll.err for details.
tests/Makefile:202: recipe for target 'fate-dca-xll' failed
make: *** [fate-dca-xll] Error 1

[...]


-- 
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


[FFmpeg-devel] [PATCH] avcodec_free_context instead of close+av_free

2015-07-11 Thread Lectem
If I understood the source and documentation correctly, avcodec_free_context 
should now be used to free a context instead of avcodec_close + av_free.
---
 doc/examples/decoding_encoding.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/doc/examples/decoding_encoding.c b/doc/examples/decoding_encoding.c
index f6643f6..e257501 100644
--- a/doc/examples/decoding_encoding.c
+++ b/doc/examples/decoding_encoding.c
@@ -232,8 +232,7 @@ static void audio_encode_example(const char *filename)
 
 av_freep(&samples);
 av_frame_free(&frame);
-avcodec_close(c);
-av_free(c);
+avcodec_free_context(c);
 }
 
 /*
@@ -279,7 +278,7 @@ static void audio_decode_example(const char *outfilename, 
const char *filename)
 }
 outfile = fopen(outfilename, "wb");
 if (!outfile) {
-av_free(c);
+avcodec_free_context(c);
 exit(1);
 }
 
@@ -336,8 +335,7 @@ static void audio_decode_example(const char *outfilename, 
const char *filename)
 fclose(outfile);
 fclose(f);
 
-avcodec_close(c);
-av_free(c);
+avcodec_free_context(c);
 av_frame_free(&decoded_frame);
 }
 
@@ -479,8 +477,7 @@ static void video_encode_example(const char *filename, int 
codec_id)
 fwrite(endcode, 1, sizeof(endcode), f);
 fclose(f);
 
-avcodec_close(c);
-av_free(c);
+avcodec_free_context(c);
 av_freep(&frame->data[0]);
 av_frame_free(&frame);
 printf("\n");
@@ -622,8 +619,7 @@ static void video_decode_example(const char *outfilename, 
const char *filename)
 
 fclose(f);
 
-avcodec_close(c);
-av_free(c);
+avcodec_free_context(c);
 av_frame_free(&frame);
 printf("\n");
 }
-- 
1.9.5.msysgit.0

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


Re: [FFmpeg-devel] GSoC Weely report (libswscale)

2015-07-11 Thread Pedro Arthur
Here is the full patch rebased including all previous changes.

2015-07-10 17:56 GMT-03:00 Pedro Arthur :

> I'll check and fix it and then send a new patch.
>
> 2015-07-09 14:37 GMT-03:00 Michael Niedermayer :
>
>> On Wed, Jul 08, 2015 at 10:36:56PM -0300, Pedro Arthur wrote:
>> > Hi,
>> >
>> > Last week I worked on adding the ring buffer logic into SwsSlice and
>> fixing
>> > some seg faults. As I'm having some problems with git send-email through
>> > gmail I've attached the patch.
>>
>> these patches dont seem to apply cleanly
>> You can try to apply them on a fresh checkout to see the problem
>> (also see below)
>>
>> Also i think you used git merge in your git branch, this is not
>> recommanded, and might be related to why they dont apply
>>
>> In practice its probably best if you use git pull --rebase
>> when updating to a new version. Its quite likely that earlier changes
>> in the set will need to be updated and that would not be possible
>> with a merge occirug later
>>
>> to correct the patches so they apply again you can probably
>> checkout origin/master, create a new branch and cherry pick
>> the comits on top of that, correcting any conflicts that might pop
>> up, and test that things still work after moving the changes on top
>> of the latest code
>>
>>
>> ffmpeg-git/ffmpeg/.git/rebase-apply/patch:142: tab in indent.
>> int maxSize;
>> ffmpeg-git/ffmpeg/.git/rebase-apply/patch:153: tab in indent.
>> maxSize = FFMAX(c->vLumFilterSize, c->vChrFilterSize <<
>> c->chrSrcVSubSample);
>> error: libswscale/slice.c: does not exist in index
>> error: patch failed: libswscale/swscale.c:451
>> error: libswscale/swscale.c: patch does not apply
>> error: patch failed: libswscale/swscale_internal.h:932
>> error: libswscale/swscale_internal.h: patch does not apply
>> Patch failed at 0001 swscale: fix seg fault when accessing src slice
>> The copy of the patch that failed is found in:
>>ffmpeg-git/ffmpeg/.git/rebase-apply/patch
>> When you have resolved this problem, run "git am --continue".
>> If you prefer to skip this patch, run "git am --skip" instead.
>> To restore the original branch and stop patching, run "git am --abort".
>>
>> Applying: swscale: fix seg fault when accessing src slice
>> ffmpeg-git/ffmpeg/.git/rebase-apply/patch:142: tab in indent.
>> int maxSize;
>> ffmpeg-git/ffmpeg/.git/rebase-apply/patch:153: tab in indent.
>> maxSize = FFMAX(c->vLumFilterSize, c->vChrFilterSize <<
>> c->chrSrcVSubSample);
>> warning: 2 lines add whitespace errors.
>> Using index info to reconstruct a base tree...
>> A   libswscale/slice.c
>> M   libswscale/swscale.c
>> M   libswscale/swscale_internal.h
>> :142: tab in indent.
>> int maxSize;
>> :153: tab in indent.
>> maxSize = FFMAX(c->vLumFilterSize, c->vChrFilterSize <<
>> c->chrSrcVSubSample);
>> :165: new blank line at EOF.
>> +
>> warning: 2 lines applied after fixing whitespace errors.
>> Falling back to patching base and 3-way merge...
>> error: refusing to lose untracked file at 'libswscale/slice.c'
>> Auto-merging libswscale/swscale_internal.h
>> CONFLICT (content): Merge conflict in libswscale/swscale_internal.h
>> Auto-merging libswscale/swscale.c
>> CONFLICT (content): Merge conflict in libswscale/swscale.c
>> CONFLICT (modify/delete): libswscale/slice.c deleted in HEAD and modified
>> in swscale: fix seg fault when accessing src slice. Version swscale: fix
>> seg fault when accessing src slice of libswscale/slice.c left in tree.
>> Failed to merge in the changes.
>> Patch failed at 0001 swscale: fix seg fault when accessing src slice
>> The copy of the patch that failed is found in:
>>ffmpeg-git/ffmpeg/.git/rebase-apply/patch
>> When you have resolved this problem, run "git am --continue".
>> If you prefer to skip this patch, run "git am --skip" instead.
>> To restore the original branch and stop patching, run "git am --abort".
>>
>> [...]
>> --
>> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>>
>> In fact, the RIAA has been known to suggest that students drop out
>> of college or go to community college in order to be able to afford
>> settlements. -- The RIAA
>>
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>>
>
From 1501f5a88afb8c1cd128969a2d950bcca594c11f Mon Sep 17 00:00:00 2001
From: Pedro Arthur 
Date: Sun, 24 May 2015 12:52:46 -0300
Subject: [PATCH 01/11] swscale refactor: added initial filters

Signed-off-by: Pedro Arthur 
---
 libswscale/slice.c| 299 ++
 libswscale/swscale.c  |  33 -
 libswscale/swscale_internal.h |  41 ++
 libswscale/utils.c|   3 +
 4 files changed, 374 insertions(+), 2 deletions(-)
 create mode 100644 libswscale/slice.c

diff --git a/libswscale/slice.c b/libswscale/slice.c
new file mode 100644
index 000..4f40ae6
--- /dev/null
+++

Re: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_w3fdif: implement slice threading

2015-07-11 Thread Paul B Mahol
On 7/11/15, Paul B Mahol  wrote:
> On 7/11/15, Michael Niedermayer  wrote:
>> On Sat, Jul 11, 2015 at 07:03:41PM +, Paul B Mahol wrote:
>>> Signed-off-by: Paul B Mahol 
>>> ---
>>>  libavfilter/vf_w3fdif.c | 75
>>> ++---
>>>  1 file changed, 53 insertions(+), 22 deletions(-)
>>
>> this is about 2x as fast but it breaks the tests
>> lter-mcdeint-fast
>> TESTfilter-mcdeint-medium
>
> Can you upload somewhere single frame as png so I
> can see how broken it looks like?
>

I managed to reproduce it, no need to upload anything.


> [...]
>
>> --
>> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>>
>> No snowflake in an avalanche ever feels responsible. -- Voltaire
>>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_w3fdif: implement slice threading

2015-07-11 Thread Paul B Mahol
On 7/11/15, Michael Niedermayer  wrote:
> On Sat, Jul 11, 2015 at 07:03:41PM +, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libavfilter/vf_w3fdif.c | 75
>> ++---
>>  1 file changed, 53 insertions(+), 22 deletions(-)
>
> this is about 2x as fast but it breaks the tests
> lter-mcdeint-fast
> TESTfilter-mcdeint-medium

Can you upload somewhere single frame as png so I
can see how broken it looks like?

[...]

> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> No snowflake in an avalanche ever feels responsible. -- Voltaire
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] fate: add tests for w3fdif filter

2015-07-11 Thread Paul B Mahol
On 7/11/15, Michael Niedermayer  wrote:
> On Sat, Jul 11, 2015 at 07:03:40PM +, Paul B Mahol wrote:
>> Signed-off-by: Paul B Mahol 
>> ---
>>  tests/fate/filter-video.mak  |  8 
>>  tests/ref/fate/filter-w3fdif-complex | 31
>> +++
>>  tests/ref/fate/filter-w3fdif-simple  | 31
>> +++
>>  3 files changed, 70 insertions(+)
>>  create mode 100644 tests/ref/fate/filter-w3fdif-complex
>>  create mode 100644 tests/ref/fate/filter-w3fdif-simple
>
> tested, seems working
>
> LGTM
>
> thx

Pushed.

>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> There will always be a question for which you do not know the correct
> answer.
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_w3fdif: implement slice threading

2015-07-11 Thread Michael Niedermayer
On Sat, Jul 11, 2015 at 07:03:41PM +, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/vf_w3fdif.c | 75 
> ++---
>  1 file changed, 53 insertions(+), 22 deletions(-)

this is about 2x as fast but it breaks the tests
lter-mcdeint-fast
TESTfilter-mcdeint-medium
--- ./tests/ref/fate/filter-w3fdif-simple   2015-07-11 21:11:06.232922890 
+0200
+++ tests/data/fate/filter-w3fdif-simple2015-07-11 21:36:10.972954591 
+0200
@@ -1,31 +1,31 @@
 #tb 0: 1/50
-0, 18, 18,1,   622080, 0xc73774f5
-0, 19, 19,1,   622080, 0x4ea3a400
-0, 20, 20,1,   622080, 0x95153cda
-0, 21, 21,1,   622080, 0xec39bf0b
-0, 22, 22,1,   622080, 0x94b6f836
-0, 23, 23,1,   622080, 0xc145c3ee
-0, 24, 24,1,   622080, 0x4d4cdee2
-0, 25, 25,1,   622080, 0x193ebc7c
-0, 26, 26,1,   622080, 0xbd728fd8
-0, 27, 27,1,   622080, 0xf0f3252f
-0, 28, 28,1,   622080, 0xc012d20a
-0, 29, 29,1,   622080, 0x7b5831b2
-0, 30, 30,1,   622080, 0x464e9622
-0, 31, 31,1,   622080, 0x46e3c6c0
-0, 32, 32,1,   622080, 0xa6ec908b
-0, 33, 33,1,   622080, 0x6a257595
-0, 34, 34,1,   622080, 0xa6552ecc
-0, 35, 35,1,   622080, 0xdecd1a91
-0, 36, 36,1,   622080, 0xfaa53e71
-0, 37, 37,1,   622080, 0xc94a9707
-0, 38, 38,1,   622080, 0xb5727fd4
-0, 39, 39,1,   622080, 0x143c018c
-0, 40, 40,1,   622080, 0x92d110c9
-0, 41, 41,1,   622080, 0x4f762fc0
-0, 42, 42,1,   622080, 0x3dd2a7d2
-0, 43, 43,1,   622080, 0xa5d02dc0
-0, 44, 44,1,   622080, 0x2223ce3d
-0, 45, 45,1,   622080, 0xe4a5fc36
-0, 46, 46,1,   622080, 0x8384159e
-0, 47, 47,1,   622080, 0x995efa57
+0, 18, 18,1,   622080, 0xb9a21d81
+0, 19, 19,1,   622080, 0xcad5045c
+0, 20, 20,1,   622080, 0xb3515cee
+0, 21, 21,1,   622080, 0xf3617e04
+0, 22, 22,1,   622080, 0x920ccb46
+0, 23, 23,1,   622080, 0x0d6bf5ee
+0, 24, 24,1,   622080, 0x3824bfa3
+0, 25, 25,1,   622080, 0x966ed01f
+0, 26, 26,1,   622080, 0x59dedfca
+0, 27, 27,1,   622080, 0xc4d9f060
+0, 28, 28,1,   622080, 0xfc425c54
+0, 29, 29,1,   622080, 0xd4d79d89
+0, 30, 30,1,   622080, 0x26112cde
+0, 31, 31,1,   622080, 0xcedc47e5
+0, 32, 32,1,   622080, 0x8a5962f3
+0, 33, 33,1,   622080, 0x290d9d70
+0, 34, 34,1,   622080, 0xc173ca6e
+0, 35, 35,1,   622080, 0x3bc28ba3
+0, 36, 36,1,   622080, 0x0450ca38
+0, 37, 37,1,   622080, 0x66e5065c
+0, 38, 38,1,   622080, 0x4b26ee9f
+0, 39, 39,1,   622080, 0x3cb19ecf
+0, 40, 40,1,   622080, 0x670d4d1b
+0, 41, 41,1,   622080, 0x18b2fc90
+0, 42, 42,1,   622080, 0x74134131
+0, 43, 43,1,   622080, 0x36cfa8dc
+0, 44, 44,1,   622080, 0xefef09d4
+0, 45, 45,1,   622080, 0x0aa0a8f6
+0, 46, 46,1,   622080, 0x3a7b42f3
+0, 47, 47,1,   622080, 0x2900da5d
TESTfilter-codecview-mvs
Test filter-w3fdif-simple failed. Look at 
tests/data/fate/filter-w3fdif-simple.err for details.
make: *** [fate-filter-w3fdif-simple] Error 1
make: *** Waiting for unfinished jobs
--- ./tests/ref/fate/filter-w3fdif-complex  2015-07-11 21:11:06.220922890 
+0200
+++ tests/data/fate/filter-w3fdif-complex   2015-07-11 21:36:10.976954590 
+0200
@@ -1,31 +1,31 @@
 #tb 0: 1/50
-0, 18, 18,1,   622080, 0x21d21485
-0, 19, 19,1,   622080, 0x600a5468
-0, 20, 20,1,   622080, 0x9526f7b8
-0, 21, 21,1,   622080, 0x8b3e661f
-0, 22, 22,1,   622080, 0xff5cb5a9
-0, 23, 23,1,   622080, 0x7e5e730c
-0, 24, 24,1,   622080, 0x85219ac6
-0, 25, 25,1,   622080, 0x2f3465a0
-0, 26, 26,1

Re: [FFmpeg-devel] [PATCH 1/2] fate: add tests for w3fdif filter

2015-07-11 Thread Michael Niedermayer
On Sat, Jul 11, 2015 at 07:03:40PM +, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol 
> ---
>  tests/fate/filter-video.mak  |  8 
>  tests/ref/fate/filter-w3fdif-complex | 31 +++
>  tests/ref/fate/filter-w3fdif-simple  | 31 +++
>  3 files changed, 70 insertions(+)
>  create mode 100644 tests/ref/fate/filter-w3fdif-complex
>  create mode 100644 tests/ref/fate/filter-w3fdif-simple

tested, seems working

LGTM

thx

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

There will always be a question for which you do not know the correct answer.


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


[FFmpeg-devel] [PATCH 2/2] avfilter/vf_w3fdif: implement slice threading

2015-07-11 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/vf_w3fdif.c | 75 ++---
 1 file changed, 53 insertions(+), 22 deletions(-)

diff --git a/libavfilter/vf_w3fdif.c b/libavfilter/vf_w3fdif.c
index bb0316b..c783477 100644
--- a/libavfilter/vf_w3fdif.c
+++ b/libavfilter/vf_w3fdif.c
@@ -40,7 +40,8 @@ typedef struct W3FDIFContext {
 int eof;
 int nb_planes;
 AVFrame *prev, *cur, *next;  ///< previous, current, next frames
-int32_t *work_line;   ///< line we are calculating
+int32_t **work_line;  ///< lines we are calculating
+int nb_threads;
 } W3FDIFContext;
 
 #define OFFSET(x) offsetof(W3FDIFContext, x)
@@ -82,9 +83,10 @@ static int query_formats(AVFilterContext *ctx)
 
 static int config_input(AVFilterLink *inlink)
 {
-W3FDIFContext *s = inlink->dst->priv;
+AVFilterContext *ctx = inlink->dst;
+W3FDIFContext *s = ctx->priv;
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
-int ret;
+int ret, i;
 
 if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, 
inlink->w)) < 0)
 return ret;
@@ -93,10 +95,17 @@ static int config_input(AVFilterLink *inlink)
 s->planeheight[0] = s->planeheight[3] = inlink->h;
 
 s->nb_planes = av_pix_fmt_count_planes(inlink->format);
-s->work_line = av_calloc(s->linesize[0], sizeof(*s->work_line));
+s->nb_threads = ctx->graph->nb_threads;
+s->work_line = av_calloc(s->nb_threads, sizeof(*s->work_line));
 if (!s->work_line)
 return AVERROR(ENOMEM);
 
+for (i = 0; i < s->nb_threads; i++) {
+s->work_line[i] = av_calloc(s->linesize[0], sizeof(*s->work_line[0]));
+if (!s->work_line[i])
+return AVERROR(ENOMEM);
+}
+
 return 0;
 }
 
@@ -128,11 +137,20 @@ static const int8_t   n_coef_hf[2] = { 3, 5 };
 static const int32_t coef_hf[2][5] = {{ -4096,  8192, -4096, 0, 0},
   {  2032, -7602, 11140, -7602,  2032}};
 
-static void deinterlace_plane(AVFilterContext *ctx, AVFrame *out,
-  const AVFrame *cur, const AVFrame *adj,
-  const int filter, const int plane)
+typedef struct ThreadData {
+AVFrame *out, *cur, *adj;
+int plane;
+} ThreadData;
+
+static int deinterlace_slice(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
 {
 W3FDIFContext *s = ctx->priv;
+ThreadData *td = arg;
+AVFrame *out = td->out;
+AVFrame *cur = td->cur;
+AVFrame *adj = td->adj;
+const int plane = td->plane;
+const int filter = s->filter;
 uint8_t *in_line, *in_lines_cur[5], *in_lines_adj[5];
 uint8_t *out_line, *out_pixel;
 int32_t *work_line, *work_pixel;
@@ -144,15 +162,17 @@ static void deinterlace_plane(AVFilterContext *ctx, 
AVFrame *out,
 const int cur_line_stride = cur->linesize[plane];
 const int adj_line_stride = adj->linesize[plane];
 const int dst_line_stride = out->linesize[plane];
+const int start = (height * jobnr) / nb_jobs;
+const int end = (height * (jobnr+1)) / nb_jobs;
 int i, j, y_in, y_out;
 
 /* copy unchanged the lines of the field */
-y_out = s->field == cur->top_field_first;
+y_out = start + (s->field == cur->top_field_first);
 
 in_line  = cur_data + (y_out * cur_line_stride);
 out_line = dst_data + (y_out * dst_line_stride);
 
-while (y_out < height) {
+while (y_out < end) {
 memcpy(out_line, in_line, linesize);
 y_out += 2;
 in_line  += cur_line_stride * 2;
@@ -160,27 +180,27 @@ static void deinterlace_plane(AVFilterContext *ctx, 
AVFrame *out,
 }
 
 /* interpolate other lines of the field */
-y_out = s->field != cur->top_field_first;
+y_out = start + (s->field != cur->top_field_first);
 
 out_line = dst_data + (y_out * dst_line_stride);
 
-while (y_out < height) {
+while (y_out < end) {
 /* clear workspace */
-memset(s->work_line, 0, sizeof(*s->work_line) * linesize);
+memset(s->work_line[jobnr], 0, sizeof(*s->work_line[jobnr]) * 
linesize);
 
 /* get low vertical frequencies from current field */
 for (j = 0; j < n_coef_lf[filter]; j++) {
 y_in = (y_out + 1) + (j * 2) - n_coef_lf[filter];
 
-while (y_in < 0)
+while (y_in < start)
 y_in += 2;
-while (y_in >= height)
+while (y_in >= end)
 y_in -= 2;
 
 in_lines_cur[j] = cur_data + (y_in * cur_line_stride);
 }
 
-work_line = s->work_line;
+work_line = s->work_line[jobnr];
 switch (n_coef_lf[filter]) {
 case 2:
 for (i = 0; i < linesize; i++) {
@@ -201,16 +221,16 @@ static void deinterlace_plane(AVFilterContext *ctx, 
AVFrame *out,
 for (j = 0; j < n_coef_hf[filter]; j++) {
 y_in = (y_out + 1) + (j * 2) - n_coef_hf[filter];
 
-while (y_in < 0)
+while (y_in < sta

[FFmpeg-devel] [PATCH 1/2] fate: add tests for w3fdif filter

2015-07-11 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 tests/fate/filter-video.mak  |  8 
 tests/ref/fate/filter-w3fdif-complex | 31 +++
 tests/ref/fate/filter-w3fdif-simple  | 31 +++
 3 files changed, 70 insertions(+)
 create mode 100644 tests/ref/fate/filter-w3fdif-complex
 create mode 100644 tests/ref/fate/filter-w3fdif-simple

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index 87af23b..76fa0f2 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -15,6 +15,14 @@ fate-filter-yadif16: CMD = framecrc -flags bitexact -idct 
simple -i $(TARGET_SAM
 
 FATE_FILTER-$(call FILTERDEMDEC, YADIF, MPEGTS, MPEG2VIDEO) += $(FATE_YADIF)
 
+FATE_W3FDIF += fate-filter-w3fdif-simple
+fate-filter-w3fdif-simple: CMD = framecrc -flags bitexact -idct simple -i 
$(TARGET_SAMPLES)/mpeg2/mpeg2_field_encoding.ts -vframes 30 -vf w3fdif=0
+
+FATE_W3FDIF += fate-filter-w3fdif-complex
+fate-filter-w3fdif-complex: CMD = framecrc -flags bitexact -idct simple -i 
$(TARGET_SAMPLES)/mpeg2/mpeg2_field_encoding.ts -vframes 30 -vf w3fdif=1
+
+FATE_FILTER-$(call FILTERDEMDEC, W3FDIF, MPEGTS, MPEG2VIDEO) += $(FATE_W3FDIF)
+
 FATE_MCDEINT += fate-filter-mcdeint-fast
 fate-filter-mcdeint-fast: CMD = framecrc -flags bitexact -idct simple -i 
$(TARGET_SAMPLES)/mpeg2/mpeg2_field_encoding.ts -vframes 30 -vf mcdeint=fast
 
diff --git a/tests/ref/fate/filter-w3fdif-complex 
b/tests/ref/fate/filter-w3fdif-complex
new file mode 100644
index 000..32eadc9
--- /dev/null
+++ b/tests/ref/fate/filter-w3fdif-complex
@@ -0,0 +1,31 @@
+#tb 0: 1/50
+0, 18, 18,1,   622080, 0x21d21485
+0, 19, 19,1,   622080, 0x600a5468
+0, 20, 20,1,   622080, 0x9526f7b8
+0, 21, 21,1,   622080, 0x8b3e661f
+0, 22, 22,1,   622080, 0xff5cb5a9
+0, 23, 23,1,   622080, 0x7e5e730c
+0, 24, 24,1,   622080, 0x85219ac6
+0, 25, 25,1,   622080, 0x2f3465a0
+0, 26, 26,1,   622080, 0xddbf4da0
+0, 27, 27,1,   622080, 0xc115d4ee
+0, 28, 28,1,   622080, 0x7a8a8d72
+0, 29, 29,1,   622080, 0xbafcd973
+0, 30, 30,1,   622080, 0xd2c15603
+0, 31, 31,1,   622080, 0xd7217855
+0, 32, 32,1,   622080, 0x9a584eca
+0, 33, 33,1,   622080, 0x9f3e1c40
+0, 34, 34,1,   622080, 0x6d01efb7
+0, 35, 35,1,   622080, 0x9ecfcce0
+0, 36, 36,1,   622080, 0xb355fd7e
+0, 37, 37,1,   622080, 0xc7784021
+0, 38, 38,1,   622080, 0x13fe4187
+0, 39, 39,1,   622080, 0xfa03b613
+0, 40, 40,1,   622080, 0x2c9ccfcd
+0, 41, 41,1,   622080, 0xcae6e6c6
+0, 42, 42,1,   622080, 0x177968f9
+0, 43, 43,1,   622080, 0xf708de36
+0, 44, 44,1,   622080, 0x4491870a
+0, 45, 45,1,   622080, 0x37709f98
+0, 46, 46,1,   622080, 0x23e8d22f
+0, 47, 47,1,   622080, 0x25cba876
diff --git a/tests/ref/fate/filter-w3fdif-simple 
b/tests/ref/fate/filter-w3fdif-simple
new file mode 100644
index 000..137d989
--- /dev/null
+++ b/tests/ref/fate/filter-w3fdif-simple
@@ -0,0 +1,31 @@
+#tb 0: 1/50
+0, 18, 18,1,   622080, 0xc73774f5
+0, 19, 19,1,   622080, 0x4ea3a400
+0, 20, 20,1,   622080, 0x95153cda
+0, 21, 21,1,   622080, 0xec39bf0b
+0, 22, 22,1,   622080, 0x94b6f836
+0, 23, 23,1,   622080, 0xc145c3ee
+0, 24, 24,1,   622080, 0x4d4cdee2
+0, 25, 25,1,   622080, 0x193ebc7c
+0, 26, 26,1,   622080, 0xbd728fd8
+0, 27, 27,1,   622080, 0xf0f3252f
+0, 28, 28,1,   622080, 0xc012d20a
+0, 29, 29,1,   622080, 0x7b5831b2
+0, 30, 30,1,   622080, 0x464e9622
+0, 31, 31,1,   622080, 0x46e3c6c0
+0, 32, 32,1,   622080, 0xa6ec908b
+0, 33, 33,1,   622080, 0x6a257595
+0, 34, 34,1,   622080, 0xa6552ecc
+0, 35, 35,1,   622080, 0xdecd1a91
+0, 36, 36,1,   622080, 0xfaa53e71
+0, 37, 37,1,   622080, 0xc94a9707
+0, 38, 38,1,   622080, 0xb5727fd4
+0, 39, 39,1,   622080, 0x143c018c
+0, 40, 40,1,   622080, 0x92d110c9
+0, 41, 41,

Re: [FFmpeg-devel] [PATCH 4/4] avcodec: loongson optimized h264pred with mmi

2015-07-11 Thread Michael Niedermayer
On Sun, Jul 05, 2015 at 11:43:37PM +0200, Michael Niedermayer wrote:
> On Sat, Jul 04, 2015 at 12:14:51PM +0800, 周晓勇 wrote:
> > i will offer a download source of Fedora21 OS next Monday.
> > i will run yum-builddep ffmpeg-xxx.src.rpm for preparing devel environment.
> >  what else do you need to install, because it maybe slow for downloading 
> > other packages abroad.
> > the new FC21 build with mips64el N64 API and mips64r2(-march=loongson3a) 
> > isa, and enabled ARCH_MIPS64 after ffmpeg configure.
> > the FC19-O32 was slow, so aborted.
> 
> other things hmm
> ccache, dash, screen

with dash configure finished in 1minute instead of 4 with bash (on loongson)

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Old school: Use the lowest level language in which you can solve the problem
conveniently.
New school: Use the highest level language in which the latest supercomputer
can solve the problem without the user falling asleep waiting.


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


[FFmpeg-devel] [PATCHv2 5/5] avformat: bump micro version after adding concatdec features

2015-07-11 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavformat/version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/version.h b/libavformat/version.h
index 052551c..3ddba0c 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -31,7 +31,7 @@
 
 #define LIBAVFORMAT_VERSION_MAJOR 56
 #define LIBAVFORMAT_VERSION_MINOR  40
-#define LIBAVFORMAT_VERSION_MICRO 100
+#define LIBAVFORMAT_VERSION_MICRO 101
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
-- 
2.1.4

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


[FFmpeg-devel] [PATCHv2 4/5] concatdec: add support for injecting packet metadata

2015-07-11 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 doc/demuxers.texi   |  5 +
 libavformat/concatdec.c | 28 
 2 files changed, 33 insertions(+)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 50b5688..e45e1af 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -148,6 +148,11 @@ stream until Out point.
 The duration of the files (if not specified by the @code{duration}
 directive) will be reduced based on their specified Out point.
 
+@item @code{file_packet_metadata @var{key=value}}
+Metadata of the packets of the file. The specified metadata will be set for
+each file packet. You can specify this directive multiple times to add multiple
+metadata entries.
+
 @item @code{stream}
 Introduce a stream in the virtual file.
 All subsequent stream-related directives apply to the last introduced
diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index 5dcfd02..fee4ff0 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -47,6 +47,7 @@ typedef struct {
 ConcatStream *streams;
 int64_t inpoint;
 int64_t outpoint;
+AVDictionary *metadata;
 int nb_streams;
 } ConcatFile;
 
@@ -334,6 +335,7 @@ static int concat_read_close(AVFormatContext *avf)
 for (i = 0; i < cat->nb_files; i++) {
 av_freep(&cat->files[i].url);
 av_freep(&cat->files[i].streams);
+av_dict_free(&cat->files[i].metadata);
 }
 av_freep(&cat->files);
 return 0;
@@ -385,6 +387,19 @@ static int concat_read_header(AVFormatContext *avf)
 file->inpoint = dur;
 else if (!strcmp(keyword, "outpoint"))
 file->outpoint = dur;
+} else if (!strcmp(keyword, "file_packet_metadata")) {
+char *metadata;
+metadata = av_get_token((const char **)&cursor, SPACE_CHARS);
+if (!metadata) {
+av_log(avf, AV_LOG_ERROR, "Line %d: packet metadata 
required\n", line);
+FAIL(AVERROR_INVALIDDATA);
+}
+if ((ret = av_dict_parse_string(&file->metadata, metadata, "=", 
"", 0)) < 0) {
+av_log(avf, AV_LOG_ERROR, "Line %d: failed to parse metadata 
string\n", line);
+av_freep(&metadata);
+FAIL(AVERROR_INVALIDDATA);
+}
+av_freep(&metadata);
 } else if (!strcmp(keyword, "stream")) {
 if (!avformat_new_stream(avf, NULL))
 FAIL(AVERROR(ENOMEM));
@@ -570,6 +585,19 @@ static int concat_read_packet(AVFormatContext *avf, 
AVPacket *pkt)
 av_log(avf, AV_LOG_DEBUG, " -> pts:%s pts_time:%s dts:%s dts_time:%s\n",
av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, &st->time_base),
av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, &st->time_base));
+if (cat->cur_file->metadata) {
+uint8_t* metadata;
+int metadata_len;
+char* packed_metadata = 
av_packet_pack_dictionary(cat->cur_file->metadata, &metadata_len);
+if (!packed_metadata)
+return AVERROR(ENOMEM);
+if (!(metadata = av_packet_new_side_data(pkt, 
AV_PKT_DATA_STRINGS_METADATA, metadata_len))) {
+av_freep(&packed_metadata);
+return AVERROR(ENOMEM);
+}
+memcpy(metadata, packed_metadata, metadata_len);
+av_freep(&packed_metadata);
+}
 return ret;
 }
 
-- 
2.1.4

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


[FFmpeg-devel] [PATCHv2 3/5] concatdec: add support for specifying outpoint of files

2015-07-11 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 doc/demuxers.texi   | 19 +++
 libavformat/concatdec.c | 29 +
 2 files changed, 44 insertions(+), 4 deletions(-)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 27a9409..50b5688 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -129,6 +129,25 @@ directive) will be reduced based on their specified In 
point.
 Because of potential packets before the specified In point, packet timestamps
 may overlap between two concatenated files.
 
+@item @code{outpoint @var{timestamp}}
+Out point of the file. When the demuxer reaches the specified decoding
+timestamp in any of the streams, it handles it as an end of file condition and
+skips the current and all the remaining packets from all streams.
+
+Out point is exclusive, which means that the demuxer will not output packets
+with a decoding timestamp greater or equal to Out point.
+
+This directive works best with intra frame codecs and formats where all streams
+are tightly interleaved. For non-intra frame codecs you will usually get
+additional packets with presentation timestamp after Out point therefore the
+decoded content will most likely contain frames after Out point too. If your
+streams are not tightly interleaved you may not get all the packets from all
+streams before Out point and you may only will be able to decode the earliest
+stream until Out point.
+
+The duration of the files (if not specified by the @code{duration}
+directive) will be reduced based on their specified Out point.
+
 @item @code{stream}
 Introduce a stream in the virtual file.
 All subsequent stream-related directives apply to the last introduced
diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index fa85b6e..5dcfd02 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -46,6 +46,7 @@ typedef struct {
 int64_t duration;
 ConcatStream *streams;
 int64_t inpoint;
+int64_t outpoint;
 int nb_streams;
 } ConcatFile;
 
@@ -147,6 +148,7 @@ static int add_file(AVFormatContext *avf, char *filename, 
ConcatFile **rfile,
 file->start_time = AV_NOPTS_VALUE;
 file->duration   = AV_NOPTS_VALUE;
 file->inpoint= AV_NOPTS_VALUE;
+file->outpoint   = AV_NOPTS_VALUE;
 
 return 0;
 
@@ -364,7 +366,7 @@ static int concat_read_header(AVFormatContext *avf)
 }
 if ((ret = add_file(avf, filename, &file, &nb_files_alloc)) < 0)
 goto fail;
-} else if (!strcmp(keyword, "duration") || !strcmp(keyword, 
"inpoint")) {
+} else if (!strcmp(keyword, "duration") || !strcmp(keyword, "inpoint") 
|| !strcmp(keyword, "outpoint")) {
 char *dur_str = get_keyword(&cursor);
 int64_t dur;
 if (!file) {
@@ -381,6 +383,8 @@ static int concat_read_header(AVFormatContext *avf)
 file->duration = dur;
 else if (!strcmp(keyword, "inpoint"))
 file->inpoint = dur;
+else if (!strcmp(keyword, "outpoint"))
+file->outpoint = dur;
 } else if (!strcmp(keyword, "stream")) {
 if (!avformat_new_stream(avf, NULL))
 FAIL(AVERROR(ENOMEM));
@@ -417,8 +421,11 @@ static int concat_read_header(AVFormatContext *avf)
 cat->files[i].start_time = time;
 else
 time = cat->files[i].start_time;
-if (cat->files[i].duration == AV_NOPTS_VALUE)
-break;
+if (cat->files[i].duration == AV_NOPTS_VALUE) {
+if (cat->files[i].inpoint == AV_NOPTS_VALUE || 
cat->files[i].outpoint == AV_NOPTS_VALUE)
+break;
+cat->files[i].duration = cat->files[i].outpoint - 
cat->files[i].inpoint;
+}
 time += cat->files[i].duration;
 }
 if (i == cat->nb_files) {
@@ -446,6 +453,8 @@ static int open_next_file(AVFormatContext *avf)
 cat->cur_file->duration = cat->avf->duration;
 if (cat->cur_file->inpoint != AV_NOPTS_VALUE)
 cat->cur_file->duration -= (cat->cur_file->inpoint - 
cat->cur_file->file_start_time);
+if (cat->cur_file->outpoint != AV_NOPTS_VALUE)
+cat->cur_file->duration -= cat->avf->duration - 
(cat->cur_file->outpoint - cat->cur_file->file_start_time);
 }
 
 if (++fileno >= cat->nb_files) {
@@ -495,6 +504,16 @@ static int filter_packet(AVFormatContext *avf, 
ConcatStream *cs, AVPacket *pkt)
 return 0;
 }
 
+/* Returns true if the packet dts is greater or equal to the specified 
outpoint. */
+static int packet_after_outpoint(ConcatContext *cat, AVPacket *pkt)
+{
+if (cat->cur_file->outpoint != AV_NOPTS_VALUE && pkt->dts != 
AV_NOPTS_VALUE) {
+return av_compare_ts(pkt->dts, 
cat->avf->streams[pkt->stream_index]->time_base,
+ cat->cur_file->outpoint, AV_TIME_BASE_Q) >= 0;
+}
+return 0;
+}
+
 static int concat_read_packet(AVFormatContext *avf, AVPacket *pkt)
 {
 ConcatContext *cat = avf

[FFmpeg-devel] [PATCH 1/5] concatdec: add support for specifying inpoint of files

2015-07-11 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 doc/demuxers.texi   | 17 +
 libavformat/concatdec.c | 39 ++-
 2 files changed, 43 insertions(+), 13 deletions(-)

diff --git a/doc/demuxers.texi b/doc/demuxers.texi
index 35a1561..27a9409 100644
--- a/doc/demuxers.texi
+++ b/doc/demuxers.texi
@@ -112,6 +112,23 @@ file is not available or accurate.
 If the duration is set for all files, then it is possible to seek in the
 whole concatenated video.
 
+@item @code{inpoint @var{timestamp}}
+In point of the file. When the demuxer opens the file it instantly seeks to the
+specified timestamp. Seeking is done so that all streams can be presented
+successfully at In point.
+
+This directive works best with intra frame codecs, because for non-intra frame
+ones you will usually get extra packets before the actual In point and the
+decoded content will most likely contain frames before In point too.
+
+For each file, packets before the file In point will have timestamps less than
+the calculated start timestamp of the file (negative in case of the first
+file), and the duration of the files (if not specified by the @code{duration}
+directive) will be reduced based on their specified In point.
+
+Because of potential packets before the specified In point, packet timestamps
+may overlap between two concatenated files.
+
 @item @code{stream}
 Introduce a stream in the virtual file.
 All subsequent stream-related directives apply to the last introduced
diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index e95ff34..de1543a 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -41,8 +41,11 @@ typedef struct ConcatStream {
 typedef struct {
 char *url;
 int64_t start_time;
+int64_t file_start_time;
+int64_t file_inpoint;
 int64_t duration;
 ConcatStream *streams;
+int64_t inpoint;
 int nb_streams;
 } ConcatFile;
 
@@ -142,6 +145,7 @@ static int add_file(AVFormatContext *avf, char *filename, 
ConcatFile **rfile,
 file->url= url;
 file->start_time = AV_NOPTS_VALUE;
 file->duration   = AV_NOPTS_VALUE;
+file->inpoint= AV_NOPTS_VALUE;
 
 return 0;
 
@@ -306,8 +310,14 @@ static int open_file(AVFormatContext *avf, unsigned fileno)
 file->start_time = !fileno ? 0 :
cat->files[fileno - 1].start_time +
cat->files[fileno - 1].duration;
+file->file_start_time = (avf->start_time == AV_NOPTS_VALUE) ? 0 : 
avf->start_time;
+file->file_inpoint = (file->file_inpoint == AV_NOPTS_VALUE) ? 
file->file_start_time : file->inpoint;
 if ((ret = match_streams(avf)) < 0)
 return ret;
+if (file->inpoint != AV_NOPTS_VALUE) {
+   if ((ret = avformat_seek_file(cat->avf, -1, INT64_MIN, file->inpoint, 
file->inpoint, 0) < 0))
+   return ret;
+}
 return 0;
 }
 
@@ -353,20 +363,23 @@ static int concat_read_header(AVFormatContext *avf)
 }
 if ((ret = add_file(avf, filename, &file, &nb_files_alloc)) < 0)
 goto fail;
-} else if (!strcmp(keyword, "duration")) {
+} else if (!strcmp(keyword, "duration") || !strcmp(keyword, 
"inpoint")) {
 char *dur_str = get_keyword(&cursor);
 int64_t dur;
 if (!file) {
-av_log(avf, AV_LOG_ERROR, "Line %d: duration without file\n",
-   line);
+av_log(avf, AV_LOG_ERROR, "Line %d: %s without file\n",
+   line, keyword);
 FAIL(AVERROR_INVALIDDATA);
 }
 if ((ret = av_parse_time(&dur, dur_str, 1)) < 0) {
-av_log(avf, AV_LOG_ERROR, "Line %d: invalid duration '%s'\n",
-   line, dur_str);
+av_log(avf, AV_LOG_ERROR, "Line %d: invalid %s '%s'\n",
+   line, keyword, dur_str);
 goto fail;
 }
-file->duration = dur;
+if (!strcmp(keyword, "duration"))
+file->duration = dur;
+else if (!strcmp(keyword, "inpoint"))
+file->inpoint = dur;
 } else if (!strcmp(keyword, "stream")) {
 if (!avformat_new_stream(avf, NULL))
 FAIL(AVERROR(ENOMEM));
@@ -428,8 +441,11 @@ static int open_next_file(AVFormatContext *avf)
 ConcatContext *cat = avf->priv_data;
 unsigned fileno = cat->cur_file - cat->files;
 
-if (cat->cur_file->duration == AV_NOPTS_VALUE)
+if (cat->cur_file->duration == AV_NOPTS_VALUE) {
 cat->cur_file->duration = cat->avf->duration;
+if (cat->cur_file->inpoint != AV_NOPTS_VALUE)
+cat->cur_file->duration -= (cat->cur_file->inpoint - 
cat->cur_file->file_start_time);
+}
 
 if (++fileno >= cat->nb_files)
 return AVERROR_EOF;
@@ -480,7 +496,7 @@ static int concat_read_packet(AVFormatContext *avf, 
AVPacket *pkt)
 {
 ConcatContext *cat = avf->priv_da

[FFmpeg-devel] [PATCHv2 2/5] concatdec: store eof condition in context

2015-07-11 Thread Marton Balint
This is needed later for outpoint support which may leave the last file in a
not-eof state.

Signed-off-by: Marton Balint 
---
 libavformat/concatdec.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index de1543a..fa85b6e 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -57,6 +57,7 @@ typedef struct {
 AVFormatContext *avf;
 int safe;
 int seekable;
+int eof;
 ConcatMatchMode stream_match_mode;
 unsigned auto_convert;
 } ConcatContext;
@@ -447,8 +448,10 @@ static int open_next_file(AVFormatContext *avf)
 cat->cur_file->duration -= (cat->cur_file->inpoint - 
cat->cur_file->file_start_time);
 }
 
-if (++fileno >= cat->nb_files)
+if (++fileno >= cat->nb_files) {
+cat->eof = 1;
 return AVERROR_EOF;
+}
 return open_file(avf, fileno);
 }
 
@@ -500,6 +503,9 @@ static int concat_read_packet(AVFormatContext *avf, 
AVPacket *pkt)
 ConcatStream *cs;
 AVStream *st;
 
+if (cat->eof)
+return AVERROR_EOF;
+
 if (!cat->avf)
 return AVERROR(EIO);
 
@@ -631,6 +637,7 @@ static int concat_seek(AVFormatContext *avf, int stream,
 cat->cur_file = cur_file_saved;
 } else {
 avformat_close_input(&cur_avf_saved);
+cat->eof = 0;
 }
 return ret;
 }
-- 
2.1.4

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


Re: [FFmpeg-devel] [PATCH] avcodec: fix micro version number decreased in merge conflict of 7871eb4.

2015-07-11 Thread Sebastien Zwickert

> On 11 Jul 2015, at 18:52, Michael Niedermayer  wrote:
> 
> On Sat, Jul 11, 2015 at 06:26:51PM +0200, Sebastien Zwickert wrote:
>> ---
>> libavcodec/version.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/libavcodec/version.h b/libavcodec/version.h
>> index ee21f5d..a9b9e25 100644
>> --- a/libavcodec/version.h
>> +++ b/libavcodec/version.h
>> @@ -30,7 +30,7 @@
>> 
>> #define LIBAVCODEC_VERSION_MAJOR 56
>> #define LIBAVCODEC_VERSION_MINOR  47
>> -#define LIBAVCODEC_VERSION_MICRO 100
>> +#define LIBAVCODEC_VERSION_MICRO 102
> 
> minor increased from 46 to 47 in 7871eb4 so micro was reset to 100
> this should have been correct unless iam missing something

Thanks to you and James for clarifying. Sure, forgot this patch :)
As videotoolbox patch depends on this part of code I want to be sure
to use the correct value. I am missing that the micro is resetting each minor 
bump.

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


Re: [FFmpeg-devel] [PATCH] vf_psnr: fix rgb channel order mixup in final log message.

2015-07-11 Thread Michael Niedermayer
On Sat, Jul 11, 2015 at 03:59:28PM +, Paul B Mahol wrote:
> Dana 11. 7. 2015. 17:21 osoba "Ronald S. Bultje" 
> napisala je:
> >
> > ---
> >  libavfilter/vf_psnr.c | 6 --
> >  1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
> > index 63baddd..9390f7c 100644
> > --- a/libavfilter/vf_psnr.c
> > +++ b/libavfilter/vf_psnr.c
> > @@ -319,9 +319,11 @@ static av_cold void uninit(AVFilterContext *ctx)
> >  char buf[256];
> >
> >  buf[0] = 0;
> > -for (j = 0; j < s->nb_components; j++)
> > +for (j = 0; j < s->nb_components; j++) {
> > +int c = s->is_rgb ? s->rgba_map[j] : j;
> >  av_strlcatf(buf, sizeof(buf), " %c:%0.2f", s->comps[j],
> > -get_psnr(s->mse_comp[j], s->nb_frames,
> s->max[j]));
> > +get_psnr(s->mse_comp[c], s->nb_frames,
> s->max[c]));
> > +}
> >  av_log(ctx, AV_LOG_INFO, "PSNR%s average:%0.2f min:%0.2f
> max:%0.2f\n",
> > buf,
> > get_psnr(s->mse, s->nb_frames, s->average_max),
> > --
> > 2.1.2
> >
> >
> 
> LGTM

applied

thanks

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

I have often repented speaking, but never of holding my tongue.
-- Xenocrates


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


Re: [FFmpeg-devel] [libav-devel] [PATCH 2/2] riff: Use the correct logging context

2015-07-11 Thread Michael Niedermayer
On Sat, Jul 11, 2015 at 05:22:04PM +0200, Andreas Cadhalpun wrote:
[...]
> This looks good.
> It has the nice side effect, that it makes it possible to get an explode
> mode working in ff_get_wav_header.
> (Attached is this patch rebased on ffmpeg, since my next riff patch
> depends on this.)

should be ok but please fix these before pushing:

libavformat/asfdec_o.c: In function ‘asf_read_stream_properties’:
libavformat/asfdec_o.c:755:9: warning: passing argument 1 of 
‘ff_get_wav_header’ from incompatible pointer type [enabled by default]
libavformat/riff.h:65:5: note: expected ‘struct AVFormatContext *’ but argument 
is of type ‘struct AVIOContext *’
libavformat/asfdec_o.c:755:9: warning: passing argument 2 of 
‘ff_get_wav_header’ from incompatible pointer type [enabled by default]
libavformat/riff.h:65:5: note: expected ‘struct AVIOContext *’ but argument is 
of type ‘struct AVCodecContext *’
libavformat/asfdec_o.c:755:9: warning: passing argument 3 of 
‘ff_get_wav_header’ makes pointer from integer without a cast [enabled by 
default]
libavformat/riff.h:65:5: note: expected ‘struct AVCodecContext *’ but argument 
is of type ‘uint32_t’
libavformat/asfdec_o.c:755:9: error: too few arguments to function 
‘ff_get_wav_header’
libavformat/riff.h:65:5: note: declared here
make: *** [libavformat/asfdec_o.o] Error 1



[...]

-- 
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


[FFmpeg-devel] [PATCH] mxfdec: calculate the index in display order

2015-07-11 Thread Marton Balint
This should fix seeking for open GOP files as well.

Signed-off-by: Marton Balint 
---
 libavformat/mxfdec.c| 23 ---
 tests/ref/seek/lavf-mxf |  2 +-
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index b3c25b7..27dd5bc 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -233,6 +233,7 @@ typedef struct MXFIndexTable {
 int nb_segments;
 MXFIndexTableSegment **segments;/* sorted by IndexStartPosition */
 AVIndexEntry *fake_index;   /* used for calling 
ff_index_search_timestamp() */
+int8_t *offsets;/* temporal offsets for display order to 
stored order conversion */
 } MXFIndexTable;
 
 typedef struct MXFContext {
@@ -1334,6 +1335,7 @@ static int mxf_compute_ptses_fake_index(MXFContext *mxf, 
MXFIndexTable *index_ta
 {
 int i, j, x;
 int8_t max_temporal_offset = -128;
+uint8_t *flags;
 
 /* first compute how many entries we have */
 for (i = 0; i < index_table->nb_segments; i++) {
@@ -1352,8 +1354,12 @@ static int mxf_compute_ptses_fake_index(MXFContext *mxf, 
MXFIndexTable *index_ta
 return 0;
 
 if (!(index_table->ptses  = av_calloc(index_table->nb_ptses, 
sizeof(int64_t))) ||
-!(index_table->fake_index = av_calloc(index_table->nb_ptses, 
sizeof(AVIndexEntry {
+!(index_table->fake_index = av_calloc(index_table->nb_ptses, 
sizeof(AVIndexEntry))) ||
+!(index_table->offsets= av_calloc(index_table->nb_ptses, 
sizeof(int8_t))) ||
+!(flags   = av_calloc(index_table->nb_ptses, 
sizeof(uint8_t {
 av_freep(&index_table->ptses);
+av_freep(&index_table->fake_index);
+av_freep(&index_table->offsets);
 return AVERROR(ENOMEM);
 }
 
@@ -1411,8 +1417,7 @@ static int mxf_compute_ptses_fake_index(MXFContext *mxf, 
MXFIndexTable *index_ta
 break;
 }
 
-index_table->fake_index[x].timestamp = x;
-index_table->fake_index[x].flags = !(s->flag_entries[j] & 0x30) ? 
AVINDEX_KEYFRAME : 0;
+flags[x] = !(s->flag_entries[j] & 0x30) ? AVINDEX_KEYFRAME : 0;
 
 if (index < 0 || index >= index_table->nb_ptses) {
 av_log(mxf->fc, AV_LOG_ERROR,
@@ -1421,11 +1426,20 @@ static int mxf_compute_ptses_fake_index(MXFContext 
*mxf, MXFIndexTable *index_ta
 continue;
 }
 
+index_table->offsets[x] = offset;
 index_table->ptses[index] = x;
 max_temporal_offset = FFMAX(max_temporal_offset, offset);
 }
 }
 
+/* calculate the fake index table in display order */
+for (x = 0; x < index_table->nb_ptses; x++) {
+index_table->fake_index[x].timestamp = x;
+if (index_table->ptses[x] != AV_NOPTS_VALUE)
+index_table->fake_index[index_table->ptses[x]].flags = flags[x];
+}
+av_freep(&flags);
+
 index_table->first_dts = -max_temporal_offset;
 
 return 0;
@@ -3085,6 +3099,7 @@ static int mxf_read_close(AVFormatContext *s)
 av_freep(&mxf->index_tables[i].segments);
 av_freep(&mxf->index_tables[i].ptses);
 av_freep(&mxf->index_tables[i].fake_index);
+av_freep(&mxf->index_tables[i].offsets);
 }
 }
 av_freep(&mxf->index_tables);
@@ -3158,6 +3173,8 @@ static int mxf_read_seek(AVFormatContext *s, int 
stream_index, int64_t sample_ti
 /* behave as if we have a proper index */
 if ((sample_time = ff_index_search_timestamp(t->fake_index, 
t->nb_ptses, sample_time, flags)) < 0)
 return sample_time;
+/* get the stored order index from the display order index */
+sample_time += t->offsets[sample_time];
 } else {
 /* no IndexEntryArray (one or more CBR segments)
  * make sure we don't seek past the end */
diff --git a/tests/ref/seek/lavf-mxf b/tests/ref/seek/lavf-mxf
index f1aaa19..ea0e0b6 100644
--- a/tests/ref/seek/lavf-mxf
+++ b/tests/ref/seek/lavf-mxf
@@ -43,6 +43,6 @@ ret:-1 st: 1 flags:0  ts: 2.671667
 ret: 0 st: 1 flags:1  ts: 1.565833
 ret: 0 st: 0 flags:1 dts: 0.84 pts: 0.96 pos: 460800 size: 
24711
 ret: 0 st:-1 flags:0  ts: 0.460008
-ret: 0 st: 0 flags:1 dts: 0.84 pts: 0.96 pos: 460800 size: 
24711
+ret: 0 st: 0 flags:1 dts: 0.36 pts: 0.48 pos: 211968 size: 
24786
 ret: 0 st:-1 flags:1  ts:-0.645825
 ret: 0 st: 0 flags:1 dts:-0.04 pts: 0.00 pos:   6656 size: 
24801
-- 
2.1.4

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


Re: [FFmpeg-devel] [PATCH] vf_psnr: always calculate MSE over full pixel range.

2015-07-11 Thread Michael Niedermayer
On Sat, Jul 11, 2015 at 02:50:52PM +, Paul B Mahol wrote:
> Dana 11. 7. 2015. 13:23 osoba "Ronald S. Bultje" 
> napisala je:
> >
> > This makes the output compatible with that of pretty much any other
> > tool that calculates PSNR.
> > ---
> >  libavfilter/vf_psnr.c | 31 ---
> >  1 file changed, 4 insertions(+), 27 deletions(-)
> >
> > diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
> > index 0c2c950..cc4546a 100644
> > --- a/libavfilter/vf_psnr.c
> > +++ b/libavfilter/vf_psnr.c
> > @@ -260,33 +260,10 @@ static int config_input_ref(AVFilterLink *inlink)
> >  return AVERROR(EINVAL);
> >  }
> >
> > -switch (inlink->format) {
> > -case AV_PIX_FMT_GRAY8:
> > -case AV_PIX_FMT_GRAY16:
> > -case AV_PIX_FMT_GBRP:
> > -case AV_PIX_FMT_GBRP9:
> > -case AV_PIX_FMT_GBRP10:
> > -case AV_PIX_FMT_GBRP12:
> > -case AV_PIX_FMT_GBRP14:
> > -case AV_PIX_FMT_GBRP16:
> > -case AV_PIX_FMT_GBRAP:
> > -case AV_PIX_FMT_GBRAP16:
> > -case AV_PIX_FMT_YUVJ411P:
> > -case AV_PIX_FMT_YUVJ420P:
> > -case AV_PIX_FMT_YUVJ422P:
> > -case AV_PIX_FMT_YUVJ440P:
> > -case AV_PIX_FMT_YUVJ444P:
> > -s->max[0] = (1 << (desc->comp[0].depth_minus1 + 1)) - 1;
> > -s->max[1] = (1 << (desc->comp[1].depth_minus1 + 1)) - 1;
> > -s->max[2] = (1 << (desc->comp[2].depth_minus1 + 1)) - 1;
> > -s->max[3] = (1 << (desc->comp[3].depth_minus1 + 1)) - 1;
> > -break;
> > -default:
> > -s->max[0] = 235 * (1 << (desc->comp[0].depth_minus1 - 7));
> > -s->max[1] = 240 * (1 << (desc->comp[1].depth_minus1 - 7));
> > -s->max[2] = 240 * (1 << (desc->comp[2].depth_minus1 - 7));
> > -s->max[3] = (1 << (desc->comp[3].depth_minus1 + 1)) - 1;
> > -}
> > +s->max[0] = (1 << (desc->comp[0].depth_minus1 + 1)) - 1;
> > +s->max[1] = (1 << (desc->comp[1].depth_minus1 + 1)) - 1;
> > +s->max[2] = (1 << (desc->comp[2].depth_minus1 + 1)) - 1;
> > +s->max[3] = (1 << (desc->comp[3].depth_minus1 + 1)) - 1;
> >
> >  s->is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0;
> >  s->comps[0] = s->is_rgb ? 'r' : 'y' ;
> > --
> > 2.1.2
> >
> 
> LGTM

applied

thanks

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

There will always be a question for which you do not know the correct answer.


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


Re: [FFmpeg-devel] [PATCH] avcodec: fix micro version number decreased in merge conflict of 7871eb4.

2015-07-11 Thread Michael Niedermayer
On Sat, Jul 11, 2015 at 06:26:51PM +0200, Sebastien Zwickert wrote:
> ---
>  libavcodec/version.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/version.h b/libavcodec/version.h
> index ee21f5d..a9b9e25 100644
> --- a/libavcodec/version.h
> +++ b/libavcodec/version.h
> @@ -30,7 +30,7 @@
>  
>  #define LIBAVCODEC_VERSION_MAJOR 56
>  #define LIBAVCODEC_VERSION_MINOR  47
> -#define LIBAVCODEC_VERSION_MICRO 100
> +#define LIBAVCODEC_VERSION_MICRO 102

minor increased from 46 to 47 in 7871eb4 so micro was reset to 100
this should have been correct unless iam missing something

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

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.


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


Re: [FFmpeg-devel] [PATCH] avcodec: fix micro version number decreased in merge conflict of 7871eb4.

2015-07-11 Thread James Almer
On 11/07/15 1:26 PM, Sebastien Zwickert wrote:
> ---
>  libavcodec/version.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/version.h b/libavcodec/version.h
> index ee21f5d..a9b9e25 100644
> --- a/libavcodec/version.h
> +++ b/libavcodec/version.h
> @@ -30,7 +30,7 @@
>  
>  #define LIBAVCODEC_VERSION_MAJOR 56
>  #define LIBAVCODEC_VERSION_MINOR  47
> -#define LIBAVCODEC_VERSION_MICRO 100
> +#define LIBAVCODEC_VERSION_MICRO 102

The library was bumped from 56.46.102 to 56.47.100. Micro is always reset
when there's a minor bump.

This patch is not needed.

>  
>  #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
> LIBAVCODEC_VERSION_MINOR, \
> 

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


Re: [FFmpeg-devel] [PATCH-v2] avcodec: add new Videotoolbox hwaccel.

2015-07-11 Thread Sebastien Zwickert

> On 05 Jul 2015, at 16:41, Sebastien Zwickert  wrote:
> 
> As VDA is a wrapper of VideoToolbox framework, the changes base vda 
> implementation
> upon the videotoolbox implementation to factorize common part of code.
> 
> The changes allow the user to request a custom pixel format to the decoder
> via a CLI option called videotoolbox_pixfmt.
> 
> ---
> Changelog|   1 +
> MAINTAINERS  |   1 +
> Makefile |   5 +-
> configure|  19 +-
> ffmpeg.h |   3 +
> ffmpeg_opt.c |   8 +-
> ffmpeg_vda.c | 136 -
> ffmpeg_videotoolbox.c| 187 ++
> libavcodec/Makefile  |  12 +-
> libavcodec/allcodecs.c   |   5 +
> libavcodec/h263dec.c |   3 +
> libavcodec/h264_slice.c  |   4 +
> libavcodec/mpeg12dec.c   |   3 +
> libavcodec/vda.c |   2 +-
> libavcodec/vda_h264.c| 154 +
> libavcodec/{vda_internal.h => vda_vt_internal.h} |  32 +-
> libavcodec/version.h |   2 +-
> libavcodec/videotoolbox.c| 690 +++
> libavcodec/videotoolbox.h| 126 +
> libavutil/pixdesc.c  |   4 +
> libavutil/pixfmt.h   |   2 +
> 21 files changed, 1112 insertions(+), 287 deletions(-)
> delete mode 100644 ffmpeg_vda.c
> create mode 100644 ffmpeg_videotoolbox.c
> rename libavcodec/{vda_internal.h => vda_vt_internal.h} (50%)
> create mode 100644 libavcodec/videotoolbox.c
> create mode 100644 libavcodec/videotoolbox.h

If no objection I’ll push this patch rebased in a few days.

> [...]

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


Re: [FFmpeg-devel] [PATCH] lavfi/removegrain: add x86 and x86_64 SSE2 functions

2015-07-11 Thread James Almer
On 11/07/15 10:40 AM, James Darnley wrote:
> Speed of all modes increased by a factor between 7.4 and 19.8 largely 
> depending
> on whether bytes are unpacked into words.  Modes 2, 3, and 4 have been sped-up
> by a factor of 43 (thanks quick sort!)
> 
> All modes are available on x86_64 but only modes 1, 10, 11, 12, 13, 14, 19, 
> 20,
> 21, and 22 are available on x86 due to the number of SIMD registers used.
> ---
>  libavfilter/removegrain.h |   40 ++
>  libavfilter/vf_removegrain.c  |   38 +-
>  libavfilter/x86/Makefile  |2 +
>  libavfilter/x86/vf_removegrain.asm| 1215 
> +
>  libavfilter/x86/vf_removegrain_init.c |  128 
>  5 files changed, 1404 insertions(+), 19 deletions(-)
>  create mode 100644 libavfilter/removegrain.h
>  create mode 100644 libavfilter/x86/vf_removegrain.asm
>  create mode 100644 libavfilter/x86/vf_removegrain_init.c
> 
> diff --git a/libavfilter/removegrain.h b/libavfilter/removegrain.h
> new file mode 100644
> index 000..60401fb
> --- /dev/null
> +++ b/libavfilter/removegrain.h
> @@ -0,0 +1,40 @@
> +/*
> + * Copyright (c) 2015 Paul B Mahol
> + * Copyright (c) 2015 James Darnley
> + *
> + * 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 "avfilter.h"
> +
> +typedef struct RemoveGrainContext {
> +const AVClass *class;
> +
> +int mode[4];
> +
> +int nb_planes;
> +int planewidth[4];
> +int planeheight[4];
> +int skip_even;
> +int skip_odd;
> +
> +int (*rg[4])(int c, int a1, int a2, int a3, int a4, int a5, int a6, int 
> a7, int a8);
> +
> +void (*fl[4])(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels);
> +} RemoveGrainContext;
> +
> +void ff_removegrain_init_x86(RemoveGrainContext *rg);
> diff --git a/libavfilter/vf_removegrain.c b/libavfilter/vf_removegrain.c
> index 77b3561..da17f6a 100644
> --- a/libavfilter/vf_removegrain.c
> +++ b/libavfilter/vf_removegrain.c
> @@ -2,6 +2,7 @@
>   * Copyright (c) 2012 Laurent de Soras
>   * Copyright (c) 2013 Fredrik Mellbin
>   * Copyright (c) 2015 Paul B Mahol
> + * Copyright (c) 2015 James Darnley
>   *
>   * This file is part of FFmpeg.
>   *
> @@ -20,32 +21,15 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 
> USA
>   */
>  
> -/*
> - * TODO: add SIMD
> - */
> -
>  #include "libavutil/imgutils.h"
>  #include "libavutil/opt.h"
>  #include "libavutil/pixdesc.h"
>  #include "avfilter.h"
>  #include "formats.h"
>  #include "internal.h"
> +#include "removegrain.h"
>  #include "video.h"
>  
> -typedef struct RemoveGrainContext {
> -const AVClass *class;
> -
> -int mode[4];
> -
> -int nb_planes;
> -int planewidth[4];
> -int planeheight[4];
> -int skip_even;
> -int skip_odd;
> -
> -int (*rg[4])(int c, int a1, int a2, int a3, int a4, int a5, int a6, int 
> a7, int a8);
> -} RemoveGrainContext;
> -
>  #define OFFSET(x) offsetof(RemoveGrainContext, x)
>  #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
>  
> @@ -142,6 +126,7 @@ static int mode05(int c, int a1, int a2, int a3, int a4, 
> int a5, int a6, int a7,
>  
>  const int mindiff = FFMIN(FFMIN(c1, c2), FFMIN(c3, c4));
>  
> +/* When adding SIMD notice the return order here: 4, 2, 3, 1. */
>  if (mindiff == c4) {
>  return av_clip(c, mi4, ma4);
>  } else if (mindiff == c2) {
> @@ -524,6 +509,9 @@ static int config_input(AVFilterLink *inlink)
>  }
>  }
>  
> +if (ARCH_X86)
> +ff_removegrain_init_x86(s);
> +
>  return 0;
>  }
>  
> @@ -566,7 +554,19 @@ static int filter_slice(AVFilterContext *ctx, void *arg, 
> int jobnr, int nb_jobs)
>  }
>  
>  *dst++ = *src++;
> -for (x = 1; x < s->planewidth[i] - 1; x++) {
> +
> +if (s->fl[i]) {
> +int w_asm = (s->planewidth[i] - 2) & ~15;

I don't thinks this belongs here. If you add an AVX2 version as you intended,
wouldn't this need to be 31?

A wrapper function to have this code in the x86 folder may be the best option.

> +
> +s->fl[i](dst, src, in->linesize[i], w_asm);
> +
> +x = 1 + w_asm;
> +dst += w_asm;
> +src += w_asm;
> +} else
> +   

[FFmpeg-devel] [PATCH] avcodec: fix micro version number decreased in merge conflict of 7871eb4.

2015-07-11 Thread Sebastien Zwickert
---
 libavcodec/version.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/version.h b/libavcodec/version.h
index ee21f5d..a9b9e25 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -30,7 +30,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR 56
 #define LIBAVCODEC_VERSION_MINOR  47
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 102
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
-- 
2.3.2 (Apple Git-55)

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


[FFmpeg-devel] [PATCH] lavfi/removegrain: add x86 and x86_64 SSE2 functions

2015-07-11 Thread James Darnley
Speed of all modes increased by a factor between 7.4 and 19.8 largely depending
on whether bytes are unpacked into words.  Modes 2, 3, and 4 have been sped-up
by a factor of 43 (thanks quick sort!)

All modes are available on x86_64 but only modes 1, 10, 11, 12, 13, 14, 19, 20,
21, and 22 are available on x86 due to the number of SIMD registers used.
---
Added correct GPL license header to asm file.  Added correct LGPL header to init
file.  Noted GPL file in LICENSE.md.  Made sure that asm file is only used when
GPL is set.  Added guards around assignments in init function.

 LICENSE.md|1 +
 libavfilter/removegrain.h |   40 ++
 libavfilter/vf_removegrain.c  |   38 +-
 libavfilter/x86/Makefile  |4 +
 libavfilter/x86/vf_removegrain.asm| 1227 +
 libavfilter/x86/vf_removegrain_init.c |  150 
 6 files changed, 1441 insertions(+), 19 deletions(-)
 create mode 100644 libavfilter/removegrain.h
 create mode 100644 libavfilter/x86/vf_removegrain.asm
 create mode 100644 libavfilter/x86/vf_removegrain_init.c

diff --git a/LICENSE.md b/LICENSE.md
index 545d366..1a6e3b3 100644
--- a/LICENSE.md
+++ b/LICENSE.md
@@ -16,6 +16,7 @@ Specifically, the GPL parts of FFmpeg are:
 - optional x86 optimizations in the files
   - `libavcodec/x86/flac_dsp_gpl.asm`
   - `libavcodec/x86/idct_mmx.c`
+  - `libavfilter/x86/vf_removegrain.asm`
 - libutvideo encoding/decoding wrappers in
   `libavcodec/libutvideo*.cpp`
 - the X11 grabber in `libavdevice/x11grab.c`
diff --git a/libavfilter/removegrain.h b/libavfilter/removegrain.h
new file mode 100644
index 000..60401fb
--- /dev/null
+++ b/libavfilter/removegrain.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2015 Paul B Mahol
+ * Copyright (c) 2015 James Darnley
+ *
+ * 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 "avfilter.h"
+
+typedef struct RemoveGrainContext {
+const AVClass *class;
+
+int mode[4];
+
+int nb_planes;
+int planewidth[4];
+int planeheight[4];
+int skip_even;
+int skip_odd;
+
+int (*rg[4])(int c, int a1, int a2, int a3, int a4, int a5, int a6, int 
a7, int a8);
+
+void (*fl[4])(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels);
+} RemoveGrainContext;
+
+void ff_removegrain_init_x86(RemoveGrainContext *rg);
diff --git a/libavfilter/vf_removegrain.c b/libavfilter/vf_removegrain.c
index 77b3561..da17f6a 100644
--- a/libavfilter/vf_removegrain.c
+++ b/libavfilter/vf_removegrain.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2012 Laurent de Soras
  * Copyright (c) 2013 Fredrik Mellbin
  * Copyright (c) 2015 Paul B Mahol
+ * Copyright (c) 2015 James Darnley
  *
  * This file is part of FFmpeg.
  *
@@ -20,32 +21,15 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-/*
- * TODO: add SIMD
- */
-
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
 #include "formats.h"
 #include "internal.h"
+#include "removegrain.h"
 #include "video.h"
 
-typedef struct RemoveGrainContext {
-const AVClass *class;
-
-int mode[4];
-
-int nb_planes;
-int planewidth[4];
-int planeheight[4];
-int skip_even;
-int skip_odd;
-
-int (*rg[4])(int c, int a1, int a2, int a3, int a4, int a5, int a6, int 
a7, int a8);
-} RemoveGrainContext;
-
 #define OFFSET(x) offsetof(RemoveGrainContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
@@ -142,6 +126,7 @@ static int mode05(int c, int a1, int a2, int a3, int a4, 
int a5, int a6, int a7,
 
 const int mindiff = FFMIN(FFMIN(c1, c2), FFMIN(c3, c4));
 
+/* When adding SIMD notice the return order here: 4, 2, 3, 1. */
 if (mindiff == c4) {
 return av_clip(c, mi4, ma4);
 } else if (mindiff == c2) {
@@ -524,6 +509,9 @@ static int config_input(AVFilterLink *inlink)
 }
 }
 
+if (ARCH_X86)
+ff_removegrain_init_x86(s);
+
 return 0;
 }
 
@@ -566,7 +554,19 @@ static int filter_slice(AVFilterContext *ctx, void *arg, 
int jobnr, int nb_jobs)
 }
 
 *dst++ = *src++;
-for (x = 1; x < s->planewidth[i] - 1; x++) {
+
+if (s->fl[i]) {
+int w_asm = (s->planewidth[i] - 2) &

Re: [FFmpeg-devel] [libav-devel] [PATCH] riffdec: error out on negative bit rate

2015-07-11 Thread Andreas Cadhalpun
On 11.07.2015 18:13, Luca Barbato wrote:
> On 11/07/15 17:22, Andreas Cadhalpun wrote:
>> On 11.07.2015 11:44, Luca Barbato wrote:
>>> On 11/07/15 01:26, Andreas Cadhalpun wrote:
 Note however that the explode mode doesn't necessarily work, because e.g.
 the avi demuxer doesn't set err_recognition for the AVCodecContext.
>>>
>>> It wouldn't work as intended, setting the bit_rate to 0 thought, does
>>> prevent an issue with g726 but probably that chunk of code could be removed.
>>>
>>> Some patches following...
>>
>> After your riff patch, it is possible to the the explode mode working.
>> Updated patch attached.
>>
> 
> @@ -79,6 +79,7 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
>AVCodecContext *codec, int size)
>  {
>  int id;
> +uint64_t bitrate;
> 
>  if (size < 14)
>  return AVERROR_INVALIDDATA;
> @@ -87,7 +88,7 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
>  codec->codec_type  = AVMEDIA_TYPE_AUDIO;
>  codec->channels= avio_rl16(pb);
>  codec->sample_rate = avio_rl32(pb);
> -codec->bit_rate= avio_rl32(pb) * 8;
> +bitrate= avio_rl32(pb) * 8;
>  codec->block_align = avio_rl16(pb);
>  if (size == 14) {  /* We're dealing with plain vanilla WAVEFORMAT */
>  codec->bits_per_coded_sample = 8;
> @@ -124,6 +125,23 @@ int ff_get_wav_header(AVFormatContext *s,
> AVIOContext *pb,
>  if (size > 0)
>  avio_skip(pb, size);
>  }
> +
> +if (bitrate > INT_MAX) {
> +if (s->error_recognition & AV_EF_EXPLODE) {
> +av_log(s, AV_LOG_ERROR,
> +   "The bitrate %"PRIu64" is too large.\n",
> +bitrate);
> +return AVERROR_INVALIDDATA;
> +} else {
> +av_log(s, AV_LOG_WARNING,
> +   "The bitrate %"PRIu64" is too large, resetting to 0.",
> +   bitrate);
> +codec->bit_rate = 0;
> +}
> +} else {
> +codec->bit_rate = bitrate;
> +}
> +
> 
> This is possibly safer, the sample_rate field might enjoy the same
> treatment, bonus point for whoever know which is the correct upper bound
> for those fields =)

That's fine as well (and avoids said undefined integer overflow).

Best regards,
Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH-v2] avcodec: add new Videotoolbox hwaccel.

2015-07-11 Thread Sebastien Zwickert

> On 07 Jul 2015, at 23:03, Michael Niedermayer  wrote:
> 
> On Sun, Jul 05, 2015 at 05:03:44PM +0200, Sebastien Zwickert wrote:
>> 
>>> On 05 Jul 2015, at 16:41, Sebastien Zwickert  wrote:
>>> 
>>> delete mode 100644 ffmpeg_vda.c
>>> create mode 100644 ffmpeg_videotoolbox.c
>> 
>> -M as arguments to the format-patch CLI does not detect these as rename...
>> 
>>> rename libavcodec/{vda_internal.h => vda_vt_internal.h} (50%)
>> 
>> while these changes are detected.
>> 
>> 
>> Have I missed something ?
> 
> git doesnt always detect every move/copy, it might be possible to
> tune some parameters to make it detect more aggressively but not sure
> thats worth

Thanks for explanation...

> if you think a diff between the 2 would be helpfull to review then
> attaching that by hand is likely quicker than trying to find
> out how to make git do it


and thanks for the clue. In attachment a diff given by the following git 
command:
git diff master:ffmpeg_vda.c ffmpeg_videotoolbox.c




ffmpeg_videotoolbox.diff
Description: Binary data


—
Sebastien Zwickert

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


Re: [FFmpeg-devel] [PATCH] vf_psnr: fix rgb channel order mixup in final log message.

2015-07-11 Thread Paul B Mahol
Dana 11. 7. 2015. 17:21 osoba "Ronald S. Bultje" 
napisala je:
>
> ---
>  libavfilter/vf_psnr.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
> index 63baddd..9390f7c 100644
> --- a/libavfilter/vf_psnr.c
> +++ b/libavfilter/vf_psnr.c
> @@ -319,9 +319,11 @@ static av_cold void uninit(AVFilterContext *ctx)
>  char buf[256];
>
>  buf[0] = 0;
> -for (j = 0; j < s->nb_components; j++)
> +for (j = 0; j < s->nb_components; j++) {
> +int c = s->is_rgb ? s->rgba_map[j] : j;
>  av_strlcatf(buf, sizeof(buf), " %c:%0.2f", s->comps[j],
> -get_psnr(s->mse_comp[j], s->nb_frames,
s->max[j]));
> +get_psnr(s->mse_comp[c], s->nb_frames,
s->max[c]));
> +}
>  av_log(ctx, AV_LOG_INFO, "PSNR%s average:%0.2f min:%0.2f
max:%0.2f\n",
> buf,
> get_psnr(s->mse, s->nb_frames, s->average_max),
> --
> 2.1.2
>
>

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


Re: [FFmpeg-devel] [libav-devel] [PATCH] riffdec: error out on negative bit rate

2015-07-11 Thread Andreas Cadhalpun
On 11.07.2015 11:44, Luca Barbato wrote:
> On 11/07/15 01:26, Andreas Cadhalpun wrote:
>> Note however that the explode mode doesn't necessarily work, because e.g.
>> the avi demuxer doesn't set err_recognition for the AVCodecContext.
> 
> It wouldn't work as intended, setting the bit_rate to 0 thought, does
> prevent an issue with g726 but probably that chunk of code could be removed.
> 
> Some patches following...

After your riff patch, it is possible to the the explode mode working.
Updated patch attached.

Best regards,
Andreas

>From e7634d4f175841285d5481ef951c62c704efbcc3 Mon Sep 17 00:00:00 2001
From: Andreas Cadhalpun 
Date: Sat, 11 Jul 2015 00:09:46 +0200
Subject: [PATCH] riffdec: prevent negative bit rate

Signed-off-by: Andreas Cadhalpun 
---
 libavformat/riffdec.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c
index 5ae9163..f798baf 100644
--- a/libavformat/riffdec.c
+++ b/libavformat/riffdec.c
@@ -107,6 +107,14 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
 codec->bit_rate= avio_rb32(pb) * 8;
 codec->block_align = avio_rb16(pb);
 }
+if (codec->bit_rate < 0) {
+av_log(s, AV_LOG_WARNING,
+   "Invalid bit rate: %d\n", codec->bit_rate);
+if (s->error_recognition & AV_EF_EXPLODE)
+return AVERROR_INVALIDDATA;
+else
+codec->bit_rate = 0;
+}
 if (size == 14) {  /* We're dealing with plain vanilla WAVEFORMAT */
 codec->bits_per_coded_sample = 8;
 } else {
-- 
2.1.4

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


Re: [FFmpeg-devel] [libav-devel] [PATCH 2/2] riff: Use the correct logging context

2015-07-11 Thread Andreas Cadhalpun
On 11.07.2015 13:08, Luca Barbato wrote:
> ---
>  libavformat/asfdec.c  | 2 +-
>  libavformat/avidec.c  | 2 +-
>  libavformat/dxa.c | 2 +-
>  libavformat/matroskadec.c | 2 +-
>  libavformat/mov.c | 2 +-
>  libavformat/riff.h| 2 +-
>  libavformat/riffdec.c | 5 +++--
>  libavformat/wavdec.c  | 4 ++--
>  libavformat/wtv.c | 2 +-
>  libavformat/xwma.c| 2 +-
>  10 files changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
> index 01d753f..8e706fb 100644
> --- a/libavformat/asfdec.c
> +++ b/libavformat/asfdec.c
> @@ -752,7 +752,7 @@ static int asf_read_stream_properties(AVFormatContext *s, 
> const GUIDParseTable *
>  switch (type) {
>  case AVMEDIA_TYPE_AUDIO:
>  asf_st->type = AVMEDIA_TYPE_AUDIO;
> -if ((ret = ff_get_wav_header(pb, st->codec, ts_data_len)) < 0)
> +if ((ret = ff_get_wav_header(s, pb, st->codec, ts_data_len)) < 0)
>  return ret;
>  break;
>  case AVMEDIA_TYPE_VIDEO:
> diff --git a/libavformat/avidec.c b/libavformat/avidec.c
> index 4caba46..8639765 100644
> --- a/libavformat/avidec.c
> +++ b/libavformat/avidec.c
> @@ -708,7 +708,7 @@ static int avi_read_header(AVFormatContext *s)
>  //avio_skip(pb, size - 5 * 4);
>  break;
>  case AVMEDIA_TYPE_AUDIO:
> -ret = ff_get_wav_header(pb, st->codec, size);
> +ret = ff_get_wav_header(s, pb, st->codec, size);
>  if (ret < 0)
>  return ret;
>  ast->dshow_block_align = st->codec->block_align;
> diff --git a/libavformat/dxa.c b/libavformat/dxa.c
> index 4a4d7c2..34085cf 100644
> --- a/libavformat/dxa.c
> +++ b/libavformat/dxa.c
> @@ -106,7 +106,7 @@ static int dxa_read_header(AVFormatContext *s)
>  ast = avformat_new_stream(s, NULL);
>  if (!ast)
>  return -1;
> -ret = ff_get_wav_header(pb, ast->codec, fsize);
> +ret = ff_get_wav_header(s, pb, ast->codec, fsize);
>  if (ret < 0)
>  return ret;
>  if (ast->codec->sample_rate > 0)
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index 34bbf37..0425d24 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -1597,7 +1597,7 @@ static int matroska_parse_tracks(AVFormatContext *s)
>  ffio_init_context(&b, track->codec_priv.data,
>track->codec_priv.size,
>0, NULL, NULL, NULL, NULL);
> -ret = ff_get_wav_header(&b, st->codec, track->codec_priv.size);
> +ret = ff_get_wav_header(s, &b, st->codec, 
> track->codec_priv.size);
>  if (ret < 0)
>  return ret;
>  codec_id = st->codec->codec_id;
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index d075645..66a0391 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -758,7 +758,7 @@ static int mov_read_wfex(MOVContext *c, AVIOContext *pb, 
> MOVAtom atom)
>  return 0;
>  st = c->fc->streams[c->fc->nb_streams-1];
>  
> -return ff_get_wav_header(pb, st->codec, atom.size);
> +return ff_get_wav_header(c->fc, pb, st->codec, atom.size);
>  }
>  
>  static int mov_read_pasp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
> diff --git a/libavformat/riff.h b/libavformat/riff.h
> index ddfb0fa..5bac95a 100644
> --- a/libavformat/riff.h
> +++ b/libavformat/riff.h
> @@ -48,7 +48,7 @@ int ff_get_bmp_header(AVIOContext *pb, AVStream *st);
>  void ff_put_bmp_header(AVIOContext *pb, AVCodecContext *enc, const 
> AVCodecTag *tags, int for_asf);
>  int ff_put_wav_header(AVIOContext *pb, AVCodecContext *enc);
>  enum AVCodecID ff_wav_codec_get_id(unsigned int tag, int bps);
> -int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size);
> +int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecContext 
> *codec, int size);
>  
>  extern const AVCodecTag ff_codec_bmp_tags[];
>  extern const AVCodecTag ff_codec_wav_tags[];
> diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c
> index 2c43afc..fc6f76c 100644
> --- a/libavformat/riffdec.c
> +++ b/libavformat/riffdec.c
> @@ -75,7 +75,8 @@ static void parse_waveformatex(AVIOContext *pb, 
> AVCodecContext *c)
>  }
>  }
>  
> -int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
> +int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
> +  AVCodecContext *codec, int size)
>  {
>  int id;
>  
> @@ -124,7 +125,7 @@ int ff_get_wav_header(AVIOContext *pb, AVCodecContext 
> *codec, int size)
>  avio_skip(pb, size);
>  }
>  if (codec->sample_rate <= 0) {
> -av_log(NULL, AV_LOG_ERROR,
> +av_log(s, AV_LOG_ERROR,
> "Invalid sample rate: %d\n", codec->sample_rate);
>  return AVERROR_INVALIDDATA;
>  }
> d

[FFmpeg-devel] [PATCH] vf_psnr: fix rgb channel order mixup in final log message.

2015-07-11 Thread Ronald S. Bultje
---
 libavfilter/vf_psnr.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
index 63baddd..9390f7c 100644
--- a/libavfilter/vf_psnr.c
+++ b/libavfilter/vf_psnr.c
@@ -319,9 +319,11 @@ static av_cold void uninit(AVFilterContext *ctx)
 char buf[256];
 
 buf[0] = 0;
-for (j = 0; j < s->nb_components; j++)
+for (j = 0; j < s->nb_components; j++) {
+int c = s->is_rgb ? s->rgba_map[j] : j;
 av_strlcatf(buf, sizeof(buf), " %c:%0.2f", s->comps[j],
-get_psnr(s->mse_comp[j], s->nb_frames, s->max[j]));
+get_psnr(s->mse_comp[c], s->nb_frames, s->max[c]));
+}
 av_log(ctx, AV_LOG_INFO, "PSNR%s average:%0.2f min:%0.2f max:%0.2f\n",
buf,
get_psnr(s->mse, s->nb_frames, s->average_max),
-- 
2.1.2

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


Re: [FFmpeg-devel] [libav-devel] [PATCH] riffdec: error out on negative bit rate

2015-07-11 Thread Andreas Cadhalpun
On 11.07.2015 12:30, Luca Barbato wrote:
> On 11/07/15 11:58, Kostya Shishkov wrote:
>> On Sat, Jul 11, 2015 at 11:35:44AM +0200, Luca Barbato wrote:
>>> On 11/07/15 00:39, Andreas Cadhalpun wrote:
 Signed-off-by: Andreas Cadhalpun 
 ---
  libavformat/riffdec.c | 5 +
  1 file changed, 5 insertions(+)

 diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c
 index eebd8ed..be55699 100644
 --- a/libavformat/riffdec.c
 +++ b/libavformat/riffdec.c
 @@ -106,6 +106,11 @@ int ff_get_wav_header(AVIOContext *pb, AVCodecContext 
 *codec, int size, int big_
  codec->bit_rate= avio_rb32(pb) * 8;
  codec->block_align = avio_rb16(pb);
  }
 +if (codec->bit_rate < 0) {
 +av_log(NULL, AV_LOG_ERROR,
 +   "Invalid bit rate: %d\n", codec->bit_rate);
 +return AVERROR_INVALIDDATA;
 +}
>>>
>>> I'm quite sure some codecs do not have a fixed bit_rate while some other
>>> (like the g726 below) do use it.
>>>
>>> So I'd expect this change to break on some semi-valid files and prevent
>>> something horrid in other.
>>
>> I know how to prevent it in much easier way - RTFM, see that byte rate in
>> WAVEFORMAT is an unsigned number and get back to sleep.
> 
> int bit_rate = avio_rl32(pb) * 8;
> 
> Anything larger than INT_MAX (and possibly much less) could be safely
> rejected as invalid.

Rejecting negative values has practically the same effect, even though
theoretically signed integer overflow is not well-defined.

> The question is if reject is as invalid by erroring out or just set to 0
> as in unknown.

Providing an explode mode is the common compromise.

Best regards,
Andreas
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 4/4] avcodec: loongson optimized h264pred with mmi

2015-07-11 Thread 周晓勇



> -原始邮件-
> 发件人: "Michael Niedermayer" 
> 发送时间: 2015年7月11日 星期六
> 收件人: "FFmpeg development discussions and patches" 
> 抄送: 
> 主题: Re: [FFmpeg-devel] [PATCH 4/4] avcodec: loongson optimized h264pred with 
> mmi
> 
> On Sat, Jul 11, 2015 at 01:59:40PM +0200, Michael Niedermayer wrote:
> > On Sat, Jul 11, 2015 at 01:54:34PM +0200, Michael Niedermayer wrote:
> > > On Sat, Jul 11, 2015 at 01:35:36PM +0800, 周晓勇 wrote:
> > > > 
> > > > 
> > > > 
> > > > > -原始邮件-
> > > > > 发件人: "Michael Niedermayer" 
> > > > > 发送时间: 2015年7月11日 星期六
> > > > > 收件人: "FFmpeg development discussions and patches" 
> > > > > 
> > > > > 抄送: 
> > > > > 主题: Re: [FFmpeg-devel] [PATCH 4/4] avcodec: loongson optimized 
> > > > > h264pred with mmi
> > > > > 
> > > > > On Mon, Jul 06, 2015 at 10:17:54PM +0800, 周晓勇 wrote:
> > > > > > upgrade the new FC21 with these steps:
> > > > > > 1.mount Fedora21-xfce-Loongson-20150706.iso to /mnt
> > > > > > 2.mkfs.ext3(ext4 may not supported by loongson pmon) the usb disk
> > > > > > 3.copy all two folders in /mnt to usb
> > > > > > 4.reboot and plug in usb disk
> > > > > > 5.press key "u" until select menu
> > > > > > 6.enter in usb disk(first menu)
> > > > > > 7.enter in install system(please do not enter int other entries, 
> > > > > > because others not correctly work)
> > > > > > 8.choose on partition to install
> > > > > 
> > > > > 8a. wonder why it installs over another partition
> > > > > 
> > > > choose one partition you want to install into.
> > > > if you installed new os on partition sda9, so you need change the 
> > > > /etc/fstab of the new os. like this:
> > > > /dev/sda9 / ext4 ...
> > > 
> > > the root partition in fstab is fine
> > > 
> > > 
> > > > 
> > > > > 
> > > > > > 9.after install completed, reboot into any other os to enable first 
> > > > > > line in FC21 /etc/fstab:
> > > > > > #/dev/sda8 / ext4 ... --> /dev/sda8 / ext4 ... (sdax is the 
> > > > > > partition which you installed yet)
> > > > > > 10.copy /boot folder of FC21 partition into the first BOOT 
> > > > > > partition(sda1) to use the new kernel 3.18.xxx
> > > > > > 11.modify the boot.cfg file in BOOT partision(sda1)
> > > > > 
> > > > > and after that it boots to the GUI login and one cannot login as the
> > > > > new user is called loongson-fc21 but the home directory loongson
> > > > > changing the directory so they match gets one further, a dialog is
> > > > > displayed with 2 buttons in chinese, closing that dialog without
> > > > > clicking either leaves one in the partly working GUI which just shows
> > > > > the background image and a gray rectangle
> > > > > its possible to open some menu list and enter commands and a terminal
> > > > > with some key combinations
> > > > > after some searching i found a list of languages but chaging that
> > > > > to english doesnt change anything
> > > > > 
> > > > > what steps are needed to get this system working ?
> > > > > 
> > > > the users's default password is loongson, and same does root.
> > > 
> > > yes, i figured these out already, that was easy
> > > 
> > > 
> > > > sorry about that, i use another partition mounted as /home before i 
> > > > tarball the os, so you may need to add a new user to work.
> > > > i have changed the language to Deutsch and it dose work correctly, but 
> > > > because of my mistake, the tarball dose not have loongson-fc21 dir in 
> > > > it. the language configure file is located in user's dir, and as it 
> > > > dose not respond after you make the change in menulist, you need change 
> > > > locale language with steps:
> > > > 1.locale -a to list all languages
> > > > 2.change /etc/default/locale to LANG="en_US.UTF-8"
> > > > 
> > > > if there is no /etc/default/locale in os, you could add this line in 
> > > > /etc/profile:
> > > > export LC_CTYPE="en_US"
> > > 
> > > theres no /etc/default/locale, adding
> > > export LC_CTYPE="en_US" to /etc/profile
> > > and  LANG="en_US.utf8"
> > > then setting the laguage/charset before login in the GUI
> > > after login the menu bar at the top is gone
> > > alt-F3 shows a chinese menu
> > > 
> > > 
> > > > 
> > > > 3.if it works, use the start menulist to find where to change the lang 
> > > > and wait for a while after click.
> > > 
> > > after login theres no start menu or anything just the background image
> > > theres no text no chinese either no buttons and no menues
> > > i can get a menu with alt-F3
> > > and select the language selection (flag icon) in the list but it seems
> > > not to start or take very long
> > > 
> > > iam pretty sure there is something from the GUI not running or missing
> > > that should be running
> > 
> > i got the GUI working by creating a completely new user
> > there must be something shoot in the configuration in /home/loongson
> 
> got the GUI working with loongson, the problem was that i clicked the
> chinese dialog away that was displayed on the first login
> 
i think the dialog displayed when first login in Chinese maybe the warning that 
ask y

Re: [FFmpeg-devel] [PATCH] vf_psnr: always calculate MSE over full pixel range.

2015-07-11 Thread Paul B Mahol
Dana 11. 7. 2015. 13:23 osoba "Ronald S. Bultje" 
napisala je:
>
> This makes the output compatible with that of pretty much any other
> tool that calculates PSNR.
> ---
>  libavfilter/vf_psnr.c | 31 ---
>  1 file changed, 4 insertions(+), 27 deletions(-)
>
> diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
> index 0c2c950..cc4546a 100644
> --- a/libavfilter/vf_psnr.c
> +++ b/libavfilter/vf_psnr.c
> @@ -260,33 +260,10 @@ static int config_input_ref(AVFilterLink *inlink)
>  return AVERROR(EINVAL);
>  }
>
> -switch (inlink->format) {
> -case AV_PIX_FMT_GRAY8:
> -case AV_PIX_FMT_GRAY16:
> -case AV_PIX_FMT_GBRP:
> -case AV_PIX_FMT_GBRP9:
> -case AV_PIX_FMT_GBRP10:
> -case AV_PIX_FMT_GBRP12:
> -case AV_PIX_FMT_GBRP14:
> -case AV_PIX_FMT_GBRP16:
> -case AV_PIX_FMT_GBRAP:
> -case AV_PIX_FMT_GBRAP16:
> -case AV_PIX_FMT_YUVJ411P:
> -case AV_PIX_FMT_YUVJ420P:
> -case AV_PIX_FMT_YUVJ422P:
> -case AV_PIX_FMT_YUVJ440P:
> -case AV_PIX_FMT_YUVJ444P:
> -s->max[0] = (1 << (desc->comp[0].depth_minus1 + 1)) - 1;
> -s->max[1] = (1 << (desc->comp[1].depth_minus1 + 1)) - 1;
> -s->max[2] = (1 << (desc->comp[2].depth_minus1 + 1)) - 1;
> -s->max[3] = (1 << (desc->comp[3].depth_minus1 + 1)) - 1;
> -break;
> -default:
> -s->max[0] = 235 * (1 << (desc->comp[0].depth_minus1 - 7));
> -s->max[1] = 240 * (1 << (desc->comp[1].depth_minus1 - 7));
> -s->max[2] = 240 * (1 << (desc->comp[2].depth_minus1 - 7));
> -s->max[3] = (1 << (desc->comp[3].depth_minus1 + 1)) - 1;
> -}
> +s->max[0] = (1 << (desc->comp[0].depth_minus1 + 1)) - 1;
> +s->max[1] = (1 << (desc->comp[1].depth_minus1 + 1)) - 1;
> +s->max[2] = (1 << (desc->comp[2].depth_minus1 + 1)) - 1;
> +s->max[3] = (1 << (desc->comp[3].depth_minus1 + 1)) - 1;
>
>  s->is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0;
>  s->comps[0] = s->is_rgb ? 'r' : 'y' ;
> --
> 2.1.2
>

LGTM

> ___
> 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] vf_psnr: sse2 optimizations for sum-squared-error.

2015-07-11 Thread Ronald S. Bultje
The internal line accumulator for 16bit can overflow, so I changed that
from int to uint64_t in the C code. The matching assembly looks a little
weird but output looks correct. It assumes aligned input pointers, I'm
not sure if that's a requirement in lavfi (it should be IMO).

(avx2 should be trivial to add later.)
---
 libavfilter/psnr.h |  33 ++
 libavfilter/vf_psnr.c  |  76 ++
 libavfilter/x86/Makefile   |   2 +
 libavfilter/x86/vf_psnr.asm| 139 +
 libavfilter/x86/vf_psnr_init.c |  39 
 5 files changed, 247 insertions(+), 42 deletions(-)
 create mode 100644 libavfilter/psnr.h
 create mode 100644 libavfilter/x86/vf_psnr.asm
 create mode 100644 libavfilter/x86/vf_psnr_init.c

diff --git a/libavfilter/psnr.h b/libavfilter/psnr.h
new file mode 100644
index 000..efe94da
--- /dev/null
+++ b/libavfilter/psnr.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015 Ronald S. Bultje 
+ *
+ * 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
+ */
+
+#ifndef LIBAVFILTER_PSNR_H
+#define LIBAVFILTER_PSNR_H
+
+#include 
+#include 
+
+typedef struct PSNRDSPContext {
+uint64_t (*sse_line)(const uint8_t *buf, const uint8_t *ref, int w);
+} PSNRDSPContext;
+
+void ff_psnr_init_x86(PSNRDSPContext *dsp, int bpp);
+
+#endif /* LIBAVFILTER_PSNR_H */
diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
index cc4546a..63baddd 100644
--- a/libavfilter/vf_psnr.c
+++ b/libavfilter/vf_psnr.c
@@ -33,6 +33,7 @@
 #include "drawutils.h"
 #include "formats.h"
 #include "internal.h"
+#include "psnr.h"
 #include "video.h"
 
 typedef struct PSNRContext {
@@ -50,11 +51,7 @@ typedef struct PSNRContext {
 int planewidth[4];
 int planeheight[4];
 double planeweight[4];
-
-void (*compute_mse)(struct PSNRContext *s,
-const uint8_t *m[4], const int ml[4],
-const uint8_t *r[4], const int rl[4],
-int w, int h, double mse[4]);
+PSNRDSPContext dsp;
 } PSNRContext;
 
 #define OFFSET(x) offsetof(PSNRContext, x)
@@ -78,55 +75,48 @@ static inline double get_psnr(double mse, uint64_t 
nb_frames, int max)
 return 10.0 * log(pow2(max) / (mse / nb_frames)) / log(10.0);
 }
 
-static inline
-void compute_images_mse(PSNRContext *s,
-const uint8_t *main_data[4], const int 
main_linesizes[4],
-const uint8_t *ref_data[4], const int ref_linesizes[4],
-int w, int h, double mse[4])
+static uint64_t sse_line_8bit(const uint8_t *main_line,  const uint8_t 
*ref_line, int outw)
 {
-int i, c, j;
+int j;
+unsigned m2 = 0;
 
-for (c = 0; c < s->nb_components; c++) {
-const int outw = s->planewidth[c];
-const int outh = s->planeheight[c];
-const uint8_t *main_line = main_data[c];
-const uint8_t *ref_line = ref_data[c];
-const int ref_linesize = ref_linesizes[c];
-const int main_linesize = main_linesizes[c];
-uint64_t m = 0;
+for (j = 0; j < outw; j++)
+m2 += pow2(main_line[j] - ref_line[j]);
 
-for (i = 0; i < outh; i++) {
-int m2 = 0;
-for (j = 0; j < outw; j++)
-m2 += pow2(main_line[j] - ref_line[j]);
-m += m2;
-ref_line += ref_linesize;
-main_line += main_linesize;
-}
-mse[c] = m / (double)(outw * outh);
-}
+return m2;
+}
+
+static uint64_t sse_line_16bit(const uint8_t *_main_line, const uint8_t 
*_ref_line, int outw)
+{
+int j;
+uint64_t m2 = 0;
+const uint16_t *main_line = (const uint16_t *) _main_line;
+const uint16_t *ref_line = (const uint16_t *) _ref_line;
+
+for (j = 0; j < outw; j++)
+m2 += pow2(main_line[j] - ref_line[j]);
+
+return m2;
 }
 
 static inline
-void compute_images_mse_16bit(PSNRContext *s,
+void compute_images_mse(PSNRContext *s,
 const uint8_t *main_data[4], const int 
main_linesizes[4],
 const uint8_t *ref_data[4], const int ref_linesizes[4],
 int w, int h, double mse[4])
 {
-int i, c, j;
+int i, c;
 
 for (c = 0; c < s->nb_components; c++) {
 const int outw =

Re: [FFmpeg-devel] [PATCH] lavfi/removegrain: add x86 and x86_64 SSE2 functions

2015-07-11 Thread James Darnley
On 2015-07-11 15:45, Carl Eugen Hoyos wrote:
> James Darnley  gmail.com> writes:
> 
>> +;* TODO: gpl text goes here.
> 
> Yes, please copy it from another asm file.
> 
> And please make sure that the file does 
> not get compiled if --enable-gpl was not 
> specified.

Dammit!  Of course I forgot to do that.  I think Paul wants it to be
LGPL anyway.  I will fix that that locally and send another patch after
waiting for other comments.




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


[FFmpeg-devel] [PATCH] vf_psnr: sse2 optimizations for sum-squared-error.

2015-07-11 Thread Ronald S. Bultje
The internal line accumulator for 16bit can overflow, so I changed that
from int to uint64_t in the C code. The matching assembly looks a little
weird but output looks correct. It assumes aligned input pointers, I'm
not sure if that's a requirement in lavfi (it should be IMO).

(avx2 should be trivial to add later.)
---
 libavfilter/psnr.h |  33 ++
 libavfilter/vf_psnr.c  |  76 ++
 libavfilter/x86/Makefile   |   2 +
 libavfilter/x86/vf_psnr.asm| 140 +
 libavfilter/x86/vf_psnr_init.c |  39 
 5 files changed, 248 insertions(+), 42 deletions(-)
 create mode 100644 libavfilter/psnr.h
 create mode 100644 libavfilter/x86/vf_psnr.asm
 create mode 100644 libavfilter/x86/vf_psnr_init.c

diff --git a/libavfilter/psnr.h b/libavfilter/psnr.h
new file mode 100644
index 000..efe94da
--- /dev/null
+++ b/libavfilter/psnr.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015 Ronald S. Bultje 
+ *
+ * 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
+ */
+
+#ifndef LIBAVFILTER_PSNR_H
+#define LIBAVFILTER_PSNR_H
+
+#include 
+#include 
+
+typedef struct PSNRDSPContext {
+uint64_t (*sse_line)(const uint8_t *buf, const uint8_t *ref, int w);
+} PSNRDSPContext;
+
+void ff_psnr_init_x86(PSNRDSPContext *dsp, int bpp);
+
+#endif /* LIBAVFILTER_PSNR_H */
diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
index cc4546a..63baddd 100644
--- a/libavfilter/vf_psnr.c
+++ b/libavfilter/vf_psnr.c
@@ -33,6 +33,7 @@
 #include "drawutils.h"
 #include "formats.h"
 #include "internal.h"
+#include "psnr.h"
 #include "video.h"
 
 typedef struct PSNRContext {
@@ -50,11 +51,7 @@ typedef struct PSNRContext {
 int planewidth[4];
 int planeheight[4];
 double planeweight[4];
-
-void (*compute_mse)(struct PSNRContext *s,
-const uint8_t *m[4], const int ml[4],
-const uint8_t *r[4], const int rl[4],
-int w, int h, double mse[4]);
+PSNRDSPContext dsp;
 } PSNRContext;
 
 #define OFFSET(x) offsetof(PSNRContext, x)
@@ -78,55 +75,48 @@ static inline double get_psnr(double mse, uint64_t 
nb_frames, int max)
 return 10.0 * log(pow2(max) / (mse / nb_frames)) / log(10.0);
 }
 
-static inline
-void compute_images_mse(PSNRContext *s,
-const uint8_t *main_data[4], const int 
main_linesizes[4],
-const uint8_t *ref_data[4], const int ref_linesizes[4],
-int w, int h, double mse[4])
+static uint64_t sse_line_8bit(const uint8_t *main_line,  const uint8_t 
*ref_line, int outw)
 {
-int i, c, j;
+int j;
+unsigned m2 = 0;
 
-for (c = 0; c < s->nb_components; c++) {
-const int outw = s->planewidth[c];
-const int outh = s->planeheight[c];
-const uint8_t *main_line = main_data[c];
-const uint8_t *ref_line = ref_data[c];
-const int ref_linesize = ref_linesizes[c];
-const int main_linesize = main_linesizes[c];
-uint64_t m = 0;
+for (j = 0; j < outw; j++)
+m2 += pow2(main_line[j] - ref_line[j]);
 
-for (i = 0; i < outh; i++) {
-int m2 = 0;
-for (j = 0; j < outw; j++)
-m2 += pow2(main_line[j] - ref_line[j]);
-m += m2;
-ref_line += ref_linesize;
-main_line += main_linesize;
-}
-mse[c] = m / (double)(outw * outh);
-}
+return m2;
+}
+
+static uint64_t sse_line_16bit(const uint8_t *_main_line, const uint8_t 
*_ref_line, int outw)
+{
+int j;
+uint64_t m2 = 0;
+const uint16_t *main_line = (const uint16_t *) _main_line;
+const uint16_t *ref_line = (const uint16_t *) _ref_line;
+
+for (j = 0; j < outw; j++)
+m2 += pow2(main_line[j] - ref_line[j]);
+
+return m2;
 }
 
 static inline
-void compute_images_mse_16bit(PSNRContext *s,
+void compute_images_mse(PSNRContext *s,
 const uint8_t *main_data[4], const int 
main_linesizes[4],
 const uint8_t *ref_data[4], const int ref_linesizes[4],
 int w, int h, double mse[4])
 {
-int i, c, j;
+int i, c;
 
 for (c = 0; c < s->nb_components; c++) {
 const int outw =

Re: [FFmpeg-devel] [PATCH]lavf/mxf: Map codec_tag for Avid files if everything else fails

2015-07-11 Thread Tomas Härdin
On Fri, 2015-07-10 at 20:11 +0200, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch allows decoding of the sample provided on ffmpeg-user:
> http://ffmpeg.org/pipermail/ffmpeg-user/2015-July/027472.html
> 
> Better suggestions welcome, Carl Eugen

Just a quick review since I have to bounce:

> +const MXFCodecUL ff_mxf_codec_tag_uls[] = {

Haven't we moved this to mxf.c already? Or rather, don't we have a whole
bunch of very similar tables already?

>  st->codec->pix_fmt = (enum AVPixelFormat)pix_fmt_ul->id;
> -if (st->codec->pix_fmt == AV_PIX_FMT_NONE) {
> +if (st->codec->pix_fmt == AV_PIX_FMT_NONE)
> +st->codec->codec_tag = 
> mxf_get_codec_ul(ff_mxf_codec_tag_uls,
> +
> &descriptor->essence_codec_ul)->id;
> +if (st->codec->pix_fmt == AV_PIX_FMT_NONE && 
> !st->codec->codec_tag) {
>  /* support files created before RP224v10 by 
> defaulting to UYVY422
> if subsampling is 4:2:2 and component depth is 
> 8-bit */
>  if (descriptor->horiz_subsampling == 2 &&

Messy bracing. Something like putting a check on codec_tag after setting
it, inside braces like before. Hard to explain and I don't have time to
type it out but:

if (st->codec->pix_fmt == AV_PIX_FMT_NONE) {
 codec_tag = ...
 if (!codec_tag) {
  do the old thing
 }
}

Gotta go!

/Tomas



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


Re: [FFmpeg-devel] [PATCH] lavfi/removegrain: add x86 and x86_64 SSE2 functions

2015-07-11 Thread Carl Eugen Hoyos
James Darnley  gmail.com> writes:

> +;* TODO: gpl text goes here.

Yes, please copy it from another asm file.

And please make sure that the file does 
not get compiled if --enable-gpl was not 
specified.

Carl Eugen

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


[FFmpeg-devel] [PATCH] lavfi/removegrain: add x86 and x86_64 SSE2 functions

2015-07-11 Thread James Darnley
Speed of all modes increased by a factor between 7.4 and 19.8 largely depending
on whether bytes are unpacked into words.  Modes 2, 3, and 4 have been sped-up
by a factor of 43 (thanks quick sort!)

All modes are available on x86_64 but only modes 1, 10, 11, 12, 13, 14, 19, 20,
21, and 22 are available on x86 due to the number of SIMD registers used.
---
 libavfilter/removegrain.h |   40 ++
 libavfilter/vf_removegrain.c  |   38 +-
 libavfilter/x86/Makefile  |2 +
 libavfilter/x86/vf_removegrain.asm| 1215 +
 libavfilter/x86/vf_removegrain_init.c |  128 
 5 files changed, 1404 insertions(+), 19 deletions(-)
 create mode 100644 libavfilter/removegrain.h
 create mode 100644 libavfilter/x86/vf_removegrain.asm
 create mode 100644 libavfilter/x86/vf_removegrain_init.c

diff --git a/libavfilter/removegrain.h b/libavfilter/removegrain.h
new file mode 100644
index 000..60401fb
--- /dev/null
+++ b/libavfilter/removegrain.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2015 Paul B Mahol
+ * Copyright (c) 2015 James Darnley
+ *
+ * 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 "avfilter.h"
+
+typedef struct RemoveGrainContext {
+const AVClass *class;
+
+int mode[4];
+
+int nb_planes;
+int planewidth[4];
+int planeheight[4];
+int skip_even;
+int skip_odd;
+
+int (*rg[4])(int c, int a1, int a2, int a3, int a4, int a5, int a6, int 
a7, int a8);
+
+void (*fl[4])(uint8_t *dst, uint8_t *src, ptrdiff_t stride, int pixels);
+} RemoveGrainContext;
+
+void ff_removegrain_init_x86(RemoveGrainContext *rg);
diff --git a/libavfilter/vf_removegrain.c b/libavfilter/vf_removegrain.c
index 77b3561..da17f6a 100644
--- a/libavfilter/vf_removegrain.c
+++ b/libavfilter/vf_removegrain.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2012 Laurent de Soras
  * Copyright (c) 2013 Fredrik Mellbin
  * Copyright (c) 2015 Paul B Mahol
+ * Copyright (c) 2015 James Darnley
  *
  * This file is part of FFmpeg.
  *
@@ -20,32 +21,15 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-/*
- * TODO: add SIMD
- */
-
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avfilter.h"
 #include "formats.h"
 #include "internal.h"
+#include "removegrain.h"
 #include "video.h"
 
-typedef struct RemoveGrainContext {
-const AVClass *class;
-
-int mode[4];
-
-int nb_planes;
-int planewidth[4];
-int planeheight[4];
-int skip_even;
-int skip_odd;
-
-int (*rg[4])(int c, int a1, int a2, int a3, int a4, int a5, int a6, int 
a7, int a8);
-} RemoveGrainContext;
-
 #define OFFSET(x) offsetof(RemoveGrainContext, x)
 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
@@ -142,6 +126,7 @@ static int mode05(int c, int a1, int a2, int a3, int a4, 
int a5, int a6, int a7,
 
 const int mindiff = FFMIN(FFMIN(c1, c2), FFMIN(c3, c4));
 
+/* When adding SIMD notice the return order here: 4, 2, 3, 1. */
 if (mindiff == c4) {
 return av_clip(c, mi4, ma4);
 } else if (mindiff == c2) {
@@ -524,6 +509,9 @@ static int config_input(AVFilterLink *inlink)
 }
 }
 
+if (ARCH_X86)
+ff_removegrain_init_x86(s);
+
 return 0;
 }
 
@@ -566,7 +554,19 @@ static int filter_slice(AVFilterContext *ctx, void *arg, 
int jobnr, int nb_jobs)
 }
 
 *dst++ = *src++;
-for (x = 1; x < s->planewidth[i] - 1; x++) {
+
+if (s->fl[i]) {
+int w_asm = (s->planewidth[i] - 2) & ~15;
+
+s->fl[i](dst, src, in->linesize[i], w_asm);
+
+x = 1 + w_asm;
+dst += w_asm;
+src += w_asm;
+} else
+x = 1;
+
+for (; x < s->planewidth[i] - 1; x++) {
 const int a1 = src[-op];
 const int a2 = src[-o0];
 const int a3 = src[-om];
diff --git a/libavfilter/x86/Makefile b/libavfilter/x86/Makefile
index 49f45b6..32a154d 100644
--- a/libavfilter/x86/Makefile
+++ b/libavfilter/x86/Makefile
@@ -7,6 +7,7 @@ OBJS-$(CONFIG_INTERLACE_FILTER)  += 
x86/vf_interlace_init.o
 OBJS-$(CONFIG_NOISE_FILTER)  += x86/vf_noise.o
 OBJS-$(CONFIG_PP7_FILTER)+= x86/v

Re: [FFmpeg-devel] [PATCH] yuv4mpeg: add rough duration estimate and seeking.

2015-07-11 Thread Michael Niedermayer
On Sat, Jul 11, 2015 at 10:59:58AM +, Paul B Mahol wrote:
> Dana 11. 7. 2015. 03:16 osoba "Ronald S. Bultje" 
> napisala je:
> >
> > ---
> >  libavformat/yuv4mpeg.h   |  1 +
> >  libavformat/yuv4mpegdec.c| 26 +++
> >  tests/ref/seek/lavf-yuv4mpeg | 78
> +---
> >  3 files changed, 72 insertions(+), 33 deletions(-)
> >
> > diff --git a/libavformat/yuv4mpeg.h b/libavformat/yuv4mpeg.h
> > index 750f498..eba7337 100644
> > --- a/libavformat/yuv4mpeg.h
> > +++ b/libavformat/yuv4mpeg.h
> > @@ -23,5 +23,6 @@
> >
> >  #define Y4M_MAGIC "YUV4MPEG2"
> >  #define Y4M_FRAME_MAGIC "FRAME"
> > +#define Y4M_FRAME_MAGIC_LEN 6
> >
> >  #endif /* AVFORMAT_YUV4MPEG_H */
> > diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
> > index 7613c3c..4ebdb78 100644
> > --- a/libavformat/yuv4mpegdec.c
> > +++ b/libavformat/yuv4mpegdec.c
> > @@ -256,6 +256,12 @@ static int yuv4_read_header(AVFormatContext *s)
> >  st->sample_aspect_ratio   = (AVRational){ aspectn, aspectd };
> >  st->codec->chroma_sample_location = chroma_sample_location;
> >  st->codec->field_order= field_order;
> > +s->packet_size = avpicture_get_size(st->codec->pix_fmt, width,
> height) + Y4M_FRAME_MAGIC_LEN;
> > +if ((int) s->packet_size < 0)
> > +return s->packet_size;
> > +s->internal->data_offset = avio_tell(pb);
> > +
> > +st->duration = (avio_size(pb) - avio_tell(pb)) / s->packet_size;
> >
> >  return 0;
> >  }
> > @@ -264,7 +270,7 @@ static int yuv4_read_packet(AVFormatContext *s,
> AVPacket *pkt)
> >  {
> >  int i;
> >  char header[MAX_FRAME_HEADER+1];
> > -int packet_size, width, height, ret;
> > +int width, height, ret, off = avio_tell(s->pb);
> >  AVStream *st = s->streams[0];
> >
> >  for (i = 0; i < MAX_FRAME_HEADER; i++) {
> > @@ -287,17 +293,22 @@ static int yuv4_read_packet(AVFormatContext *s,
> AVPacket *pkt)
> >  width  = st->codec->width;
> >  height = st->codec->height;
> >
> > -packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
> > -if (packet_size < 0)
> > -return packet_size;
> > -
> > -ret = av_get_packet(s->pb, pkt, packet_size);
> > +ret = av_get_packet(s->pb, pkt, s->packet_size -
> Y4M_FRAME_MAGIC_LEN);
> >  if (ret < 0)
> >  return ret;
> > -else if (ret != packet_size)
> > +else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN)
> >  return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
> >
> >  pkt->stream_index = 0;
> > +pkt->pts = (off - s->internal->data_offset) / s->packet_size;
> > +pkt->duration = 1;
> > +return 0;
> > +}
> > +
> > +static int yuv4_read_seek(AVFormatContext *s, int stream_index,
> > +  int64_t pts, int flags)
> > +{
> > +avio_seek(s->pb, pts * s->packet_size + s->internal->data_offset,
> SEEK_SET);
> >  return 0;
> >  }
> >
> > @@ -316,5 +327,6 @@ AVInputFormat ff_yuv4mpegpipe_demuxer = {
> >  .read_probe = yuv4_probe,
> >  .read_header= yuv4_read_header,
> >  .read_packet= yuv4_read_packet,
> > +.read_seek  = yuv4_read_seek,
> >  .extensions = "y4m",
> >  };
> > diff --git a/tests/ref/seek/lavf-yuv4mpeg b/tests/ref/seek/lavf-yuv4mpeg
> > index 81c1de9..60c3036 100644
> > --- a/tests/ref/seek/lavf-yuv4mpeg
> > +++ b/tests/ref/seek/lavf-yuv4mpeg
> > @@ -1,27 +1,53 @@
> >  ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 64
> size:152064
> > -ret:-1 st:-1 flags:0  ts:-1.00
> > -ret:-1 st:-1 flags:1  ts: 1.894167
> > -ret:-1 st: 0 flags:0  ts: 0.80
> > -ret:-1 st: 0 flags:1  ts:-0.32
> > -ret:-1 st:-1 flags:0  ts: 2.576668
> > -ret:-1 st:-1 flags:1  ts: 1.470835
> > -ret:-1 st: 0 flags:0  ts: 0.36
> > -ret:-1 st: 0 flags:1  ts:-0.76
> > -ret:-1 st:-1 flags:0  ts: 2.153336
> > -ret:-1 st:-1 flags:1  ts: 1.047503
> > -ret:-1 st: 0 flags:0  ts:-0.04
> > -ret:-1 st: 0 flags:1  ts: 2.84
> > -ret:-1 st:-1 flags:0  ts: 1.730004
> > -ret:-1 st:-1 flags:1  ts: 0.624171
> > -ret:-1 st: 0 flags:0  ts:-0.48
> > -ret:-1 st: 0 flags:1  ts: 2.40
> > -ret:-1 st:-1 flags:0  ts: 1.306672
> > -ret:-1 st:-1 flags:1  ts: 0.200839
> > -ret:-1 st: 0 flags:0  ts:-0.92
> > -ret:-1 st: 0 flags:1  ts: 2.00
> > -ret:-1 st:-1 flags:0  ts: 0.883340
> > -ret:-1 st:-1 flags:1  ts:-0.222493
> > -ret:-1 st: 0 flags:0  ts: 2.68
> > -ret:-1 st: 0 flags:1  ts: 1.56
> > -ret:-1 st:-1 flags:0  ts: 0.460008
> > -ret:-1 st:-1 flags:1  ts:-0.645825
> > +ret: 0 st:-1 flags:0  ts:-1.00
> > +ret: 0 st: 0 flags:1 dts: 0.04 pts: 0.04 pos: 152134
> size:152064
> > +ret: 0 st:-1 flags:1  ts: 1.894167
> > +ret:-EOF
> > +ret: 0

Re: [FFmpeg-devel] [PATCH 4/4] avcodec: loongson optimized h264pred with mmi

2015-07-11 Thread Michael Niedermayer
On Sat, Jul 11, 2015 at 01:59:40PM +0200, Michael Niedermayer wrote:
> On Sat, Jul 11, 2015 at 01:54:34PM +0200, Michael Niedermayer wrote:
> > On Sat, Jul 11, 2015 at 01:35:36PM +0800, 周晓勇 wrote:
> > > 
> > > 
> > > 
> > > > -原始邮件-
> > > > 发件人: "Michael Niedermayer" 
> > > > 发送时间: 2015年7月11日 星期六
> > > > 收件人: "FFmpeg development discussions and patches" 
> > > > 
> > > > 抄送: 
> > > > 主题: Re: [FFmpeg-devel] [PATCH 4/4] avcodec: loongson optimized h264pred 
> > > > with mmi
> > > > 
> > > > On Mon, Jul 06, 2015 at 10:17:54PM +0800, 周晓勇 wrote:
> > > > > upgrade the new FC21 with these steps:
> > > > > 1.mount Fedora21-xfce-Loongson-20150706.iso to /mnt
> > > > > 2.mkfs.ext3(ext4 may not supported by loongson pmon) the usb disk
> > > > > 3.copy all two folders in /mnt to usb
> > > > > 4.reboot and plug in usb disk
> > > > > 5.press key "u" until select menu
> > > > > 6.enter in usb disk(first menu)
> > > > > 7.enter in install system(please do not enter int other entries, 
> > > > > because others not correctly work)
> > > > > 8.choose on partition to install
> > > > 
> > > > 8a. wonder why it installs over another partition
> > > > 
> > > choose one partition you want to install into.
> > > if you installed new os on partition sda9, so you need change the 
> > > /etc/fstab of the new os. like this:
> > > /dev/sda9 / ext4 ...
> > 
> > the root partition in fstab is fine
> > 
> > 
> > > 
> > > > 
> > > > > 9.after install completed, reboot into any other os to enable first 
> > > > > line in FC21 /etc/fstab:
> > > > > #/dev/sda8 / ext4 ... --> /dev/sda8 / ext4 ... (sdax is the partition 
> > > > > which you installed yet)
> > > > > 10.copy /boot folder of FC21 partition into the first BOOT 
> > > > > partition(sda1) to use the new kernel 3.18.xxx
> > > > > 11.modify the boot.cfg file in BOOT partision(sda1)
> > > > 
> > > > and after that it boots to the GUI login and one cannot login as the
> > > > new user is called loongson-fc21 but the home directory loongson
> > > > changing the directory so they match gets one further, a dialog is
> > > > displayed with 2 buttons in chinese, closing that dialog without
> > > > clicking either leaves one in the partly working GUI which just shows
> > > > the background image and a gray rectangle
> > > > its possible to open some menu list and enter commands and a terminal
> > > > with some key combinations
> > > > after some searching i found a list of languages but chaging that
> > > > to english doesnt change anything
> > > > 
> > > > what steps are needed to get this system working ?
> > > > 
> > > the users's default password is loongson, and same does root.
> > 
> > yes, i figured these out already, that was easy
> > 
> > 
> > > sorry about that, i use another partition mounted as /home before i 
> > > tarball the os, so you may need to add a new user to work.
> > > i have changed the language to Deutsch and it dose work correctly, but 
> > > because of my mistake, the tarball dose not have loongson-fc21 dir in it. 
> > > the language configure file is located in user's dir, and as it dose not 
> > > respond after you make the change in menulist, you need change locale 
> > > language with steps:
> > > 1.locale -a to list all languages
> > > 2.change /etc/default/locale to LANG="en_US.UTF-8"
> > > 
> > > if there is no /etc/default/locale in os, you could add this line in 
> > > /etc/profile:
> > > export LC_CTYPE="en_US"
> > 
> > theres no /etc/default/locale, adding
> > export LC_CTYPE="en_US" to /etc/profile
> > and  LANG="en_US.utf8"
> > then setting the laguage/charset before login in the GUI
> > after login the menu bar at the top is gone
> > alt-F3 shows a chinese menu
> > 
> > 
> > > 
> > > 3.if it works, use the start menulist to find where to change the lang 
> > > and wait for a while after click.
> > 
> > after login theres no start menu or anything just the background image
> > theres no text no chinese either no buttons and no menues
> > i can get a menu with alt-F3
> > and select the language selection (flag icon) in the list but it seems
> > not to start or take very long
> > 
> > iam pretty sure there is something from the GUI not running or missing
> > that should be running
> 
> i got the GUI working by creating a completely new user
> there must be something shoot in the configuration in /home/loongson

got the GUI working with loongson, the problem was that i clicked the
chinese dialog away that was displayed on the first login


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


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

Re: [FFmpeg-devel] [PATCH 4/4] avcodec: loongson optimized h264pred with mmi

2015-07-11 Thread Michael Niedermayer
On Sat, Jul 11, 2015 at 01:54:34PM +0200, Michael Niedermayer wrote:
> On Sat, Jul 11, 2015 at 01:35:36PM +0800, 周晓勇 wrote:
> > 
> > 
> > 
> > > -原始邮件-
> > > 发件人: "Michael Niedermayer" 
> > > 发送时间: 2015年7月11日 星期六
> > > 收件人: "FFmpeg development discussions and patches" 
> > > 
> > > 抄送: 
> > > 主题: Re: [FFmpeg-devel] [PATCH 4/4] avcodec: loongson optimized h264pred 
> > > with mmi
> > > 
> > > On Mon, Jul 06, 2015 at 10:17:54PM +0800, 周晓勇 wrote:
> > > > upgrade the new FC21 with these steps:
> > > > 1.mount Fedora21-xfce-Loongson-20150706.iso to /mnt
> > > > 2.mkfs.ext3(ext4 may not supported by loongson pmon) the usb disk
> > > > 3.copy all two folders in /mnt to usb
> > > > 4.reboot and plug in usb disk
> > > > 5.press key "u" until select menu
> > > > 6.enter in usb disk(first menu)
> > > > 7.enter in install system(please do not enter int other entries, 
> > > > because others not correctly work)
> > > > 8.choose on partition to install
> > > 
> > > 8a. wonder why it installs over another partition
> > > 
> > choose one partition you want to install into.
> > if you installed new os on partition sda9, so you need change the 
> > /etc/fstab of the new os. like this:
> > /dev/sda9 / ext4 ...
> 
> the root partition in fstab is fine
> 
> 
> > 
> > > 
> > > > 9.after install completed, reboot into any other os to enable first 
> > > > line in FC21 /etc/fstab:
> > > > #/dev/sda8 / ext4 ... --> /dev/sda8 / ext4 ... (sdax is the partition 
> > > > which you installed yet)
> > > > 10.copy /boot folder of FC21 partition into the first BOOT 
> > > > partition(sda1) to use the new kernel 3.18.xxx
> > > > 11.modify the boot.cfg file in BOOT partision(sda1)
> > > 
> > > and after that it boots to the GUI login and one cannot login as the
> > > new user is called loongson-fc21 but the home directory loongson
> > > changing the directory so they match gets one further, a dialog is
> > > displayed with 2 buttons in chinese, closing that dialog without
> > > clicking either leaves one in the partly working GUI which just shows
> > > the background image and a gray rectangle
> > > its possible to open some menu list and enter commands and a terminal
> > > with some key combinations
> > > after some searching i found a list of languages but chaging that
> > > to english doesnt change anything
> > > 
> > > what steps are needed to get this system working ?
> > > 
> > the users's default password is loongson, and same does root.
> 
> yes, i figured these out already, that was easy
> 
> 
> > sorry about that, i use another partition mounted as /home before i tarball 
> > the os, so you may need to add a new user to work.
> > i have changed the language to Deutsch and it dose work correctly, but 
> > because of my mistake, the tarball dose not have loongson-fc21 dir in it. 
> > the language configure file is located in user's dir, and as it dose not 
> > respond after you make the change in menulist, you need change locale 
> > language with steps:
> > 1.locale -a to list all languages
> > 2.change /etc/default/locale to LANG="en_US.UTF-8"
> > 
> > if there is no /etc/default/locale in os, you could add this line in 
> > /etc/profile:
> > export LC_CTYPE="en_US"
> 
> theres no /etc/default/locale, adding
> export LC_CTYPE="en_US" to /etc/profile
> and  LANG="en_US.utf8"
> then setting the laguage/charset before login in the GUI
> after login the menu bar at the top is gone
> alt-F3 shows a chinese menu
> 
> 
> > 
> > 3.if it works, use the start menulist to find where to change the lang and 
> > wait for a while after click.
> 
> after login theres no start menu or anything just the background image
> theres no text no chinese either no buttons and no menues
> i can get a menu with alt-F3
> and select the language selection (flag icon) in the list but it seems
> not to start or take very long
> 
> iam pretty sure there is something from the GUI not running or missing
> that should be running

i got the GUI working by creating a completely new user
there must be something shoot in the configuration in /home/loongson

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle


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


Re: [FFmpeg-devel] [PATCH 4/4] avcodec: loongson optimized h264pred with mmi

2015-07-11 Thread Michael Niedermayer
On Sat, Jul 11, 2015 at 01:35:36PM +0800, 周晓勇 wrote:
> 
> 
> 
> > -原始邮件-
> > 发件人: "Michael Niedermayer" 
> > 发送时间: 2015年7月11日 星期六
> > 收件人: "FFmpeg development discussions and patches" 
> > 抄送: 
> > 主题: Re: [FFmpeg-devel] [PATCH 4/4] avcodec: loongson optimized h264pred 
> > with mmi
> > 
> > On Mon, Jul 06, 2015 at 10:17:54PM +0800, 周晓勇 wrote:
> > > upgrade the new FC21 with these steps:
> > > 1.mount Fedora21-xfce-Loongson-20150706.iso to /mnt
> > > 2.mkfs.ext3(ext4 may not supported by loongson pmon) the usb disk
> > > 3.copy all two folders in /mnt to usb
> > > 4.reboot and plug in usb disk
> > > 5.press key "u" until select menu
> > > 6.enter in usb disk(first menu)
> > > 7.enter in install system(please do not enter int other entries, because 
> > > others not correctly work)
> > > 8.choose on partition to install
> > 
> > 8a. wonder why it installs over another partition
> > 
> choose one partition you want to install into.
> if you installed new os on partition sda9, so you need change the /etc/fstab 
> of the new os. like this:
> /dev/sda9 / ext4 ...

the root partition in fstab is fine


> 
> > 
> > > 9.after install completed, reboot into any other os to enable first line 
> > > in FC21 /etc/fstab:
> > > #/dev/sda8 / ext4 ... --> /dev/sda8 / ext4 ... (sdax is the partition 
> > > which you installed yet)
> > > 10.copy /boot folder of FC21 partition into the first BOOT 
> > > partition(sda1) to use the new kernel 3.18.xxx
> > > 11.modify the boot.cfg file in BOOT partision(sda1)
> > 
> > and after that it boots to the GUI login and one cannot login as the
> > new user is called loongson-fc21 but the home directory loongson
> > changing the directory so they match gets one further, a dialog is
> > displayed with 2 buttons in chinese, closing that dialog without
> > clicking either leaves one in the partly working GUI which just shows
> > the background image and a gray rectangle
> > its possible to open some menu list and enter commands and a terminal
> > with some key combinations
> > after some searching i found a list of languages but chaging that
> > to english doesnt change anything
> > 
> > what steps are needed to get this system working ?
> > 
> the users's default password is loongson, and same does root.

yes, i figured these out already, that was easy


> sorry about that, i use another partition mounted as /home before i tarball 
> the os, so you may need to add a new user to work.
> i have changed the language to Deutsch and it dose work correctly, but 
> because of my mistake, the tarball dose not have loongson-fc21 dir in it. the 
> language configure file is located in user's dir, and as it dose not respond 
> after you make the change in menulist, you need change locale language with 
> steps:
> 1.locale -a to list all languages
> 2.change /etc/default/locale to LANG="en_US.UTF-8"
> 
> if there is no /etc/default/locale in os, you could add this line in 
> /etc/profile:
> export LC_CTYPE="en_US"

theres no /etc/default/locale, adding
export LC_CTYPE="en_US" to /etc/profile
and  LANG="en_US.utf8"
then setting the laguage/charset before login in the GUI
after login the menu bar at the top is gone
alt-F3 shows a chinese menu


> 
> 3.if it works, use the start menulist to find where to change the lang and 
> wait for a while after click.

after login theres no start menu or anything just the background image
theres no text no chinese either no buttons and no menues
i can get a menu with alt-F3
and select the language selection (flag icon) in the list but it seems
not to start or take very long

iam pretty sure there is something from the GUI not running or missing
that should be running


> 
> we have the live install iso, but only could install via network for now. 
> i considered it may waste your time as the download speed is slow, so i 
> tarball the os for you.
> so sorry for that, and we will improve it.
> 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I know you won't believe me, but the highest form of Human Excellence is
to question oneself and others. -- 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] ivfenc: write duration at end-of-stream.

2015-07-11 Thread Hendrik Leppkes
On Sat, Jul 11, 2015 at 1:17 PM, Ronald S. Bultje  wrote:
> At the beginning, the value is not initialized.
> ---
>  libavformat/ivfenc.c | 28 +++-
>  1 file changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c
> index 1d76c5c..0c81d41 100644
> --- a/libavformat/ivfenc.c
> +++ b/libavformat/ivfenc.c
> @@ -20,6 +20,11 @@
>  #include "avformat.h"
>  #include "libavutil/intreadwrite.h"
>
> +typedef struct IVFEncContext {
> +unsigned frame_cnt;
> +uint64_t last_pts, sum_delta_pts;
> +} IVFEncContext;
> +
>  static int ivf_write_header(AVFormatContext *s)
>  {
>  AVCodecContext *ctx;
> @@ -43,7 +48,7 @@ static int ivf_write_header(AVFormatContext *s)
>  avio_wl16(pb, ctx->height);
>  avio_wl32(pb, s->streams[0]->time_base.den);
>  avio_wl32(pb, s->streams[0]->time_base.num);
> -avio_wl64(pb, s->streams[0]->duration); // TODO: duration or number of 
> frames?!?
> +avio_wl64(pb, 0xULL);
>
>  return 0;
>  }
> @@ -51,14 +56,34 @@ static int ivf_write_header(AVFormatContext *s)
>  static int ivf_write_packet(AVFormatContext *s, AVPacket *pkt)
>  {
>  AVIOContext *pb = s->pb;
> +IVFEncContext *ctx = s->priv_data;
> +
>  avio_wl32(pb, pkt->size);
>  avio_wl64(pb, pkt->pts);
>  avio_write(pb, pkt->data, pkt->size);
> +if (ctx->frame_cnt)
> +ctx->sum_delta_pts += pkt->pts - ctx->last_pts;
> +ctx->frame_cnt++;
> +ctx->last_pts = pkt->pts;
> +
> +return 0;
> +}
> +
> +static int ivf_write_trailer(AVFormatContext *s)
> +{
> +AVIOContext *pb = s->pb;
> +IVFEncContext *ctx = s->priv_data;
> +size_t end = avio_tell(pb);
> +
> +avio_seek(pb, 24, SEEK_SET);
> +avio_wl64(pb, ctx->frame_cnt * ctx->sum_delta_pts / (ctx->frame_cnt - 
> 1));
> +avio_seek(pb, end, SEEK_SET);
>
Should probably wrap this in if (pb->seekable) just to be sure.

>  return 0;
>  }
>
>  AVOutputFormat ff_ivf_muxer = {
> +.priv_data_size = sizeof(IVFEncContext),
>  .name = "ivf",
>  .long_name= NULL_IF_CONFIG_SMALL("On2 IVF"),
>  .extensions   = "ivf",
> @@ -66,4 +91,5 @@ AVOutputFormat ff_ivf_muxer = {
>  .video_codec  = AV_CODEC_ID_VP8,
>  .write_header = ivf_write_header,
>  .write_packet = ivf_write_packet,
> +.write_trailer = ivf_write_trailer,
>  };

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


Re: [FFmpeg-devel] [PATCH] ivfenc: write duration at end-of-stream.

2015-07-11 Thread Carl Eugen Hoyos
Ronald S. Bultje  gmail.com> writes:

> +avio_seek(pb, 24, SEEK_SET);
> +avio_wl64()

Doesn't this need if (seekable) ?

Carl Eugen

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


[FFmpeg-devel] [PATCH] vf_psnr: always calculate MSE over full pixel range.

2015-07-11 Thread Ronald S. Bultje
This makes the output compatible with that of pretty much any other
tool that calculates PSNR.
---
 libavfilter/vf_psnr.c | 31 ---
 1 file changed, 4 insertions(+), 27 deletions(-)

diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
index 0c2c950..cc4546a 100644
--- a/libavfilter/vf_psnr.c
+++ b/libavfilter/vf_psnr.c
@@ -260,33 +260,10 @@ static int config_input_ref(AVFilterLink *inlink)
 return AVERROR(EINVAL);
 }
 
-switch (inlink->format) {
-case AV_PIX_FMT_GRAY8:
-case AV_PIX_FMT_GRAY16:
-case AV_PIX_FMT_GBRP:
-case AV_PIX_FMT_GBRP9:
-case AV_PIX_FMT_GBRP10:
-case AV_PIX_FMT_GBRP12:
-case AV_PIX_FMT_GBRP14:
-case AV_PIX_FMT_GBRP16:
-case AV_PIX_FMT_GBRAP:
-case AV_PIX_FMT_GBRAP16:
-case AV_PIX_FMT_YUVJ411P:
-case AV_PIX_FMT_YUVJ420P:
-case AV_PIX_FMT_YUVJ422P:
-case AV_PIX_FMT_YUVJ440P:
-case AV_PIX_FMT_YUVJ444P:
-s->max[0] = (1 << (desc->comp[0].depth_minus1 + 1)) - 1;
-s->max[1] = (1 << (desc->comp[1].depth_minus1 + 1)) - 1;
-s->max[2] = (1 << (desc->comp[2].depth_minus1 + 1)) - 1;
-s->max[3] = (1 << (desc->comp[3].depth_minus1 + 1)) - 1;
-break;
-default:
-s->max[0] = 235 * (1 << (desc->comp[0].depth_minus1 - 7));
-s->max[1] = 240 * (1 << (desc->comp[1].depth_minus1 - 7));
-s->max[2] = 240 * (1 << (desc->comp[2].depth_minus1 - 7));
-s->max[3] = (1 << (desc->comp[3].depth_minus1 + 1)) - 1;
-}
+s->max[0] = (1 << (desc->comp[0].depth_minus1 + 1)) - 1;
+s->max[1] = (1 << (desc->comp[1].depth_minus1 + 1)) - 1;
+s->max[2] = (1 << (desc->comp[2].depth_minus1 + 1)) - 1;
+s->max[3] = (1 << (desc->comp[3].depth_minus1 + 1)) - 1;
 
 s->is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0;
 s->comps[0] = s->is_rgb ? 'r' : 'y' ;
-- 
2.1.2

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


[FFmpeg-devel] [PATCH] ivfenc: write duration at end-of-stream.

2015-07-11 Thread Ronald S. Bultje
At the beginning, the value is not initialized.
---
 libavformat/ivfenc.c | 28 +++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/libavformat/ivfenc.c b/libavformat/ivfenc.c
index 1d76c5c..0c81d41 100644
--- a/libavformat/ivfenc.c
+++ b/libavformat/ivfenc.c
@@ -20,6 +20,11 @@
 #include "avformat.h"
 #include "libavutil/intreadwrite.h"
 
+typedef struct IVFEncContext {
+unsigned frame_cnt;
+uint64_t last_pts, sum_delta_pts;
+} IVFEncContext;
+
 static int ivf_write_header(AVFormatContext *s)
 {
 AVCodecContext *ctx;
@@ -43,7 +48,7 @@ static int ivf_write_header(AVFormatContext *s)
 avio_wl16(pb, ctx->height);
 avio_wl32(pb, s->streams[0]->time_base.den);
 avio_wl32(pb, s->streams[0]->time_base.num);
-avio_wl64(pb, s->streams[0]->duration); // TODO: duration or number of 
frames?!?
+avio_wl64(pb, 0xULL);
 
 return 0;
 }
@@ -51,14 +56,34 @@ static int ivf_write_header(AVFormatContext *s)
 static int ivf_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
 AVIOContext *pb = s->pb;
+IVFEncContext *ctx = s->priv_data;
+
 avio_wl32(pb, pkt->size);
 avio_wl64(pb, pkt->pts);
 avio_write(pb, pkt->data, pkt->size);
+if (ctx->frame_cnt)
+ctx->sum_delta_pts += pkt->pts - ctx->last_pts;
+ctx->frame_cnt++;
+ctx->last_pts = pkt->pts;
+
+return 0;
+}
+
+static int ivf_write_trailer(AVFormatContext *s)
+{
+AVIOContext *pb = s->pb;
+IVFEncContext *ctx = s->priv_data;
+size_t end = avio_tell(pb);
+
+avio_seek(pb, 24, SEEK_SET);
+avio_wl64(pb, ctx->frame_cnt * ctx->sum_delta_pts / (ctx->frame_cnt - 1));
+avio_seek(pb, end, SEEK_SET);
 
 return 0;
 }
 
 AVOutputFormat ff_ivf_muxer = {
+.priv_data_size = sizeof(IVFEncContext),
 .name = "ivf",
 .long_name= NULL_IF_CONFIG_SMALL("On2 IVF"),
 .extensions   = "ivf",
@@ -66,4 +91,5 @@ AVOutputFormat ff_ivf_muxer = {
 .video_codec  = AV_CODEC_ID_VP8,
 .write_header = ivf_write_header,
 .write_packet = ivf_write_packet,
+.write_trailer = ivf_write_trailer,
 };
-- 
2.1.2

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


Re: [FFmpeg-devel] [PATCH] vf_psnr: fix rgb channel order in metadata names.

2015-07-11 Thread Ronald S. Bultje
Hi,

On Sat, Jul 11, 2015 at 1:03 AM, Paul B Mahol  wrote:

> Dana 11. 7. 2015. 04:50 osoba "Ronald S. Bultje" 
> napisala je:
> >
> > ---
> >  libavfilter/vf_psnr.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
> > index 0c2c950..d9a6030 100644
> > --- a/libavfilter/vf_psnr.c
> > +++ b/libavfilter/vf_psnr.c
> > @@ -289,9 +289,9 @@ static int config_input_ref(AVFilterLink *inlink)
> >  }
> >
> >  s->is_rgb = ff_fill_rgba_map(s->rgba_map, inlink->format) >= 0;
> > -s->comps[0] = s->is_rgb ? 'r' : 'y' ;
> > -s->comps[1] = s->is_rgb ? 'g' : 'u' ;
> > -s->comps[2] = s->is_rgb ? 'b' : 'v' ;
> > +s->comps[0] = s->is_rgb ? 'g' : 'y' ;
> > +s->comps[1] = s->is_rgb ? 'b' : 'u' ;
> > +s->comps[2] = s->is_rgb ? 'r' : 'v' ;
> >  s->comps[3] = 'a';
> >
> >  s->planeheight[1] = s->planeheight[2] = FF_CEIL_RSHIFT(inlink->h,
> desc->log2_chroma_h);
> > --
> > 2.1.2
> >
>
> See rgba_map above, this breaks code that use it.


Oh, I see, I didn't notice that, I guess patch withdrawn then.

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


Re: [FFmpeg-devel] [PATCH] yuv4mpeg: add rough duration estimate and seeking.

2015-07-11 Thread Paul B Mahol
Dana 11. 7. 2015. 03:16 osoba "Ronald S. Bultje" 
napisala je:
>
> ---
>  libavformat/yuv4mpeg.h   |  1 +
>  libavformat/yuv4mpegdec.c| 26 +++
>  tests/ref/seek/lavf-yuv4mpeg | 78
+---
>  3 files changed, 72 insertions(+), 33 deletions(-)
>
> diff --git a/libavformat/yuv4mpeg.h b/libavformat/yuv4mpeg.h
> index 750f498..eba7337 100644
> --- a/libavformat/yuv4mpeg.h
> +++ b/libavformat/yuv4mpeg.h
> @@ -23,5 +23,6 @@
>
>  #define Y4M_MAGIC "YUV4MPEG2"
>  #define Y4M_FRAME_MAGIC "FRAME"
> +#define Y4M_FRAME_MAGIC_LEN 6
>
>  #endif /* AVFORMAT_YUV4MPEG_H */
> diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
> index 7613c3c..4ebdb78 100644
> --- a/libavformat/yuv4mpegdec.c
> +++ b/libavformat/yuv4mpegdec.c
> @@ -256,6 +256,12 @@ static int yuv4_read_header(AVFormatContext *s)
>  st->sample_aspect_ratio   = (AVRational){ aspectn, aspectd };
>  st->codec->chroma_sample_location = chroma_sample_location;
>  st->codec->field_order= field_order;
> +s->packet_size = avpicture_get_size(st->codec->pix_fmt, width,
height) + Y4M_FRAME_MAGIC_LEN;
> +if ((int) s->packet_size < 0)
> +return s->packet_size;
> +s->internal->data_offset = avio_tell(pb);
> +
> +st->duration = (avio_size(pb) - avio_tell(pb)) / s->packet_size;
>
>  return 0;
>  }
> @@ -264,7 +270,7 @@ static int yuv4_read_packet(AVFormatContext *s,
AVPacket *pkt)
>  {
>  int i;
>  char header[MAX_FRAME_HEADER+1];
> -int packet_size, width, height, ret;
> +int width, height, ret, off = avio_tell(s->pb);
>  AVStream *st = s->streams[0];
>
>  for (i = 0; i < MAX_FRAME_HEADER; i++) {
> @@ -287,17 +293,22 @@ static int yuv4_read_packet(AVFormatContext *s,
AVPacket *pkt)
>  width  = st->codec->width;
>  height = st->codec->height;
>
> -packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
> -if (packet_size < 0)
> -return packet_size;
> -
> -ret = av_get_packet(s->pb, pkt, packet_size);
> +ret = av_get_packet(s->pb, pkt, s->packet_size -
Y4M_FRAME_MAGIC_LEN);
>  if (ret < 0)
>  return ret;
> -else if (ret != packet_size)
> +else if (ret != s->packet_size - Y4M_FRAME_MAGIC_LEN)
>  return s->pb->eof_reached ? AVERROR_EOF : AVERROR(EIO);
>
>  pkt->stream_index = 0;
> +pkt->pts = (off - s->internal->data_offset) / s->packet_size;
> +pkt->duration = 1;
> +return 0;
> +}
> +
> +static int yuv4_read_seek(AVFormatContext *s, int stream_index,
> +  int64_t pts, int flags)
> +{
> +avio_seek(s->pb, pts * s->packet_size + s->internal->data_offset,
SEEK_SET);
>  return 0;
>  }
>
> @@ -316,5 +327,6 @@ AVInputFormat ff_yuv4mpegpipe_demuxer = {
>  .read_probe = yuv4_probe,
>  .read_header= yuv4_read_header,
>  .read_packet= yuv4_read_packet,
> +.read_seek  = yuv4_read_seek,
>  .extensions = "y4m",
>  };
> diff --git a/tests/ref/seek/lavf-yuv4mpeg b/tests/ref/seek/lavf-yuv4mpeg
> index 81c1de9..60c3036 100644
> --- a/tests/ref/seek/lavf-yuv4mpeg
> +++ b/tests/ref/seek/lavf-yuv4mpeg
> @@ -1,27 +1,53 @@
>  ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos: 64
size:152064
> -ret:-1 st:-1 flags:0  ts:-1.00
> -ret:-1 st:-1 flags:1  ts: 1.894167
> -ret:-1 st: 0 flags:0  ts: 0.80
> -ret:-1 st: 0 flags:1  ts:-0.32
> -ret:-1 st:-1 flags:0  ts: 2.576668
> -ret:-1 st:-1 flags:1  ts: 1.470835
> -ret:-1 st: 0 flags:0  ts: 0.36
> -ret:-1 st: 0 flags:1  ts:-0.76
> -ret:-1 st:-1 flags:0  ts: 2.153336
> -ret:-1 st:-1 flags:1  ts: 1.047503
> -ret:-1 st: 0 flags:0  ts:-0.04
> -ret:-1 st: 0 flags:1  ts: 2.84
> -ret:-1 st:-1 flags:0  ts: 1.730004
> -ret:-1 st:-1 flags:1  ts: 0.624171
> -ret:-1 st: 0 flags:0  ts:-0.48
> -ret:-1 st: 0 flags:1  ts: 2.40
> -ret:-1 st:-1 flags:0  ts: 1.306672
> -ret:-1 st:-1 flags:1  ts: 0.200839
> -ret:-1 st: 0 flags:0  ts:-0.92
> -ret:-1 st: 0 flags:1  ts: 2.00
> -ret:-1 st:-1 flags:0  ts: 0.883340
> -ret:-1 st:-1 flags:1  ts:-0.222493
> -ret:-1 st: 0 flags:0  ts: 2.68
> -ret:-1 st: 0 flags:1  ts: 1.56
> -ret:-1 st:-1 flags:0  ts: 0.460008
> -ret:-1 st:-1 flags:1  ts:-0.645825
> +ret: 0 st:-1 flags:0  ts:-1.00
> +ret: 0 st: 0 flags:1 dts: 0.04 pts: 0.04 pos: 152134
size:152064
> +ret: 0 st:-1 flags:1  ts: 1.894167
> +ret:-EOF
> +ret: 0 st: 0 flags:0  ts: 0.80
> +ret: 0 st: 0 flags:1 dts: 0.80 pts: 0.80 pos:3041464
size:152064
> +ret: 0 st: 0 flags:1  ts:-0.32
> +ret: 0 st: 0 flags:1 dts: 0.84 pts: 0.84 pos:3193534
size:152064
> +ret: 0 st:-1 flags:0  ts: 2.576668
> +ret:-EOF
> +ret: 0  

Re: [FFmpeg-devel] [PATCH] vF_psnr: move set_meta() calls out of loop.

2015-07-11 Thread Michael Niedermayer
On Sat, Jul 11, 2015 at 05:01:03AM +, Paul B Mahol wrote:
> Dana 11. 7. 2015. 04:47 osoba "Ronald S. Bultje" 
> napisala je:
> >
> > ---
> >  libavfilter/vf_psnr.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
> > index b2c6531..0c2c950 100644
> > --- a/libavfilter/vf_psnr.c
> > +++ b/libavfilter/vf_psnr.c
> > @@ -173,10 +173,10 @@ static AVFrame *do_psnr(AVFilterContext *ctx,
> AVFrame *main,
> >  for (j = 0; j < s->nb_components; j++) {
> >  c = s->is_rgb ? s->rgba_map[j] : j;
> >  set_meta(metadata, "lavfi.psnr.mse.", s->comps[j], comp_mse[c]);
> > -set_meta(metadata, "lavfi.psnr.mse_avg", 0, mse);
> >  set_meta(metadata, "lavfi.psnr.psnr.", s->comps[j],
> get_psnr(comp_mse[c], 1, s->max[c]));
> > -set_meta(metadata, "lavfi.psnr.psnr_avg", 0, get_psnr(mse, 1,
> s->average_max));
> >  }
> > +set_meta(metadata, "lavfi.psnr.mse_avg", 0, mse);
> > +set_meta(metadata, "lavfi.psnr.psnr_avg", 0, get_psnr(mse, 1,
> s->average_max));
> >
> >  if (s->stats_file) {
> >  fprintf(s->stats_file, "n:%"PRId64" mse_avg:%0.2f ",
> s->nb_frames, mse);
> > --
> > 2.1.2
> >
> 
> Oops, LGTM.

applied

thanks

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

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA


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


[FFmpeg-devel] Controlling the server reply (was: 9/9] doc/example: Add http multi-client) example code

2015-07-11 Thread Nicolas George
Le primidi 21 messidor, an CCXXIII, Stephan Holljes a écrit :
> Good question, I haven't thought about that myself. Adding a 404 error
> to handle_http_errors() and calling it with AVERROR_HTTP_NOT_FOUND
> could be a solution. I feel like the name "handle_http_errors" is not
> well chosen then, though.

Unfortunately, that will not do, because handle_http_errors() is not public
API.

And this is a rather fundamental issue, we can not disregard it just by
making handle_http_errors() public. I had hoped we could finish this patch
series and handle this issue afterwards, but it seems it must be addressed
sooner. Let me explain.

Returning 404 Not found, or 401 Unauthorized, or... is performed by the
library, but it is the decision of the application (I hope the distinction
between application and library is clear). The library can not know if a
particular file exists or not, because it does not even know if the
application is getting the files from the filesystem or from a database or
from on-the-fly computations. And the library can even less know the policy
for authorizing files.

I can see three rather distinct sub-issues:

Q1. how the library communicates to the application the details of the
request;

Q2. how the application communicates to the library the decision it made;

Q3. when the application can make its decision.

Q3 is the crux of the problem: remember we had to split avio_accept() into
avio_accept() and avio_handshake() to give the application a chance of
forking or any other solution to handle several clients in parallel. Just
the same, we will have to split avio_handshake() further to give the
application a chance of making a decision.

Furthermore, we need something that will work not only for HTTP but for any
protocol that FFmpeg may support as a server.

Q1 is the logical equivalent to the "address" parameter to the accept()
system call. To be sure of it, think of an application that serves files
without authentication on the local network but requires authentication
otherwise: the client's address is part of the decision making.

Q1 has a rather obvious and easy answer, that is the reason I hoped we could
leave it for later: put the request parameters in the context and access
them with the AVOption system. Thus, the application would access the
request path with something like "av_opt_get(client_ctx,
"http_request_path", AV_OPT_SEARCH_CHILDREN)".

Q2 have the same obvious answer: "av_opt_set_int(client_ctx,
"http_reply_code", 404)".

Q3 is the hard part.

I can see an answer to Q3, but since this is your internship, I think it is
better to give you a chance to find your own answer first.

When thinking on it, remember two situations that the API must be able to
handle:

* A protocol can have several round-trips with decision to make at each
  step. For example, first negotiate the authentication scheme, then
  authenticate, then request a resource. All this is part of the handshake,
  but the application needs an entry point at each step.

* Nested protocols: in HTTP-over-TCP, there is no decision to make until we
  have the full request, but in HTTP-over-TLS, i.e. HTTPS, the application
  needs a hook during the TLS handshake to handle Server Name Indication,
  and then the normal HTTP hook to set the reply code. We do not want to add
  special code in the upper protocol to handle the lower protocol.

Please let me know your thoughts about that.

Regards,

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