Re: [libav-devel] [PATCH] Revert mov: Double-check that alias path is not an absolute path

2015-07-15 Thread Vittorio Giovara
On Fri, Jul 10, 2015 at 7:41 PM, Hendrik Leppkes h.lepp...@gmail.com wrote:
 On Fri, Jul 10, 2015 at 7:46 PM, Vittorio Giovara
 vittorio.giov...@gmail.com wrote:
 This reverts commit 9286de045968ad456d4e752651eec22de5e89060.
 The change broke support for legit absolute file paths.

 Reported-by: Maksym Veremeyenko ve...@m1stereo.tv.
 ---
 It looks like there are more samples that reference absolute path files
 than samples referencing files from the same directory.
 I proposed to just revert the change for now, and think on a solution when
 the number of samples of the second kind increases.


 I think breaking absolute file paths was the entire point of this change?

Not quite, it was making sure that when dref type 18 was parsed you'd
not try to load from absolute when references were stored in the same
level of the source.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] Revert mov: Double-check that alias path is not an absolute path

2015-07-15 Thread Vittorio Giovara
On Fri, Jul 10, 2015 at 8:12 PM, Luca Barbato lu_z...@gentoo.org wrote:
 On 10/07/15 19:46, Vittorio Giovara wrote:
 This reverts commit 9286de045968ad456d4e752651eec22de5e89060.
 The change broke support for legit absolute file paths.

 Reported-by: Maksym Veremeyenko ve...@m1stereo.tv.
 ---
 It looks like there are more samples that reference absolute path files
 than samples referencing files from the same directory.
 I proposed to just revert the change for now, and think on a solution when
 the number of samples of the second kind increases.

 Vittorio

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

 diff --git a/libavformat/mov.c b/libavformat/mov.c
 index d075645..eb42bf5 100644
 --- a/libavformat/mov.c
 +++ b/libavformat/mov.c
 @@ -2394,7 +2394,7 @@ static int mov_open_dref(AVIOContext **pb, char *src, 
 MOVDref *ref,
  {
  /* try relative path, we do not try the absolute because it can leak 
 information about our
 system to an attacker */
 -if (ref-nlvl_to  0  ref-nlvl_from  0  ref-path[0] != '/') {
 +if (ref-nlvl_to  0  ref-nlvl_from  0) {
  char filename[1024];
  char *src_path;
  int i, l;


 I'd rather provide a switch in the shape of -fflags savepath or such.

Probably a good idea, but this needs further study, so for the time
being I think it ought to be reverted.
-- 
Vittorio
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] asfdec: factor out seeking to the Data

2015-07-15 Thread Alexandra Hájková
when !pb-seekable happens, while breaks after reading Data Object
header, just before first data packet and asf_read_packet is called

On Wed, Jul 15, 2015 at 11:34 AM, Luca Barbato lu_z...@gentoo.org wrote:
 On 15/07/15 09:48, Alexandra Hájková wrote:
 ---
  libavformat/asfdec.c | 27 +++
  1 file changed, 15 insertions(+), 12 deletions(-)

 What happens when you have non-seekable streams?

 +/* Data are skipped for the first time, Index object is processed,
 + * EOF is reached and then seeking back to the Data is performed.

 using `Data objects` instead of `Data` would probably clarify this comment.

 lu

 ___
 libav-devel mailing list
 libav-devel@libav.org
 https://lists.libav.org/mailman/listinfo/libav-devel
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH] hevc: Split the struct setup from the pps parsing

2015-07-15 Thread Luca Barbato
On 14/07/15 12:36, Luca Barbato wrote:
 ---
 
 Properly rebased version
 

Ping.

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 1/2] asfdec: align object position only if its size is not too big

2015-07-15 Thread Alexandra Hájková
if size is invalid seek to the Data or return error
---
 libavformat/asfdec.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 7af3728..34841e9 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -1660,7 +1660,15 @@ static int asf_read_header(AVFormatContext *s)
 return ret;
 } else {
 size = avio_rl64(pb);
-align_position(pb, asf-offset, size);
+if (size  INT64_MAX)
+align_position(pb, asf-offset, size);
+else {
+if (asf-data_reached) {
+avio_seek(pb, asf-first_packet_offset, SEEK_SET);
+break;
+} else
+return AVERROR_INVALIDDATA;
+}
 }
 if (asf-data_reached  !pb-seekable)
 break;
-- 
2.0.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 2/2] asfdec: ommit the wrong condition

2015-07-15 Thread Alexandra Hájková
---
 libavformat/asfdec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 34841e9..ab230e7 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -903,7 +903,7 @@ static int asf_read_data(AVFormatContext *s, const 
GUIDParseTable *g)
 uint64_t size   = asf-data_size = avio_rl64(pb);
 int i;
 
-if (!asf-data_reached  pb-seekable) {
+if (!asf-data_reached) {
 asf-data_reached   = 1;
 asf-data_offset= asf-offset;
 }
-- 
2.0.1

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] checkasm: Add unit tests for h264qpel

2015-07-15 Thread Janne Grunau
On 2015-07-14 01:14:27 +0200, Luca Barbato wrote:
 On 13/07/15 23:21, Henrik Gramner wrote:
  Attaching a modified version that also verifies that the src buffers
  are identical after the calls. Probably overkill, but might as well
  check while we're at it.
  
 
 Beside few nits I can fix myself it looks fine to me, Janne are you ok
 with it?

looks good to me

Janne
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] hevc: Split the struct setup from the pps parsing

2015-07-15 Thread Luca Barbato
On 15/07/15 19:26, James Almer wrote:
 Function call overhead. ff_hevc_decode_nal_pps() is not an init function, it 
 may
 or may not be called for every decoded frame.

Actually the function is a tad big and will get bigger so probably won't
hurt leaving to the compiler the task to decide if inline or not.

lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH] libx262: Add support for the MPEG2 encoder

2015-07-15 Thread Luca Barbato
---

As Anton suggested now x262 is a subfeature of x264

 configure  |  5 +++-
 libavcodec/Makefile|  1 +
 libavcodec/allcodecs.c |  1 +
 libavcodec/libx264.c   | 62 +++---
 4 files changed, 60 insertions(+), 9 deletions(-)

diff --git a/configure b/configure
index 28115d3..5e66034 100755
--- a/configure
+++ b/configure
@@ -1607,6 +1607,7 @@ CONFIG_EXTRA=
 imdct15
 intrax8
 jpegtables
+libx262
 lgplv3
 lpc
 me_cmp
@@ -4351,7 +4352,9 @@ enabled libwavpack require libwavpack 
wavpack/wavpack.h WavpackOpenFil
 enabled libwebprequire_pkg_config libwebp webp/encode.h 
WebPGetEncoderVersion
 enabled libx264require_pkg_config x264 stdint.h x264.h 
x264_encoder_encode 
  { check_cpp_condition x264.h X264_BUILD = 118 
||
-   die ERROR: libx264 version must be = 0.118.; 
}
+   die ERROR: libx264 version must be = 0.118.; 
} 
+ { check_cpp_condition x264.h X264_MPEG2 
+   enable libx262; }
 enabled libx265require_pkg_config x265 x265.h x265_api_get 
  { check_cpp_condition x265.h X265_BUILD = 57 ||
die ERROR: libx265 version must be = 57.; }
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index d933ffd..008207b 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -671,6 +671,7 @@ OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o 
libvpx.o
 OBJS-$(CONFIG_LIBVPX_VP9_ENCODER) += libvpxenc.o libvpx.o
 OBJS-$(CONFIG_LIBWAVPACK_ENCODER) += libwavpackenc.o
 OBJS-$(CONFIG_LIBWEBP_ENCODER)+= libwebpenc.o
+OBJS-$(CONFIG_LIBX262_ENCODER)+= libx264.o
 OBJS-$(CONFIG_LIBX264_ENCODER)+= libx264.o
 OBJS-$(CONFIG_LIBX265_ENCODER)+= libx265.o
 OBJS-$(CONFIG_LIBXAVS_ENCODER)+= libxavs.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index a3f1550..9fdbe8f 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -473,6 +473,7 @@ void avcodec_register_all(void)
 REGISTER_ENCDEC (LIBVPX_VP9,libvpx_vp9);
 REGISTER_ENCODER(LIBWAVPACK,libwavpack);
 REGISTER_ENCODER(LIBWEBP,   libwebp);
+REGISTER_ENCODER(LIBX262,   libx262);
 REGISTER_ENCODER(LIBX264,   libx264);
 REGISTER_ENCODER(LIBX265,   libx265);
 REGISTER_ENCODER(LIBXAVS,   libxavs);
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 7c502fd..7da09ca 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -319,11 +319,18 @@ static int convert_pix_fmt(enum AVPixelFormat pix_fmt)
 return AVERROR(EINVAL);\
 }

-static av_cold int X264_init(AVCodecContext *avctx)
+static av_always_inline int common_init(AVCodecContext *avctx, int mpeg2)
 {
 X264Context *x4 = avctx-priv_data;

+#if CONFIG_LIBX262_ENCODER
+if (mpeg2) {
+x4-params.b_mpeg2 = 1;
+x264_param_default_mpeg2(x4-params);
+} else
+#else
 x264_param_default(x4-params);
+#endif

 x4-params.b_deblocking_filter = avctx-flags  
CODEC_FLAG_LOOP_FILTER;

@@ -663,13 +670,6 @@ static const AVOption options[] = {
 { NULL },
 };

-static const AVClass class = {
-.class_name = libx264,
-.item_name  = av_default_item_name,
-.option = options,
-.version= LIBAVUTIL_VERSION_INT,
-};
-
 static const AVCodecDefault x264_defaults[] = {
 { b,0 },
 { bf,   -1 },
@@ -698,6 +698,20 @@ static const AVCodecDefault x264_defaults[] = {
 { NULL },
 };

+
+#if CONFIG_LIBX264_ENCODER
+static av_cold int X264_init(AVCodecContext *avctx)
+{
+return common_init(avctx, 0);
+}
+
+static const AVClass class = {
+.class_name = libx264,
+.item_name  = av_default_item_name,
+.option = options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
 AVCodec ff_libx264_encoder = {
 .name = libx264,
 .long_name= NULL_IF_CONFIG_SMALL(libx264 H.264 / AVC / MPEG-4 AVC 
/ MPEG-4 part 10),
@@ -714,3 +728,35 @@ AVCodec ff_libx264_encoder = {
 .caps_internal= FF_CODEC_CAP_INIT_THREADSAFE |
 FF_CODEC_CAP_INIT_CLEANUP,
 };
+#endif
+
+#if CONFIG_LIBX262_ENCODER
+static av_cold int X262_init(AVCodecContext *avctx)
+{
+return common_init(avctx, 1);
+}
+
+static const AVClass X262_class = {
+.class_name = libx262,
+.item_name  = av_default_item_name,
+.option = options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
+AVCodec ff_libx262_encoder = {
+.name = libx262,
+.long_name= NULL_IF_CONFIG_SMALL(libx262 MPEG2VIDEO),
+.type = AVMEDIA_TYPE_VIDEO,
+.id   = AV_CODEC_ID_MPEG2VIDEO,
+.priv_data_size   = sizeof(X264Context),
+.init = X262_init,
+

Re: [libav-devel] [PATCH] hevc: Split the struct setup from the pps parsing

2015-07-15 Thread James Almer
On 15/07/15 1:46 PM, Luca Barbato wrote:
 On 15/07/15 18:26, James Almer wrote:
 If this is done only for readability's sake and not because this function 
 will be
 used somewhere else, then making sure the compiler always inlines this 
 function may
 be a good idea.
 
 Good idea, the idea itself is fine?
 
 lu

The split? It won't hurt, so sure.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] hevc: Split the struct setup from the pps parsing

2015-07-15 Thread Anton Khirnov
Quoting James Almer (2015-07-15 19:26:08)
 On 15/07/15 2:06 PM, Anton Khirnov wrote:
  Quoting James Almer (2015-07-15 18:26:28)
  On 14/07/15 7:36 AM, Luca Barbato wrote:
  ---
 
  Properly rebased version
 
   libavcodec/hevc_ps.c | 258 
  ++-
   1 file changed, 131 insertions(+), 127 deletions(-)
 
  diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
  index a5a2ace..2112265 100644
  --- a/libavcodec/hevc_ps.c
  +++ b/libavcodec/hevc_ps.c
  @@ -1039,14 +1039,139 @@ static void hevc_pps_free(void *opaque, uint8_t 
  *data)
   av_freep(pps);
   }
 
  +static int setup_pps(AVCodecContext *avctx, GetBitContext *gb,
 
  If this is done only for readability's sake and not because this function 
  will be
  used somewhere else, then making sure the compiler always inlines this 
  function may
  be a good idea.
 
  
  Why should that be important in this specific case?
 
 Function call overhead. ff_hevc_decode_nal_pps() is not an init function, it 
 may
 or may not be called for every decoded frame.

If it gets called every frame, then the function call overhead is the
least of our worries. Worrying about such microoptimizations is IMO
counterproductive, unless there's a good reason to think they actually
have a measurable effect.

-- 
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 13/15] Gather all coded_frame allocations and free functions to a single place

2015-07-15 Thread Vittorio Giovara
Allocating coded_frame is what most encoders do anyway, so it makes
sense to always allocate it in a single place. This bring uniformity to
encoder behaviour and prevents applications from erroneusly accessing
this field when not allocated.

Additionally this helps isolating encoders that export information with
it, and it heavily simplifies its deprecation.

Signed-off-by: Vittorio Giovara vittorio.giov...@gmail.com
---
 libavcodec/a64multienc.c|  7 ---
 libavcodec/alacenc.c|  7 ---
 libavcodec/aliaspixenc.c| 16 
 libavcodec/asvenc.c | 18 ++
 libavcodec/bmpenc.c | 11 ---
 libavcodec/cljrenc.c| 17 -
 libavcodec/dnxhdenc.c   |  6 --
 libavcodec/dpxenc.c | 11 ---
 libavcodec/dvenc.c  | 11 ---
 libavcodec/ffv1enc.c|  5 -
 libavcodec/flashsvenc.c |  8 
 libavcodec/gif.c|  6 --
 libavcodec/huffyuvenc.c |  5 +
 libavcodec/jpeglsenc.c  | 11 ---
 libavcodec/lclenc.c |  6 --
 libavcodec/libopencore-amr.c|  1 -
 libavcodec/libopenjpegenc.c |  8 
 libavcodec/libschroedingerenc.c |  6 --
 libavcodec/libspeexenc.c|  4 ++--
 libavcodec/libtheoraenc.c   |  6 --
 libavcodec/libvpxenc.c  |  7 ---
 libavcodec/libx264.c|  6 --
 libavcodec/libx265.c|  8 
 libavcodec/libxavs.c|  6 --
 libavcodec/libxvid.c|  4 
 libavcodec/ljpegenc.c   |  5 -
 libavcodec/mpegvideo_enc.c  |  3 +--
 libavcodec/nvenc.c  |  6 --
 libavcodec/pamenc.c | 11 ---
 libavcodec/pcm.c| 11 ---
 libavcodec/pcxenc.c | 11 ---
 libavcodec/pngenc.c | 11 ---
 libavcodec/pnmenc.c | 14 --
 libavcodec/proresenc.c  |  5 -
 libavcodec/qsvenc.c |  6 --
 libavcodec/qtrleenc.c   |  8 
 libavcodec/rawenc.c | 11 ---
 libavcodec/sgienc.c | 11 ---
 libavcodec/sunrastenc.c | 11 ---
 libavcodec/svq1enc.c|  4 +---
 libavcodec/targaenc.c   | 11 ---
 libavcodec/tiffenc.c| 11 ---
 libavcodec/utils.c  | 12 ++--
 libavcodec/utvideoenc.c |  9 -
 libavcodec/v210enc.c| 12 
 libavcodec/v410enc.c| 15 ---
 libavcodec/xbmenc.c | 11 ---
 libavcodec/xwdenc.c | 18 --
 libavcodec/zmbvenc.c|  8 
 49 files changed, 17 insertions(+), 419 deletions(-)

diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c
index 1bd8287..192adb5 100644
--- a/libavcodec/a64multienc.c
+++ b/libavcodec/a64multienc.c
@@ -166,7 +166,6 @@ static void render_charset(AVCodecContext *avctx, uint8_t 
*charset,
 static av_cold int a64multi_close_encoder(AVCodecContext *avctx)
 {
 A64Context *c = avctx-priv_data;
-av_frame_free(avctx-coded_frame);
 av_free(c-mc_meta_charset);
 av_free(c-mc_best_cb);
 av_free(c-mc_charset);
@@ -218,12 +217,6 @@ static av_cold int a64multi_encode_init(AVCodecContext 
*avctx)
 AV_WB32(avctx-extradata, c-mc_lifetime);
 AV_WB32(avctx-extradata + 16, INTERLACED);
 
-avctx-coded_frame = av_frame_alloc();
-if (!avctx-coded_frame) {
-a64multi_close_encoder(avctx);
-return AVERROR(ENOMEM);
-}
-
 avctx-coded_frame-pict_type = AV_PICTURE_TYPE_I;
 avctx-coded_frame-key_frame = 1;
 if (!avctx-codec_tag)
diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c
index 401f26f..cf7 100644
--- a/libavcodec/alacenc.c
+++ b/libavcodec/alacenc.c
@@ -483,7 +483,6 @@ static av_cold int alac_encode_close(AVCodecContext *avctx)
 ff_lpc_end(s-lpc_ctx);
 av_freep(avctx-extradata);
 avctx-extradata_size = 0;
-av_freep(avctx-coded_frame);
 return 0;
 }
 
@@ -579,12 +578,6 @@ static av_cold int alac_encode_init(AVCodecContext *avctx)
 goto error;
 }
 
-avctx-coded_frame = av_frame_alloc();
-if (!avctx-coded_frame) {
-ret = AVERROR(ENOMEM);
-goto error;
-}
-
 s-avctx = avctx;
 
 if ((ret = ff_lpc_init(s-lpc_ctx, avctx-frame_size,
diff --git a/libavcodec/aliaspixenc.c b/libavcodec/aliaspixenc.c
index 47e0612..5e3bcb4 100644
--- a/libavcodec/aliaspixenc.c
+++ b/libavcodec/aliaspixenc.c
@@ -27,14 +27,6 @@
 
 #define ALIAS_HEADER_SIZE 10
 
-static av_cold int encode_init(AVCodecContext *avctx)
-{
-avctx-coded_frame = av_frame_alloc();
-if (!avctx-coded_frame)
-return AVERROR(ENOMEM);
-return 0;
-}
-
 static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 const AVFrame *frame, int *got_packet)
 {
@@ -114,20 +106,12 

[libav-devel] [PATCH 10/15] ffv1enc: Keep coded_frame.key_frame a write-only variable

2015-07-15 Thread Vittorio Giovara
---
 libavcodec/ffv1.h|  1 +
 libavcodec/ffv1enc.c | 11 ++-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index bc433bc..6e8c798 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -78,6 +78,7 @@ typedef struct FFV1Context {
 int transparency;
 int flags;
 int picture_number;
+int key_frame;
 const AVFrame *frame;
 AVFrame *last_picture;
 
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index f689bd9..ad52f15 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -884,7 +884,7 @@ static int encode_slice(AVCodecContext *c, void *arg)
? (f-bits_per_raw_sample  8) + 1
: 4;
 
-if (c-coded_frame-key_frame)
+if (f-key_frame)
 ffv1_clear_slice_state(f, fs);
 if (f-version  2) {
 encode_slice_header(f, fs);
@@ -931,7 +931,6 @@ static int ffv1_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 {
 FFV1Context *f  = avctx-priv_data;
 RangeCoder *const c = f-slice_context[0]-c;
-AVFrame *const p= avctx-coded_frame;
 int used_count  = 0;
 uint8_t keystate= 128;
 uint8_t *buf_p;
@@ -951,12 +950,12 @@ static int ffv1_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 
 if (avctx-gop_size == 0 || f-picture_number % avctx-gop_size == 0) {
 put_rac(c, keystate, 1);
-p-key_frame = 1;
+f-key_frame = 1;
 f-gob_count++;
 write_header(f);
 } else {
 put_rac(c, keystate, 0);
-p-key_frame = 0;
+f-key_frame = 0;
 }
 
 if (f-ac  1) {
@@ -1050,9 +1049,11 @@ static int ffv1_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 } else if (avctx-flags  CODEC_FLAG_PASS1)
 avctx-stats_out[0] = '\0';
 
+avctx-coded_frame-key_frame = f-key_frame;
+
 f-picture_number++;
 pkt-size   = buf_p - pkt-data;
-pkt-flags |= AV_PKT_FLAG_KEY * p-key_frame;
+pkt-flags |= AV_PKT_FLAG_KEY * f-key_frame;
 *got_packet = 1;
 
 return 0;
-- 
1.9.5 (Apple Git-50.3)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] hevc: Split the struct setup from the pps parsing

2015-07-15 Thread Anton Khirnov
Quoting James Almer (2015-07-15 18:26:28)
 On 14/07/15 7:36 AM, Luca Barbato wrote:
  ---
  
  Properly rebased version
  
   libavcodec/hevc_ps.c | 258 
  ++-
   1 file changed, 131 insertions(+), 127 deletions(-)
  
  diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
  index a5a2ace..2112265 100644
  --- a/libavcodec/hevc_ps.c
  +++ b/libavcodec/hevc_ps.c
  @@ -1039,14 +1039,139 @@ static void hevc_pps_free(void *opaque, uint8_t 
  *data)
   av_freep(pps);
   }
  
  +static int setup_pps(AVCodecContext *avctx, GetBitContext *gb,
 
 If this is done only for readability's sake and not because this function 
 will be
 used somewhere else, then making sure the compiler always inlines this 
 function may
 be a good idea.
 

Why should that be important in this specific case?

-- 
Anton Khirnov
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] hevc: Split the struct setup from the pps parsing

2015-07-15 Thread James Almer
On 15/07/15 2:06 PM, Anton Khirnov wrote:
 Quoting James Almer (2015-07-15 18:26:28)
 On 14/07/15 7:36 AM, Luca Barbato wrote:
 ---

 Properly rebased version

  libavcodec/hevc_ps.c | 258 
 ++-
  1 file changed, 131 insertions(+), 127 deletions(-)

 diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
 index a5a2ace..2112265 100644
 --- a/libavcodec/hevc_ps.c
 +++ b/libavcodec/hevc_ps.c
 @@ -1039,14 +1039,139 @@ static void hevc_pps_free(void *opaque, uint8_t 
 *data)
  av_freep(pps);
  }

 +static int setup_pps(AVCodecContext *avctx, GetBitContext *gb,

 If this is done only for readability's sake and not because this function 
 will be
 used somewhere else, then making sure the compiler always inlines this 
 function may
 be a good idea.

 
 Why should that be important in this specific case?

Function call overhead. ff_hevc_decode_nal_pps() is not an init function, it may
or may not be called for every decoded frame.

The split in question doesn't seem to be anything but cosmetics, so might as 
well
make sure it doesn't affect performance, even if marginally, for no real gain.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 02/15] roqvideoenc: Drop unneeded initialization

2015-07-15 Thread Vittorio Giovara
Its fields are never initialized to begin with.
---
 libavcodec/roqvideoenc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index 872bee8..32dabae 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -955,8 +955,6 @@ static int roq_encode_video(RoqContext *enc)
 reconstruct_and_encode_image(enc, tempData, enc-width, enc-height,
  enc-width*enc-height/64);
 
-enc-avctx-coded_frame = enc-current_frame;
-
 /* Rotate frame history */
 FFSWAP(AVFrame *, enc-current_frame, enc-last_frame);
 FFSWAP(motion_vect *, enc-last_motion4, enc-this_motion4);
-- 
1.9.5 (Apple Git-50.3)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 01/15] mpegvideo_enc: Drop unnneded initialization

2015-07-15 Thread Vittorio Giovara
coded_frame is already initialized where needed.
---
 libavcodec/mpegvideo_enc.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index f88e009..35c7839 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -722,8 +722,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
 ff_pixblockdsp_init(s-pdsp, avctx);
 ff_qpeldsp_init(s-qdsp);
 
-s-avctx-coded_frame = s-current_picture.f;
-
 if (s-msmpeg4_version) {
 FF_ALLOCZ_OR_GOTO(s-avctx, s-ac_stats,
   2 * 2 * (MAX_LEVEL + 1) *
-- 
1.9.5 (Apple Git-50.3)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 07/15] libvpxenc: Do not entangle coded_frame

2015-07-15 Thread Vittorio Giovara
Keep coded_frame.key_frame a write-only variable.
---
 libavcodec/libvpxenc.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index f690de1..e8c7327 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -398,20 +398,21 @@ static inline void cx_pktcpy(struct FrameListData *dst,
  * @return a negative AVERROR on error
  */
 static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame,
-  AVPacket *pkt, AVFrame *coded_frame)
+  AVPacket *pkt)
 {
 int ret = ff_alloc_packet(pkt, cx_frame-sz);
 if (ret = 0) {
 memcpy(pkt-data, cx_frame-buf, pkt-size);
-pkt-pts = pkt-dts= cx_frame-pts;
-coded_frame-pts   = cx_frame-pts;
-coded_frame-key_frame = !!(cx_frame-flags  VPX_FRAME_IS_KEY);
-
-if (coded_frame-key_frame) {
-coded_frame-pict_type = AV_PICTURE_TYPE_I;
-pkt-flags|= AV_PKT_FLAG_KEY;
-} else
-coded_frame-pict_type = AV_PICTURE_TYPE_P;
+pkt-pts = pkt-dts = cx_frame-pts;
+avctx-coded_frame-pts   = cx_frame-pts;
+avctx-coded_frame-key_frame = !!(cx_frame-flags  VPX_FRAME_IS_KEY);
+
+if (!!(cx_frame-flags  VPX_FRAME_IS_KEY)) {
+avctx-coded_frame-pict_type = AV_PICTURE_TYPE_I;
+pkt-flags |= AV_PKT_FLAG_KEY;
+} else {
+avctx-coded_frame-pict_type = AV_PICTURE_TYPE_P;
+}
 } else {
 av_log(avctx, AV_LOG_ERROR,
Error getting output packet of size %zu.\n, cx_frame-sz);
@@ -428,8 +429,7 @@ static int storeframe(AVCodecContext *avctx, struct 
FrameListData *cx_frame,
  * @return AVERROR(EINVAL) on output size error
  * @return AVERROR(ENOMEM) on coded frame queue data allocation error
  */
-static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out,
-AVFrame *coded_frame)
+static int queue_frames(AVCodecContext *avctx, AVPacket *pkt_out)
 {
 VP8Context *ctx = avctx-priv_data;
 const struct vpx_codec_cx_pkt *pkt;
@@ -439,7 +439,7 @@ static int queue_frames(AVCodecContext *avctx, AVPacket 
*pkt_out,
 if (ctx-coded_frame_list) {
 struct FrameListData *cx_frame = ctx-coded_frame_list;
 /* return the leading frame if we've already begun queueing */
-size = storeframe(avctx, cx_frame, pkt_out, coded_frame);
+size = storeframe(avctx, cx_frame, pkt_out);
 if (size  0)
 return size;
 ctx-coded_frame_list = cx_frame-next;
@@ -458,7 +458,7 @@ static int queue_frames(AVCodecContext *avctx, AVPacket 
*pkt_out,
provided a frame for output */
 assert(!ctx-coded_frame_list);
 cx_pktcpy(cx_frame, pkt);
-size = storeframe(avctx, cx_frame, pkt_out, coded_frame);
+size = storeframe(avctx, cx_frame, pkt_out);
 if (size  0)
 return size;
 } else {
@@ -537,7 +537,7 @@ static int vp8_encode(AVCodecContext *avctx, AVPacket *pkt,
 log_encoder_error(avctx, Error encoding frame);
 return AVERROR_INVALIDDATA;
 }
-coded_size = queue_frames(avctx, pkt, avctx-coded_frame);
+coded_size = queue_frames(avctx, pkt);
 
 if (!frame  avctx-flags  CODEC_FLAG_PASS1) {
 unsigned int b64_size = AV_BASE64_SIZE(ctx-twopass_stats.sz);
-- 
1.9.5 (Apple Git-50.3)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 12/15] flashsvenc: Keep coded_frame.key_frame a write-only variable

2015-07-15 Thread Vittorio Giovara
---
 libavcodec/flashsvenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/flashsvenc.c b/libavcodec/flashsvenc.c
index 971ce1b..1c87ae3 100644
--- a/libavcodec/flashsvenc.c
+++ b/libavcodec/flashsvenc.c
@@ -275,7 +275,7 @@ static int flashsv_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 avctx-coded_frame-key_frame = 0;
 }
 
-if (avctx-coded_frame-key_frame)
+if (I_frame)
 pkt-flags |= AV_PKT_FLAG_KEY;
 *got_packet = 1;
 
-- 
1.9.5 (Apple Git-50.3)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 06/15] libxvid: Do not entangle coded_frame

2015-07-15 Thread Vittorio Giovara
---
 libavcodec/libxvid.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index 97ff95b..0012876 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -663,7 +663,6 @@ static int xvid_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 {
 int xerr, i, ret, user_packet = !!pkt-data;
 struct xvid_context *x = avctx-priv_data;
-AVFrame *p = avctx-coded_frame;
 int mb_width  = (avctx-width  + 15) / 16;
 int mb_height = (avctx-height + 15) / 16;
 char *tmp;
@@ -749,23 +748,24 @@ static int xvid_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 if (xerr  0) {
 *got_packet = 1;
 
-p-quality = xvid_enc_stats.quant * FF_QP2LAMBDA;
+avctx-coded_frame-quality = xvid_enc_stats.quant * FF_QP2LAMBDA;
 if (xvid_enc_stats.type == XVID_TYPE_PVOP)
-p-pict_type = AV_PICTURE_TYPE_P;
+avctx-coded_frame-pict_type = AV_PICTURE_TYPE_P;
 else if (xvid_enc_stats.type == XVID_TYPE_BVOP)
-p-pict_type = AV_PICTURE_TYPE_B;
+avctx-coded_frame-pict_type = AV_PICTURE_TYPE_B;
 else if (xvid_enc_stats.type == XVID_TYPE_SVOP)
-p-pict_type = AV_PICTURE_TYPE_S;
+avctx-coded_frame-pict_type = AV_PICTURE_TYPE_S;
 else
-p-pict_type = AV_PICTURE_TYPE_I;
+avctx-coded_frame-pict_type = AV_PICTURE_TYPE_I;
 if (xvid_enc_frame.out_flags  XVID_KEYFRAME) {
-p-key_frame = 1;
+avctx-coded_frame-key_frame = 1;
 pkt-flags  |= AV_PKT_FLAG_KEY;
 if (x-quicktime_format)
 return xvid_strip_vol_header(avctx, pkt,
  xvid_enc_stats.hlength, xerr);
-} else
-p-key_frame = 0;
+} else {
+avctx-coded_frame-key_frame = 0;
+}
 
 pkt-size = xerr;
 
-- 
1.9.5 (Apple Git-50.3)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 04/15] proresenc: Do not entangle coded_frame

2015-07-15 Thread Vittorio Giovara
---
 libavcodec/proresenc.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavcodec/proresenc.c b/libavcodec/proresenc.c
index 3a5524a..b71a7db 100644
--- a/libavcodec/proresenc.c
+++ b/libavcodec/proresenc.c
@@ -195,6 +195,7 @@ typedef struct ProresContext {
  int linesize, int16_t *block);
 FDCTDSPContext fdsp;
 
+const AVFrame *pic;
 int mb_width, mb_height;
 int mbs_per_slice;
 int num_chroma_blocks, chroma_factor;
@@ -743,7 +744,7 @@ static int estimate_alpha_plane(ProresContext *ctx, int 
*error,
 return bits;
 }
 
-static int find_slice_quant(AVCodecContext *avctx, const AVFrame *pic,
+static int find_slice_quant(AVCodecContext *avctx,
 int trellis_node, int x, int y, int mbs_per_slice,
 ProresThreadData *td)
 {
@@ -765,7 +766,7 @@ static int find_slice_quant(AVCodecContext *avctx, const 
AVFrame *pic,
 if (ctx-pictures_per_frame == 1)
 line_add = 0;
 else
-line_add = ctx-cur_picture_idx ^ !pic-top_field_first;
+line_add = ctx-cur_picture_idx ^ !ctx-pic-top_field_first;
 mbs = x + mbs_per_slice;
 
 for (i = 0; i  ctx-num_planes; i++) {
@@ -785,9 +786,9 @@ static int find_slice_quant(AVCodecContext *avctx, const 
AVFrame *pic,
 pwidth = avctx-width  1;
 }
 
-linesize[i] = pic-linesize[i] * ctx-pictures_per_frame;
-src = (const uint16_t*)(pic-data[i] + yp * linesize[i] +
-line_add * pic-linesize[i]) + xp;
+linesize[i] = ctx-pic-linesize[i] * ctx-pictures_per_frame;
+src = (const uint16_t *)(ctx-pic-data[i] + yp * linesize[i] +
+ line_add * ctx-pic-linesize[i]) + xp;
 
 if (i  3) {
 get_slice_data(ctx, src, linesize[i], xp, yp,
@@ -910,7 +911,7 @@ static int find_quant_thread(AVCodecContext *avctx, void 
*arg,
 for (x = mb = 0; x  ctx-mb_width; x += mbs_per_slice, mb++) {
 while (ctx-mb_width - x  mbs_per_slice)
 mbs_per_slice = 1;
-q = find_slice_quant(avctx, avctx-coded_frame,
+q = find_slice_quant(avctx,
  (mb + 1) * TRELLIS_WIDTH, x, y,
  mbs_per_slice, td);
 }
@@ -937,7 +938,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket 
*pkt,
 int pkt_size, ret, max_slice_size = 0;
 uint8_t frame_flags;
 
-*avctx-coded_frame   = *pic;
+ctx-pic = pic;
 avctx-coded_frame-pict_type = AV_PICTURE_TYPE_I;
 avctx-coded_frame-key_frame = 1;
 
-- 
1.9.5 (Apple Git-50.3)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] hevc: Split the struct setup from the pps parsing

2015-07-15 Thread Luca Barbato
On 15/07/15 18:26, James Almer wrote:
 If this is done only for readability's sake and not because this function 
 will be
 used somewhere else, then making sure the compiler always inlines this 
 function may
 be a good idea.

Good idea, the idea itself is fine?

lu
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 03/15] a64multienc: Do not entangle coded_frame

2015-07-15 Thread Vittorio Giovara
This change (and the following ones of the same kind) is mainly to simplify
wrapping this section with an #if block later on.

No functional changes are applied, the context coded_frame fields are
initialized instead of keeping a reference to it.

Signed-off-by: Vittorio Giovara vittorio.giov...@gmail.com
---
 libavcodec/a64multienc.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c
index d742dee..1bd8287 100644
--- a/libavcodec/a64multienc.c
+++ b/libavcodec/a64multienc.c
@@ -44,7 +44,8 @@ static const int mc_colors[5]={0x0,0xb,0xc,0xf,0x1};
 //static const int mc_colors[5]={0x0,0x8,0xa,0xf,0x7};
 //static const int mc_colors[5]={0x0,0x9,0x8,0xa,0x3};
 
-static void to_meta_with_crop(AVCodecContext *avctx, AVFrame *p, int *dest)
+static void to_meta_with_crop(AVCodecContext *avctx,
+  const AVFrame *p, int *dest)
 {
 int blockx, blocky, x, y;
 int luma = 0;
@@ -252,7 +253,6 @@ static int a64multi_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
  const AVFrame *pict, int *got_packet)
 {
 A64Context *c = avctx-priv_data;
-AVFrame *const p = avctx-coded_frame;
 
 int frame;
 int x, y;
@@ -296,10 +296,9 @@ static int a64multi_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 } else {
 /* fill up mc_meta_charset with data until lifetime exceeds */
 if (c-mc_frame_counter  c-mc_lifetime) {
-*p = *pict;
-p-pict_type = AV_PICTURE_TYPE_I;
-p-key_frame = 1;
-to_meta_with_crop(avctx, p, meta + 32000 * c-mc_frame_counter);
+avctx-coded_frame-pict_type = AV_PICTURE_TYPE_I;
+avctx-coded_frame-key_frame = 1;
+to_meta_with_crop(avctx, pict, meta + 32000 * c-mc_frame_counter);
 c-mc_frame_counter++;
 if (c-next_pts == AV_NOPTS_VALUE)
 c-next_pts = pict-pts;
-- 
1.9.5 (Apple Git-50.3)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 15/15] Deprecate avctx.coded_frame

2015-07-15 Thread Vittorio Giovara
The rationale is that coded_frame was only used to communicate key_frame,
pict_type and quality to the caller, as well as a few other random fields,
in a non predictable, let alone consistent way.

There was agreement that there was no use case for coded_frame, as it is
a full-sized AVFrame container used for just 2-3 int-sized properties,
which shouldn't even belong into the AVCodecContext in the first place.

The appropriate AVPacket flag can be used instead of key_frame, while
quality is exported with the new AVPacketSideData quality factor.
There is no replacement for the other fields as they were unreliable,
misused or just not used at all.

Signed-off-by: Vittorio Giovara vittorio.giov...@gmail.com
---
 avconv.c| 19 +++
 libavcodec/a64multienc.c|  8 
 libavcodec/aliaspixenc.c|  4 
 libavcodec/asvenc.c |  4 
 libavcodec/avcodec.h|  6 +-
 libavcodec/bmpenc.c |  4 
 libavcodec/cljrenc.c|  4 
 libavcodec/dnxhdenc.c   | 12 
 libavcodec/dpxenc.c |  4 
 libavcodec/dvenc.c  |  4 
 libavcodec/ffv1enc.c|  8 
 libavcodec/flashsvenc.c |  8 
 libavcodec/gif.c|  4 
 libavcodec/huffyuvenc.c |  4 
 libavcodec/jpeglsenc.c  |  4 
 libavcodec/lclenc.c |  4 
 libavcodec/libschroedingerenc.c |  8 ++--
 libavcodec/libtheoraenc.c   |  4 
 libavcodec/libvpxenc.c  | 12 
 libavcodec/libx264.c| 10 +-
 libavcodec/libx265.c|  4 
 libavcodec/libxavs.c| 16 
 libavcodec/libxvid.c| 12 
 libavcodec/ljpegenc.c   |  4 
 libavcodec/mpegvideo_enc.c  |  4 
 libavcodec/nvenc.c  |  4 
 libavcodec/pamenc.c |  4 
 libavcodec/pcxenc.c |  4 
 libavcodec/pngenc.c |  4 
 libavcodec/pnmenc.c |  4 
 libavcodec/proresenc.c  |  4 
 libavcodec/pthread_frame.c  |  4 
 libavcodec/qsvenc.c |  4 
 libavcodec/qtrleenc.c   |  6 +-
 libavcodec/rawenc.c |  4 
 libavcodec/sgienc.c |  4 
 libavcodec/sunrastenc.c |  4 
 libavcodec/svq1enc.c|  4 
 libavcodec/targaenc.c   |  4 
 libavcodec/tiffenc.c|  4 
 libavcodec/utils.c  | 12 
 libavcodec/utvideoenc.c |  4 
 libavcodec/v210enc.c|  4 
 libavcodec/v410enc.c|  4 
 libavcodec/version.h|  5 -
 libavcodec/xbmenc.c |  4 
 libavcodec/xwdenc.c |  4 
 libavcodec/zmbvenc.c|  4 
 libavdevice/v4l2.c  |  8 
 49 files changed, 280 insertions(+), 6 deletions(-)

diff --git a/avconv.c b/avconv.c
index b4654fc..597f436 100644
--- a/avconv.c
+++ b/avconv.c
@@ -38,6 +38,7 @@
 #include libavutil/parseutils.h
 #include libavutil/samplefmt.h
 #include libavutil/fifo.h
+#include libavutil/internal.h
 #include libavutil/intreadwrite.h
 #include libavutil/dict.h
 #include libavutil/mathematics.h
@@ -553,8 +554,12 @@ static void do_video_out(AVFormatContext *s,
 /* raw pictures are written as AVPicture structure to
avoid any copies. We support temporarily the older
method. */
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
 enc-coded_frame-interlaced_frame = in_picture-interlaced_frame;
 enc-coded_frame-top_field_first  = in_picture-top_field_first;
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 pkt.data   = (uint8_t *)in_picture;
 pkt.size   =  sizeof(AVPicture);
 pkt.pts= av_rescale_q(in_picture-pts, enc-time_base, 
ost-st-time_base);
@@ -629,8 +634,13 @@ static void do_video_stats(OutputStream *ost, int 
frame_size)
 frame_number = ost-frame_number;
 fprintf(vstats_file, frame= %5d q= %2.1f , frame_number,
 ost-quality / (float)FF_QP2LAMBDA);
+
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
 if (enc-flagsCODEC_FLAG_PSNR)
 fprintf(vstats_file, PSNR= %6.2f , 
psnr(enc-coded_frame-error[0] / (enc-width * enc-height * 255.0 * 255.0)));
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
 
 fprintf(vstats_file,f_size= %6d , frame_size);
 /* compute pts value */
@@ -642,7 +652,11 @@ static void do_video_stats(OutputStream *ost, int 
frame_size)
 avg_bitrate = (double)(ost-data_size * 8) / ti1 / 1000.0;
 fprintf(vstats_file, s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s 
avg_br= %7.1fkbits/s ,
(double)ost-data_size / 1024, ti1, bitrate, avg_bitrate);
+#if FF_API_CODED_FRAME
+FF_DISABLE_DEPRECATION_WARNINGS
 fprintf(vstats_file, type= %c\n, 

[libav-devel] [PATCH 09/15] qtrleenc: Keep coded_frame.key_frame a write-only variable

2015-07-15 Thread Vittorio Giovara
---
 libavcodec/qtrleenc.c | 22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/libavcodec/qtrleenc.c b/libavcodec/qtrleenc.c
index 7c98bea..fe1fafc 100644
--- a/libavcodec/qtrleenc.c
+++ b/libavcodec/qtrleenc.c
@@ -57,6 +57,9 @@ typedef struct QtrleEncContext {
  * Will contain at ith position the number of consecutive pixels equal to 
the previous
  * frame starting from pixel i */
 uint8_t* skip_table;
+
+/** Encoded frame is a key frame */
+int key_frame;
 } QtrleEncContext;
 
 static av_cold int qtrle_encode_end(AVCodecContext *avctx)
@@ -159,7 +162,7 @@ static void qtrle_encode_line(QtrleEncContext *s, const 
AVFrame *p, int line, ui
 
 for (i = width - 1; i = 0; i--) {
 
-if (!s-avctx-coded_frame-key_frame  !memcmp(this_line, prev_line, 
s-pixel_size))
+if (!s-key_frame  !memcmp(this_line, prev_line, s-pixel_size))
 skipcount = FFMIN(skipcount + 1, MAX_RLE_SKIP);
 else
 skipcount = 0;
@@ -263,7 +266,7 @@ static int encode_frame(QtrleEncContext *s, const AVFrame 
*p, uint8_t *buf)
 int end_line = s-avctx-height;
 uint8_t *orig_buf = buf;
 
-if (!s-avctx-coded_frame-key_frame) {
+if (!s-key_frame) {
 unsigned line_size = s-avctx-width * s-pixel_size;
 for (start_line = 0; start_line  s-avctx-height; start_line++)
 if (memcmp(p-data[0] + start_line*p-linesize[0],
@@ -301,7 +304,7 @@ static int qtrle_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
   const AVFrame *pict, int *got_packet)
 {
 QtrleEncContext * const s = avctx-priv_data;
-AVFrame * const p = avctx-coded_frame;
+enum AVPictureType pict_type;
 int ret;
 
 if ((ret = ff_alloc_packet(pkt, s-max_buf_size))  0) {
@@ -312,12 +315,12 @@ static int qtrle_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 
 if (avctx-gop_size == 0 || (s-avctx-frame_number % avctx-gop_size) == 
0) {
 /* I-Frame */
-p-pict_type = AV_PICTURE_TYPE_I;
-p-key_frame = 1;
+pict_type = AV_PICTURE_TYPE_I;
+s-key_frame = 1;
 } else {
 /* P-Frame */
-p-pict_type = AV_PICTURE_TYPE_P;
-p-key_frame = 0;
+pict_type = AV_PICTURE_TYPE_P;
+s-key_frame = 0;
 }
 
 pkt-size = encode_frame(s, pict, pkt-data);
@@ -326,7 +329,10 @@ static int qtrle_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 av_picture_copy(s-previous_frame, (const AVPicture *)pict,
 avctx-pix_fmt, avctx-width, avctx-height);
 
-if (p-key_frame)
+avctx-coded_frame-key_frame = s-key_frame;
+avctx-coded_frame-pict_type = s-pict_type;
+
+if (s-key_frame)
 pkt-flags |= AV_PKT_FLAG_KEY;
 *got_packet = 1;
 
-- 
1.9.5 (Apple Git-50.3)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 08/15] libtheoraenc: Keep coded_frame.key_frame a write-only variable

2015-07-15 Thread Vittorio Giovara
---
 libavcodec/libtheoraenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c
index 097336b..612a808 100644
--- a/libavcodec/libtheoraenc.c
+++ b/libavcodec/libtheoraenc.c
@@ -349,7 +349,7 @@ static int encode_frame(AVCodecContext* avc_context, 
AVPacket *pkt,
 // multithreaded (which will be disabled unless explicitly requested)
 pkt-pts = pkt-dts = frame-pts;
 avc_context-coded_frame-key_frame = !(o_packet.granulepos  
h-keyframe_mask);
-if (avc_context-coded_frame-key_frame)
+if (!(o_packet.granulepos  h-keyframe_mask))
 pkt-flags |= AV_PKT_FLAG_KEY;
 *got_packet = 1;
 
-- 
1.9.5 (Apple Git-50.3)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 00/15] coded_frame

2015-07-15 Thread Vittorio Giovara
This version of the set is just for review commodity, with all the amendment
requested (thanks Anton). 
Vittorio

Vittorio Giovara (15):
  mpegvideo_enc: Drop unnneded initialization
  roqvideoenc: Drop unneeded initialization
  a64multienc: Do not entangle coded_frame
  proresenc: Do not entangle coded_frame
  svq1enc: Do not entangle coded_frame
  libxvid: Do not entangle coded_frame
  libvpxenc: Do not entangle coded_frame
  libtheoraenc: Keep coded_frame.key_frame a write-only variable
  qtrleenc: Keep coded_frame.key_frame a write-only variable
  ffv1enc: Keep coded_frame.key_frame a write-only variable
  ffv1enc: Use input frame to set SAR and interlacing
  flashsvenc: Keep coded_frame.key_frame a write-only variable
  Gather all coded_frame allocations and free functions to a single
place
  Add a quality factor packet side data
  Deprecate avctx.coded_frame

 avconv.c| 32 ---
 avconv.h|  3 +++
 doc/APIchanges  |  3 +++
 libavcodec/a64multienc.c| 26 +++---
 libavcodec/alacenc.c|  7 --
 libavcodec/aliaspixenc.c| 20 -
 libavcodec/asvenc.c | 22 +-
 libavcodec/avcodec.h| 13 ++-
 libavcodec/bmpenc.c | 15 -
 libavcodec/cljrenc.c| 21 --
 libavcodec/dnxhdenc.c   | 25 +++--
 libavcodec/dpxenc.c | 15 -
 libavcodec/dvenc.c  | 15 -
 libavcodec/ffv1.h   |  1 +
 libavcodec/ffv1enc.c| 32 +++
 libavcodec/flashsvenc.c | 18 +++
 libavcodec/gif.c| 10 -
 libavcodec/huffyuvenc.c |  9 
 libavcodec/jpeglsenc.c  | 15 -
 libavcodec/lclenc.c | 10 -
 libavcodec/libopencore-amr.c|  1 -
 libavcodec/libopenjpegenc.c |  8 ---
 libavcodec/libschroedingerenc.c | 14 +---
 libavcodec/libspeexenc.c|  4 ++--
 libavcodec/libtheoraenc.c   | 12 +-
 libavcodec/libvpxenc.c  | 49 +++--
 libavcodec/libx264.c| 25 ++---
 libavcodec/libx265.c| 12 --
 libavcodec/libxavs.c| 28 ++-
 libavcodec/libxvid.c| 40 ++---
 libavcodec/ljpegenc.c   |  9 
 libavcodec/mpegvideo_enc.c  | 16 ++
 libavcodec/nvenc.c  | 10 -
 libavcodec/pamenc.c | 15 -
 libavcodec/pcm.c| 11 -
 libavcodec/pcxenc.c | 15 -
 libavcodec/pngenc.c | 15 -
 libavcodec/pnmenc.c | 18 ---
 libavcodec/proresenc.c  | 24 ++--
 libavcodec/pthread_frame.c  |  4 
 libavcodec/qsvenc.c | 10 -
 libavcodec/qtrleenc.c   | 34 ++--
 libavcodec/rawenc.c | 15 -
 libavcodec/roqvideoenc.c|  2 --
 libavcodec/sgienc.c | 15 -
 libavcodec/sunrastenc.c | 15 -
 libavcodec/svq1enc.c| 46 +++---
 libavcodec/svq1enc.h|  4 
 libavcodec/targaenc.c   | 15 -
 libavcodec/tiffenc.c| 15 -
 libavcodec/utils.c  | 24 ++--
 libavcodec/utvideoenc.c | 13 ---
 libavcodec/v210enc.c| 16 --
 libavcodec/v410enc.c| 19 
 libavcodec/version.h|  7 --
 libavcodec/xbmenc.c | 15 -
 libavcodec/xwdenc.c | 22 --
 libavcodec/zmbvenc.c| 12 --
 libavdevice/v4l2.c  |  8 +++
 libavformat/dump.c  |  3 +++
 60 files changed, 447 insertions(+), 505 deletions(-)

-- 
1.9.5 (Apple Git-50.3)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 11/15] ffv1enc: Use input frame to set SAR and interlacing

2015-07-15 Thread Vittorio Giovara
---
 libavcodec/ffv1enc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c
index ad52f15..28289fb 100644
--- a/libavcodec/ffv1enc.c
+++ b/libavcodec/ffv1enc.c
@@ -863,12 +863,12 @@ static void encode_slice_header(FFV1Context *f, 
FFV1Context *fs)
 put_symbol(c, state, f-plane[j].quant_table_index, 0);
 av_assert0(f-plane[j].quant_table_index == f-avctx-context_model);
 }
-if (!f-avctx-coded_frame-interlaced_frame)
+if (!f-frame-interlaced_frame)
 put_symbol(c, state, 3, 0);
 else
-put_symbol(c, state, 1 + !f-avctx-coded_frame-top_field_first, 0);
-put_symbol(c, state, f-avctx-coded_frame-sample_aspect_ratio.num, 0);
-put_symbol(c, state, f-avctx-coded_frame-sample_aspect_ratio.den, 0);
+put_symbol(c, state, 1 + !f-frame-top_field_first, 0);
+put_symbol(c, state, f-frame-sample_aspect_ratio.num, 0);
+put_symbol(c, state, f-frame-sample_aspect_ratio.den, 0);
 }
 
 static int encode_slice(AVCodecContext *c, void *arg)
-- 
1.9.5 (Apple Git-50.3)

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 14/15] Add a quality factor packet side data

2015-07-15 Thread Vittorio Giovara
This is necessary to preserve the quality information currently exported
with coded_frame. Add the new side data to every encoder that needs it,
and use it in avconv.

Signed-off-by: Vittorio Giovara vittorio.giov...@gmail.com
---
 avconv.c   | 13 ++---
 avconv.h   |  3 +++
 doc/APIchanges |  3 +++
 libavcodec/avcodec.h   |  7 +++
 libavcodec/dnxhdenc.c  |  7 ++-
 libavcodec/libx264.c   |  9 -
 libavcodec/libxavs.c   |  6 ++
 libavcodec/libxvid.c   |  6 ++
 libavcodec/mpegvideo_enc.c |  7 +++
 libavcodec/svq1enc.c   |  6 ++
 libavcodec/version.h   |  2 +-
 libavformat/dump.c |  3 +++
 12 files changed, 66 insertions(+), 6 deletions(-)

diff --git a/avconv.c b/avconv.c
index 5efa80d..b4654fc 100644
--- a/avconv.c
+++ b/avconv.c
@@ -335,6 +335,11 @@ static void write_frame(AVFormatContext *s, AVPacket *pkt, 
OutputStream *ost)
 }
 ost-frame_number++;
 }
+if (avctx-codec_type == AVMEDIA_TYPE_VIDEO) {
+uint8_t *sd = av_packet_get_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR,
+  NULL);
+ost-quality = sd ? *(int *)sd : -1;
+}
 
 while (bsfc) {
 AVPacket new_pkt = *pkt;
@@ -622,7 +627,8 @@ static void do_video_stats(OutputStream *ost, int 
frame_size)
 enc = ost-enc_ctx;
 if (enc-codec_type == AVMEDIA_TYPE_VIDEO) {
 frame_number = ost-frame_number;
-fprintf(vstats_file, frame= %5d q= %2.1f , frame_number, 
enc-coded_frame-quality / (float)FF_QP2LAMBDA);
+fprintf(vstats_file, frame= %5d q= %2.1f , frame_number,
+ost-quality / (float)FF_QP2LAMBDA);
 if (enc-flagsCODEC_FLAG_PSNR)
 fprintf(vstats_file, PSNR= %6.2f , 
psnr(enc-coded_frame-error[0] / (enc-width * enc-height * 255.0 * 255.0)));
 
@@ -907,8 +913,9 @@ static void print_report(int is_last_report, int64_t 
timer_start)
 float q = -1;
 ost = output_streams[i];
 enc = ost-enc_ctx;
-if (!ost-stream_copy  enc-coded_frame)
-q = enc-coded_frame-quality / (float)FF_QP2LAMBDA;
+if (!ost-stream_copy)
+q = ost-quality / (float) FF_QP2LAMBDA;
+
 if (vid  enc-codec_type == AVMEDIA_TYPE_VIDEO) {
 snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), q=%2.1f , 
q);
 }
diff --git a/avconv.h b/avconv.h
index 5fddf98..0d6f293 100644
--- a/avconv.h
+++ b/avconv.h
@@ -361,6 +361,9 @@ typedef struct OutputStream {
 // number of frames/samples sent to the encoder
 uint64_t frames_encoded;
 uint64_t samples_encoded;
+
+/* packet quality factor */
+int quality;
 } OutputStream;
 
 typedef struct OutputFile {
diff --git a/doc/APIchanges b/doc/APIchanges
index a2c5eb05..c803f71 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2014-08-09
 
 API changes, most recent first:
 
+2015-xx-xx - xxx - lavc 56.33.0 - avcodec.h
+  Add AV_PKT_DATA_QUALITY_FACTOR to export the quality value of an AVPacket.
+
 2015-xx-xx - xxx - lavu 56.15.0
   Add av_version_info().
 
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index e8be196..db077e9 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -930,6 +930,13 @@ enum AVPacketSideDataType {
  * to enum AVAudioServiceType.
  */
 AV_PKT_DATA_AUDIO_SERVICE_TYPE,
+
+/**
+ * This side data contains an integer value representing the quality
+ * factor of the compressed frame. Allowed range is between 1 (good)
+ * and FF_LAMBDA_MAX (bad).
+ */
+AV_PKT_DATA_QUALITY_FACTOR,
 };
 
 typedef struct AVPacketSideData {
diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c
index 5c45fe0..bccf5c8 100644
--- a/libavcodec/dnxhdenc.c
+++ b/libavcodec/dnxhdenc.c
@@ -1036,7 +1036,7 @@ static int dnxhd_encode_picture(AVCodecContext *avctx, 
AVPacket *pkt,
 DNXHDEncContext *ctx = avctx-priv_data;
 int first_field = 1;
 int offset, i, ret;
-uint8_t *buf;
+uint8_t *buf, *sd;
 
 if ((ret = ff_alloc_packet(pkt, ctx-cid_table-frame_size))  0) {
 av_log(avctx, AV_LOG_ERROR,
@@ -1092,6 +1092,11 @@ encode_coding_unit:
 
 avctx-coded_frame-quality = ctx-qscale * FF_QP2LAMBDA;
 
+sd = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR, sizeof(int));
+if (!sd)
+return AVERROR(ENOMEM);
+*(int *)sd = ctx-qscale * FF_QP2LAMBDA;
+
 pkt-flags |= AV_PKT_FLAG_KEY;
 *got_packet = 1;
 return 0;
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 6b31616..8972c8a 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -268,8 +268,15 @@ static int X264_frame(AVCodecContext *ctx, AVPacket *pkt, 
const AVFrame *frame,
 }
 
 pkt-flags |= AV_PKT_FLAG_KEY*pic_out.b_keyframe;
-if (ret)
+if (ret) {
+uint8_t *sd = av_packet_new_side_data(pkt, AV_PKT_DATA_QUALITY_FACTOR,
+   

[libav-devel] [PATCH 1/2] x86: bswapdsp: Don't treat 32-bit integers as 64-bit

2015-07-15 Thread Henrik Gramner
The upper halves are not guaranteed to be zero in x86-64.

Also use `test` instead of `and` when the result isn't used for anything other
than as a branch condition, this allows some register moves to be eliminated.
---
 libavcodec/x86/bswapdsp.asm | 23 ++-
 1 file changed, 10 insertions(+), 13 deletions(-)

diff --git a/libavcodec/x86/bswapdsp.asm b/libavcodec/x86/bswapdsp.asm
index 17a6cb1..42580a3 100644
--- a/libavcodec/x86/bswapdsp.asm
+++ b/libavcodec/x86/bswapdsp.asm
@@ -28,8 +28,8 @@ SECTION_TEXT
 
 ; %1 = aligned/unaligned
 %macro BSWAP_LOOPS  1
-mov  r3, r2
-sar  r2, 3
+mov  r3d, r2d
+sar  r2d, 3
 jz   .left4_%1
 .loop8_%1:
 mov%1m0, [r1 +  0]
@@ -57,11 +57,11 @@ SECTION_TEXT
 %endif
 add  r0, 32
 add  r1, 32
-dec  r2
+dec  r2d
 jnz  .loop8_%1
 .left4_%1:
-mov  r2, r3
-and  r3, 4
+mov  r2d, r3d
+test r3d, 4
 jz   .left
 mov%1m0, [r1]
 %if cpuflag(ssse3)
@@ -84,13 +84,11 @@ SECTION_TEXT
 %macro BSWAP32_BUF 0
 %if cpuflag(ssse3)
 cglobal bswap32_buf, 3,4,3
-mov  r3, r1
 mova m2, [pb_bswap32]
 %else
 cglobal bswap32_buf, 3,4,5
-mov  r3, r1
 %endif
-and  r3, 15
+test r1, 15
 jz   .start_align
 BSWAP_LOOPS  u
 jmp  .left
@@ -98,8 +96,7 @@ cglobal bswap32_buf, 3,4,5
 BSWAP_LOOPS  a
 .left:
 %if cpuflag(ssse3)
-mov  r3, r2
-and  r2, 2
+test r2d, 2
 jz   .left1
 movq m0, [r1]
 pshufb   m0, m2
@@ -107,13 +104,13 @@ cglobal bswap32_buf, 3,4,5
 add  r1, 8
 add  r0, 8
 .left1:
-and  r3, 1
+test r2d, 1
 jz   .end
 mov  r2d, [r1]
 bswapr2d
 mov  [r0], r2d
 %else
-and  r2, 3
+and  r2d, 3
 jz   .end
 .loop2:
 mov  r3d, [r1]
@@ -121,7 +118,7 @@ cglobal bswap32_buf, 3,4,5
 mov  [r0], r3d
 add  r1, 4
 add  r0, 4
-dec  r2
+dec  r2d
 jnz  .loop2
 %endif
 .end:
-- 
1.8.3.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


[libav-devel] [PATCH 2/2] checkasm: add unit tests for bswapdsp

2015-07-15 Thread Henrik Gramner
---
 tests/checkasm/Makefile   |  1 +
 tests/checkasm/bswapdsp.c | 73 +++
 tests/checkasm/checkasm.c |  3 ++
 tests/checkasm/checkasm.h |  1 +
 4 files changed, 78 insertions(+)
 create mode 100644 tests/checkasm/bswapdsp.c

diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile
index 0758746..483ad13 100644
--- a/tests/checkasm/Makefile
+++ b/tests/checkasm/Makefile
@@ -1,4 +1,5 @@
 # libavcodec tests
+AVCODECOBJS-$(CONFIG_BSWAPDSP) += bswapdsp.o
 AVCODECOBJS-$(CONFIG_H264PRED) += h264pred.o
 AVCODECOBJS-$(CONFIG_H264QPEL) += h264qpel.o
 
diff --git a/tests/checkasm/bswapdsp.c b/tests/checkasm/bswapdsp.c
new file mode 100644
index 000..7b1566b
--- /dev/null
+++ b/tests/checkasm/bswapdsp.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2015 Henrik Gramner
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Libav 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with Libav; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include string.h
+#include checkasm.h
+#include libavcodec/bswapdsp.h
+#include libavutil/common.h
+#include libavutil/intreadwrite.h
+
+#define BUF_SIZE 512
+
+#define randomize_buffers()\
+do {\
+int i;\
+for (i = 0; i  BUF_SIZE; i += 4) {\
+uint32_t r = rnd();\
+AV_WN32A(src0+i, r);\
+AV_WN32A(src1+i, r);\
+r = rnd();\
+AV_WN32A(dst0+i, r);\
+AV_WN32A(dst1+i, r);\
+}\
+} while (0)
+
+#define check_bswap(type)\
+do {\
+int w;\
+for (w = 0; w  BUF_SIZE/sizeof(type); w++) {\
+int offset = (BUF_SIZE/sizeof(type) - w)  15; /* Test various 
alignments */\
+randomize_buffers();\
+call_ref((type*)dst0+offset, (type*)src0+offset, w);\
+call_new((type*)dst1+offset, (type*)src1+offset, w);\
+if (memcmp(src0, src1, BUF_SIZE) || memcmp(dst0, dst1, BUF_SIZE))\
+fail();\
+bench_new((type*)dst1+offset, (type*)src1+offset, w);\
+}\
+} while (0)
+
+void checkasm_check_bswapdsp(void)
+{
+DECLARE_ALIGNED(16, uint8_t, src0)[BUF_SIZE];
+DECLARE_ALIGNED(16, uint8_t, src1)[BUF_SIZE];
+DECLARE_ALIGNED(16, uint8_t, dst0)[BUF_SIZE];
+DECLARE_ALIGNED(16, uint8_t, dst1)[BUF_SIZE];
+BswapDSPContext h;
+
+ff_bswapdsp_init(h);
+
+if (check_func(h.bswap_buf, bswap_buf))
+check_bswap(uint32_t);
+
+if (check_func(h.bswap16_buf, bswap16_buf))
+check_bswap(uint16_t);
+
+report(bswap);
+}
diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c
index 7b1ea8f..ce73778 100644
--- a/tests/checkasm/checkasm.c
+++ b/tests/checkasm/checkasm.c
@@ -54,6 +54,9 @@
 
 /* List of tests to invoke */
 static void (* const tests[])(void) = {
+#if CONFIG_BSWAPDSP
+checkasm_check_bswapdsp,
+#endif
 #if CONFIG_H264PRED
 checkasm_check_h264pred,
 #endif
diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h
index 1a46e9b..c2e359f 100644
--- a/tests/checkasm/checkasm.h
+++ b/tests/checkasm/checkasm.h
@@ -29,6 +29,7 @@
 #include libavutil/lfg.h
 #include libavutil/timer.h
 
+void checkasm_check_bswapdsp(void);
 void checkasm_check_h264pred(void);
 void checkasm_check_h264qpel(void);
 
-- 
1.8.3.2

___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] hevc: Split the struct setup from the pps parsing

2015-07-15 Thread James Almer
On 14/07/15 7:36 AM, Luca Barbato wrote:
 ---
 
 Properly rebased version
 
  libavcodec/hevc_ps.c | 258 
 ++-
  1 file changed, 131 insertions(+), 127 deletions(-)
 
 diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
 index a5a2ace..2112265 100644
 --- a/libavcodec/hevc_ps.c
 +++ b/libavcodec/hevc_ps.c
 @@ -1039,14 +1039,139 @@ static void hevc_pps_free(void *opaque, uint8_t 
 *data)
  av_freep(pps);
  }
 
 +static int setup_pps(AVCodecContext *avctx, GetBitContext *gb,

If this is done only for readability's sake and not because this function will 
be
used somewhere else, then making sure the compiler always inlines this function 
may
be a good idea.

 + HEVCPPS *pps, HEVCSPS *sps)
 +{
 +int log2_diff;
 +int pic_area_in_ctbs, pic_area_in_min_tbs;
 +int i, j, x, y, ctb_addr_rs, tile_id;
 +
 +// Inferred parameters
 +pps-col_bd   = av_malloc_array(pps-num_tile_columns + 1, 
 sizeof(*pps-col_bd));
 +pps-row_bd   = av_malloc_array(pps-num_tile_rows + 1,
 sizeof(*pps-row_bd));
 +pps-col_idxX = av_malloc_array(sps-ctb_width,
 sizeof(*pps-col_idxX));
 +if (!pps-col_bd || !pps-row_bd || !pps-col_idxX)
 +return AVERROR(ENOMEM);
 +
 +if (pps-uniform_spacing_flag) {
 +if (!pps-column_width) {
 +pps-column_width = av_malloc_array(pps-num_tile_columns, 
 sizeof(*pps-column_width));
 +pps-row_height   = av_malloc_array(pps-num_tile_rows,
 sizeof(*pps-row_height));
 +}
 +if (!pps-column_width || !pps-row_height)
 +return AVERROR(ENOMEM);
 +
 +for (i = 0; i  pps-num_tile_columns; i++) {
 +pps-column_width[i] = ((i + 1) * sps-ctb_width) / 
 pps-num_tile_columns -
 +   (i * sps-ctb_width) / 
 pps-num_tile_columns;
 +}
 +
 +for (i = 0; i  pps-num_tile_rows; i++) {
 +pps-row_height[i] = ((i + 1) * sps-ctb_height) / 
 pps-num_tile_rows -
 + (i * sps-ctb_height) / pps-num_tile_rows;
 +}
 +}
 +
 +pps-col_bd[0] = 0;
 +for (i = 0; i  pps-num_tile_columns; i++)
 +pps-col_bd[i + 1] = pps-col_bd[i] + pps-column_width[i];
 +
 +pps-row_bd[0] = 0;
 +for (i = 0; i  pps-num_tile_rows; i++)
 +pps-row_bd[i + 1] = pps-row_bd[i] + pps-row_height[i];
 +
 +for (i = 0, j = 0; i  sps-ctb_width; i++) {
 +if (i  pps-col_bd[j])
 +j++;
 +pps-col_idxX[i] = j;
 +}
 +
 +/**
 + * 6.5
 + */
 +pic_area_in_ctbs = sps-ctb_width* sps-ctb_height;
 +pic_area_in_min_tbs  = sps-min_tb_width * sps-min_tb_height;
 +
 +pps-ctb_addr_rs_to_ts = av_malloc_array(pic_area_in_ctbs,
 sizeof(*pps-ctb_addr_rs_to_ts));
 +pps-ctb_addr_ts_to_rs = av_malloc_array(pic_area_in_ctbs,
 sizeof(*pps-ctb_addr_ts_to_rs));
 +pps-tile_id   = av_malloc_array(pic_area_in_ctbs,
 sizeof(*pps-tile_id));
 +pps-min_tb_addr_zs= av_malloc_array(pic_area_in_min_tbs, 
 sizeof(*pps-min_tb_addr_zs));
 +if (!pps-ctb_addr_rs_to_ts || !pps-ctb_addr_ts_to_rs ||
 +!pps-tile_id || !pps-min_tb_addr_zs) {
 +return AVERROR(ENOMEM);
 +}
 +
 +for (ctb_addr_rs = 0; ctb_addr_rs  pic_area_in_ctbs; ctb_addr_rs++) {
 +int tb_x   = ctb_addr_rs % sps-ctb_width;
 +int tb_y   = ctb_addr_rs / sps-ctb_width;
 +int tile_x = 0;
 +int tile_y = 0;
 +int val= 0;
 +
 +for (i = 0; i  pps-num_tile_columns; i++) {
 +if (tb_x  pps-col_bd[i + 1]) {
 +tile_x = i;
 +break;
 +}
 +}
 +
 +for (i = 0; i  pps-num_tile_rows; i++) {
 +if (tb_y  pps-row_bd[i + 1]) {
 +tile_y = i;
 +break;
 +}
 +}
 +
 +for (i = 0; i  tile_x; i++)
 +val += pps-row_height[tile_y] * pps-column_width[i];
 +for (i = 0; i  tile_y; i++)
 +val += sps-ctb_width * pps-row_height[i];
 +
 +val += (tb_y - pps-row_bd[tile_y]) * pps-column_width[tile_x] +
 +   tb_x - pps-col_bd[tile_x];
 +
 +pps-ctb_addr_rs_to_ts[ctb_addr_rs] = val;
 +pps-ctb_addr_ts_to_rs[val] = ctb_addr_rs;
 +}
 +
 +for (j = 0, tile_id = 0; j  pps-num_tile_rows; j++)
 +for (i = 0; i  pps-num_tile_columns; i++, tile_id++)
 +for (y = pps-row_bd[j]; y  pps-row_bd[j + 1]; y++)
 +for (x = pps-col_bd[i]; x  pps-col_bd[i + 1]; x++)
 +pps-tile_id[pps-ctb_addr_rs_to_ts[y * sps-ctb_width + 
 x]] = tile_id;
 +
 +pps-tile_pos_rs = av_malloc_array(tile_id, sizeof(*pps-tile_pos_rs));
 +if (!pps-tile_pos_rs)
 +return AVERROR(ENOMEM);
 +
 +for (j = 0; j  pps-num_tile_rows; j++)
 +for (i = 0; i  pps-num_tile_columns; i++)
 +pps-tile_pos_rs[j * pps-num_tile_columns + i] =
 +