Re: [libav-devel] [PATCH 05/12] h264: Replace mpegvideo-specific MAX_PICTURE_COUNT by private define

2014-03-05 Thread Anton Khirnov

On Tue,  4 Mar 2014 19:24:35 +0100, Vittorio Giovara 
vittorio.giov...@gmail.com wrote:
 ---
  libavcodec/h264.c| 22 +++---
  libavcodec/h264.h|  2 ++
  libavcodec/h264_ps.c |  2 +-
  3 files changed, 14 insertions(+), 12 deletions(-)
 
 diff --git a/libavcodec/h264.c b/libavcodec/h264.c
 index e6011b5..536ec47 100644
 --- a/libavcodec/h264.c
 +++ b/libavcodec/h264.c
 @@ -279,7 +279,7 @@ static void release_unused_pictures(H264Context *h, int 
 remove_current)
  int i;
  
  /* release non reference frames */
 -for (i = 0; i  MAX_PICTURE_COUNT; i++) {
 +for (i = 0; i  H264_MAX_PICTURE_COUNT; i++) {

Seems to me in most(all?) those cases FF_ARRAY_ELEMS(h-DPB) would be even more
appropriate.

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


Re: [libav-devel] [PATCH 2/8] resample: fix avresample_get_delay() return value

2014-03-05 Thread Luca Barbato
On 05/03/14 07:50, Anton Khirnov wrote:
 The correct next input sample is not the first sample of the
 resampling buffer, but the center sample of the filter_length-sized
 block at the beginning.

Ok.

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


Re: [libav-devel] [PATCH 3/8] resample: split the nearest neighbour path into a separate function pointer

2014-03-05 Thread Luca Barbato
On 05/03/14 07:50, Anton Khirnov wrote:
 ---
  libavresample/resample.c  |   26 ++
  libavresample/resample_template.c |   13 -
  2 files changed, 26 insertions(+), 13 deletions(-)

stray space aside looks ok.

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


Re: [libav-devel] [PATCH 4/8] resample: reindent

2014-03-05 Thread Luca Barbato
On 05/03/14 07:50, Anton Khirnov wrote:
 ---
  libavresample/resample_template.c |   41 
 ++---
  1 file changed, 20 insertions(+), 21 deletions(-)
 

Probably could be folded with the previous.

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


[libav-devel] [PATCH] avfilter: Add missing emms_c when needed

2014-03-05 Thread Luca Barbato
Arch specific calls should have an emms_c following to keep the cpu
state consistent.

Reported-By: wm4
CC: libav-sta...@libav.org
---
 libavfilter/af_volume.c  | 1 +
 libavfilter/vf_gradfun.c | 1 +
 libavfilter/vf_hqdn3d.c  | 1 +
 3 files changed, 3 insertions(+)

diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
index 12d496e..2cdfe23 100644
--- a/libavfilter/af_volume.c
+++ b/libavfilter/af_volume.c
@@ -262,6 +262,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
 vol-scale_samples(out_buf-extended_data[p],
buf-extended_data[p], plane_samples,
vol-volume_i);
+emms_c();
 }
 } else if (av_get_packed_sample_fmt(vol-sample_fmt) == 
AV_SAMPLE_FMT_FLT) {
 for (p = 0; p  vol-planes; p++) {
diff --git a/libavfilter/vf_gradfun.c b/libavfilter/vf_gradfun.c
index 79f6790..f7c4372 100644
--- a/libavfilter/vf_gradfun.c
+++ b/libavfilter/vf_gradfun.c
@@ -118,6 +118,7 @@ static void filter(GradFunContext *ctx, uint8_t *dst, 
uint8_t *src, int width, i
 ctx-filter_line(dst + y * dst_linesize, src + y * src_linesize, dc - 
r / 2, width, thresh, dither[y  7]);
 if (++y = height) break;
 }
+emms_c();
 }
 
 static av_cold int init(AVFilterContext *ctx)
diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c
index cd9f0d2..be6b761 100644
--- a/libavfilter/vf_hqdn3d.c
+++ b/libavfilter/vf_hqdn3d.c
@@ -147,6 +147,7 @@ static void denoise_depth(HQDN3DContext *s,
 else
 denoise_temporal(src, dst, frame_ant,
  w, h, sstride, dstride, temporal, depth);
+emms_c();
 }
 
 #define denoise(...) \
-- 
1.8.5.1

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


Re: [libav-devel] [PATCH] avfilter: Add missing emms_c when needed

2014-03-05 Thread Kostya Shishkov
On Wed, Mar 05, 2014 at 10:43:24AM +0100, Luca Barbato wrote:
 Arch specific calls should have an emms_c following to keep the cpu
 state consistent.
 
 Reported-By: wm4
 CC: libav-sta...@libav.org
 ---
  libavfilter/af_volume.c  | 1 +
  libavfilter/vf_gradfun.c | 1 +
  libavfilter/vf_hqdn3d.c  | 1 +
  3 files changed, 3 insertions(+)
 
 diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
 index 12d496e..2cdfe23 100644
 --- a/libavfilter/af_volume.c
 +++ b/libavfilter/af_volume.c
 @@ -262,6 +262,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
 *buf)
  vol-scale_samples(out_buf-extended_data[p],
 buf-extended_data[p], plane_samples,
 vol-volume_i);
 +emms_c();
  }
  } else if (av_get_packed_sample_fmt(vol-sample_fmt) == 
 AV_SAMPLE_FMT_FLT) {
  for (p = 0; p  vol-planes; p++) {

should be at the end of the function (there are fdsp.vector_fmul_scalar()
calls below too)

 diff --git a/libavfilter/vf_gradfun.c b/libavfilter/vf_gradfun.c
 index 79f6790..f7c4372 100644
 --- a/libavfilter/vf_gradfun.c
 +++ b/libavfilter/vf_gradfun.c
 @@ -118,6 +118,7 @@ static void filter(GradFunContext *ctx, uint8_t *dst, 
 uint8_t *src, int width, i
  ctx-filter_line(dst + y * dst_linesize, src + y * src_linesize, dc 
 - r / 2, width, thresh, dither[y  7]);
  if (++y = height) break;
  }
 +emms_c();
  }
  
  static av_cold int init(AVFilterContext *ctx)
 diff --git a/libavfilter/vf_hqdn3d.c b/libavfilter/vf_hqdn3d.c
 index cd9f0d2..be6b761 100644
 --- a/libavfilter/vf_hqdn3d.c
 +++ b/libavfilter/vf_hqdn3d.c
 @@ -147,6 +147,7 @@ static void denoise_depth(HQDN3DContext *s,
  else
  denoise_temporal(src, dst, frame_ant,
   w, h, sstride, dstride, temporal, depth);
 +emms_c();
  }
  
  #define denoise(...) \
 -- 

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


[libav-devel] [PATCH 1/1] arm: hpeldsp: prevent overreads in armv6 asm

2014-03-05 Thread Janne Grunau
Based on a patch by Russel King rmk+li...@arm.linux.org.uk

Bug-Id: 646
CC: libav-sta...@libav.org
---
 libavcodec/arm/hpeldsp_armv6.S | 20 
 libavutil/arm/asm.S|  7 +++
 2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/libavcodec/arm/hpeldsp_armv6.S b/libavcodec/arm/hpeldsp_armv6.S
index f85c8cb..984e0f0 100644
--- a/libavcodec/arm/hpeldsp_armv6.S
+++ b/libavcodec/arm/hpeldsp_armv6.S
@@ -132,11 +132,12 @@ function ff_put_pixels8_y2_armv6, export=1
 uhadd8  r9,  r5,  r7
 eor r11, r5,  r7
 and r10, r10, r12
-ldr_pre r4,  r1,  r2
+ldrc_prene,  r4,  r1,  r2
 uadd8   r8,  r8,  r10
 and r11, r11, r12
 uadd8   r9,  r9,  r11
-ldr r5,  [r1, #4]
+it  ne
+ldrne   r5,  [r1, #4]
 uhadd8  r10, r4,  r6
 eor r6,  r4,  r6
 uhadd8  r11, r5,  r7
@@ -144,10 +145,11 @@ function ff_put_pixels8_y2_armv6, export=1
 eor r7,  r5,  r7
 uadd8   r10, r10, r6
 and r7,  r7,  r12
-ldr_pre r6,  r1,  r2
+ldrc_prene,  r6,  r1,  r2
 uadd8   r11, r11, r7
 strd_post   r8,  r9,  r0,  r2
-ldr r7,  [r1, #4]
+it  ne
+ldrne   r7,  [r1, #4]
 strd_post   r10, r11, r0,  r2
 bne 1b
 
@@ -192,13 +194,15 @@ function ff_put_pixels8_y2_no_rnd_armv6, export=1
 1:
 subsr3,  r3,  #2
 uhadd8  r8,  r4,  r6
-ldr_pre r4,  r1,  r2
+ldrc_prene,  r4,  r1,  r2
 uhadd8  r9,  r5,  r7
-ldr r5,  [r1, #4]
+it  ne
+ldrne   r5,  [r1, #4]
 uhadd8  r12, r4,  r6
-ldr_pre r6,  r1,  r2
+ldrc_prene,  r6,  r1,  r2
 uhadd8  r14, r5,  r7
-ldr r7,  [r1, #4]
+it  ne
+ldrne   r7,  [r1, #4]
 stm r0,  {r8,r9}
 add r0,  r0,  r2
 stm r0,  {r12,r14}
diff --git a/libavutil/arm/asm.S b/libavutil/arm/asm.S
index 45fdf55..5884e17 100644
--- a/libavutil/arm/asm.S
+++ b/libavutil/arm/asm.S
@@ -216,6 +216,13 @@ T   ldr \rt, [\rn]
 T   add \rn, \rn, \rm
 .endm
 
+.macro  ldrc_precc,  rt,  rn,  rm:vararg
+A   ldr\cc  \rt, [\rn, \rm]!
+T   itt \cc
+T   add\cc  \rn, \rn, \rm
+T   ldr\cc  \rt, [\rn]
+.endm
+
 .macro  ldrd_regrt,  rt2, rn,  rm
 A   ldrd\rt, \rt2, [\rn, \rm]
 T   add \rt, \rn, \rm
-- 
1.9.0

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


Re: [libav-devel] [PATCH 1/1] arm: hpeldsp: prevent overreads in armv6 asm

2014-03-05 Thread Martin Storsjö

On Wed, 5 Mar 2014, Janne Grunau wrote:


Based on a patch by Russel King rmk+li...@arm.linux.org.uk

Bug-Id: 646
CC: libav-sta...@libav.org
---
libavcodec/arm/hpeldsp_armv6.S | 20 
libavutil/arm/asm.S|  7 +++
2 files changed, 19 insertions(+), 8 deletions(-)


LGTM

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


Re: [libav-devel] [PATCH 1/2] vda: Use the current hwaccel1 layout

2014-03-05 Thread Diego Biurrun
On Wed, Mar 05, 2014 at 01:29:59AM +0100, Luca Barbato wrote:
 --- a/libavcodec/vda.h
 +++ b/libavcodec/vda.h
 @@ -125,15 +129,119 @@ struct vda_context {
 +#if 0

?

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


Re: [libav-devel] [PATCH 1/2] vda: Use the current hwaccel1 layout

2014-03-05 Thread Luca Barbato
On 05/03/14 13:48, Diego Biurrun wrote:
 On Wed, Mar 05, 2014 at 01:29:59AM +0100, Luca Barbato wrote:
 --- a/libavcodec/vda.h
 +++ b/libavcodec/vda.h
 @@ -125,15 +129,119 @@ struct vda_context {
 +#if 0
 
 ?
 
 Diego

I couldn't find a better place to put the example functions and if the
get_buffer override is working and acceptable I wouldn't go this route.

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


[libav-devel] [PATCH] af_channelmap: fix ONE_STR mapping mode

2014-03-05 Thread Anton Khirnov
get_channel() returns 0 on success

CC:libav-sta...@libav.org
---
Indeed, good catch
---
 libavfilter/af_channelmap.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/af_channelmap.c b/libavfilter/af_channelmap.c
index 71d51e7..3e5cc3d 100644
--- a/libavfilter/af_channelmap.c
+++ b/libavfilter/af_channelmap.c
@@ -188,7 +188,7 @@ static av_cold int channelmap_init(AVFilterContext *ctx)
 s-map[i].out_channel_idx = i;
 break;
 case MAP_ONE_STR:
-if (!get_channel(mapping, in_ch, separator)) {
+if (get_channel(mapping, in_ch, separator)  0) {
 av_log(ctx, AV_LOG_ERROR, err);
 return AVERROR(EINVAL);
 }
-- 
1.7.10.4

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


Re: [libav-devel] [PATCH 1/1] avcodec: guarantee one addtional picture line

2014-03-05 Thread Anton Khirnov

On Tue,  4 Mar 2014 13:01:51 +0100, Janne Grunau janne-li...@jannau.net wrote:
 Various optimized DSP functions read one line past the aligned picture.
 Several ARMv6 put_pixels functions in HpelDSPContext load the input of
 the next line while processing the current one. Explicitly allow this
 for all codecs and not just H264.
 
 Bug-Id: 646
 CC: libav-sta...@libav.org
 ---
  libavcodec/utils.c | 9 ++---
  1 file changed, 6 insertions(+), 3 deletions(-)
 
 diff --git a/libavcodec/utils.c b/libavcodec/utils.c
 index c88b346..a1de113 100644
 --- a/libavcodec/utils.c
 +++ b/libavcodec/utils.c
 @@ -265,9 +265,12 @@ void avcodec_align_dimensions2(AVCodecContext *s, int 
 *width, int *height,
  
  *width  = FFALIGN(*width, w_align);
  *height = FFALIGN(*height, h_align);
 -if (s-codec_id == AV_CODEC_ID_H264)
 -// some of the optimized chroma MC reads one line too much
 -*height += 2;
 +
 +/* Some optimized dsp functions read one line too much (H264 chroma mc,
 + * ARM put_pixels functions, ...). Always add two lines so that 
 subsampled
 + * chroma has also one additional line.
 + */
 +*height += 2;
  
  for (i = 0; i  4; i++)
  linesize_align[i] = STRIDE_ALIGN;
 -- 
 1.9.0
 

If you think it is still needed, I'm ok with this.

It can hide bugs though.

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


[libav-devel] [PATCH] x86: dcadsp: Fix linking with yasm and optimizations disabled

2014-03-05 Thread Diego Biurrun
Some optimized functions reference optimized symbols, so the functions
must be explicitly disabled when those symbols are unavailable.
---

Now with a more general #if, as suggested by James.

 libavcodec/x86/dcadsp_init.c |4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/x86/dcadsp_init.c b/libavcodec/x86/dcadsp_init.c
index 3821892..65e3db5 100644
--- a/libavcodec/x86/dcadsp_init.c
+++ b/libavcodec/x86/dcadsp_init.c
@@ -60,6 +60,7 @@ void ff_synth_filter_inner_sse2(float *synth_buf_ptr, float 
synth_buf2[32],
 const float window[512],
 float out[32], intptr_t offset, float scale);
 
+#if HAVE_YASM
 static void synth_filter_sse2(FFTContext *imdct,
   float *synth_buf_ptr, int *synth_buf_offset,
   float synth_buf2[32], const float window[512],
@@ -74,12 +75,15 @@ static void synth_filter_sse2(FFTContext *imdct,
 
 *synth_buf_offset = (*synth_buf_offset - 32)  511;
 }
+#endif /* HAVE_YASM */
 
 av_cold void ff_synth_filter_init_x86(SynthFilterContext *s)
 {
+#if HAVE_YASM
 int cpu_flags = av_get_cpu_flags();
 
 if (EXTERNAL_SSE2(cpu_flags)) {
 s-synth_filter_float = synth_filter_sse2;
 }
+#endif /* HAVE_YASM */
 }
-- 
1.7.9.5

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


Re: [libav-devel] [RFC] exporting replaygain and other similar metadata

2014-03-05 Thread Anton Khirnov

On Wed, 26 Feb 2014 01:49:14 +0100, Vittorio Giovara 
vittorio.giov...@gmail.com wrote:
 On Tue, Feb 25, 2014 at 11:32 AM, Kostya Shishkov
 kostya.shish...@gmail.com wrote:
  On Tue, Feb 25, 2014 at 11:27:09AM +0100, Anton Khirnov wrote:
 
  On Thu, 20 Feb 2014 00:13:35 +0100, Vittorio Giovara 
  vittorio.giov...@gmail.com wrote:
  
   Is it worthwhile to reuse some of the showinfo functions in the avconv
   output too?
 
  ???
  In what form
 
  Stream #0.1(cz): Audio: ac3, 48000 Hz, 5.1, fltp, 448 kb/s (default)
  Metadata:
title   : AC3 Audio
  Side data:
replaygain  : 1 0 1 0
 
 
 Exactly!
 Maybe each side data file could have its own av_side_data_dumper
 function that prints the relevant information or just prepares the
 strings.
 So, in (for example) stereo3d.c there would be a av_stereo3d_dump
 function (or similar) that vf_showinfo and avconv (and possibly users)
 might call.
 In this way the functions would be closer to the original source of
 side data and more easily found when adding new values or modifying
 old ones.

I do not believe this is such a great idea, the printing format ends up
specifically tailored to just one caller. avconv/showinfo are better places for
this IMO

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


Re: [libav-devel] [PATCH 1/8] FATE: add tests for more resampling modes

2014-03-05 Thread Diego Biurrun
On Wed, Mar 05, 2014 at 07:50:52AM +0100, Anton Khirnov wrote:
 ---
  tests/fate/libavresample.mak |   14 ++
  1 file changed, 14 insertions(+)

LGTM

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


Re: [libav-devel] [PATCH] avfilter: Add missing emms_c when needed

2014-03-05 Thread Justin Ruggles
On 03/05/2014 04:43 AM, Luca Barbato wrote:
 diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
 index 12d496e..2cdfe23 100644
 --- a/libavfilter/af_volume.c
 +++ b/libavfilter/af_volume.c
 @@ -262,6 +262,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
 *buf)
  vol-scale_samples(out_buf-extended_data[p],
 buf-extended_data[p], plane_samples,
 vol-volume_i);
 +emms_c();
  }
  } else if (av_get_packed_sample_fmt(vol-sample_fmt) == 
 AV_SAMPLE_FMT_FLT) {
  for (p = 0; p  vol-planes; p++) {

Neither of the dsp functions used in af_volume utilize MMX registers.
Adding emms_c() is completely pointless.

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


Re: [libav-devel] [PATCH] avformat/rtmppkt: handle extended timestamp field even for one-byte header

2014-03-05 Thread Martin Storsjö

Hi Martin,

Thanks for your patch! It looks mostly good - I've added a few comments 
below. I'll split up your patch in a few smaller patches and resend it to 
libav-devel@libav.org (and to you so you can verify, I can't test it 
myself).


On Wed, 5 Mar 2014, Martin Panter wrote:


From 0a1e2beac5b276f74622ab33fe5245e831de516d Mon Sep 17 00:00:00 2001
From: Martin Panter vadmium à gmail·com


I hope you're ok with changing this to the proper address with @ and . - 
we don't use obfuscated email addresses in the git history in libav, and 
spam shouldn't be an issue with gmail anyway.



Date: Wed, 5 Mar 2014 04:04:39 +
Subject: [PATCH] avformat/rtmppkt: handle extended timestamp field even for
one-byte header

Related fix in rtmpdump:
https://repo.or.cz/w/rtmpdump.git/commitdiff/79459a2

Adobe's RTMP specification (21 Dec 2012), section 5.3.1.3 (Extended
Timestamp), says this field is present in Type 3 chunks. Type 3 chunks are
those with the one-byte header size.

This resolves intermittent hangs and segfaults caused by the read function,
and also includes an untested fix for the write function.

The read function was tested with ABC (Australia) News 24 streams, however
they are probably restricted to only Australian internet addresses. Some of
the packets at the start of these streams seem to contain junk timestamp
fields, often requiring the extended field. Test command:

ffplay rtmp://cp81899.live.edgefcs.net/live/news24-med@28772
---
Original patch: https://github.com/vadmium/FFmpeg/commit/0a1e2be.patch

I fixed the equivalent issue in “rtmpdump” and Martin Storsjö
suggested fixing the internal “libavformat” implementation as well, so
here you are :). I also tried fixing the packet write function,
because it shares the affected “ts_delta” field, but I have not tested
it. (Testing would probably involve generating packets with a
timestamp delta ≥ 0xFF, or arbitrary junk like I was seeing from
the ABC.)

Also, I would suggest renaming “ts_delta” to “ts_field” or something
in the RTMPPacket structure, because it is not always interpreted as a
delta. But I’m not sure if that is practical; maybe the structure has
a public API scope or is used elsewhere.


It's not a public API, so it should be just fine to rename it. I can 
rename it in a patch on top of yours.



libavformat/rtmppkt.c | 59 ---
libavformat/rtmppkt.h |  2 +-
2 files changed, 34 insertions(+), 27 deletions(-)

diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index f99540c..b3a8294 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -169,6 +169,7 @@ static int rtmp_packet_read_one_chunk(URLContext
*h, RTMPPacket *p,

uint8_t buf[16];
int channel_id, timestamp, size;
+uint32_t ts_field; // non-extended timestamp or delta field
uint32_t extra = 0;
enum RTMPPacketType type;
int written = 0;
@@ -193,14 +194,14 @@ static int rtmp_packet_read_one_chunk(URLContext
*h, RTMPPacket *p,
type  = prev_pkt[channel_id].type;
extra = prev_pkt[channel_id].extra;

-hdr = 6;
+hdr = 6; // header size indicator


Technically this change is kinda unrelated to the rest - I'll split it out 
separately.



if (hdr == RTMP_PS_ONEBYTE) {
-timestamp = prev_pkt[channel_id].ts_delta;
+ts_field = prev_pkt[channel_id].ts_delta;
} else {
if (ffurl_read_complete(h, buf, 3) != 3)
return AVERROR(EIO);
written += 3;
-timestamp = AV_RB24(buf);
+ts_field = AV_RB24(buf);
if (hdr != RTMP_PS_FOURBYTES) {
if (ffurl_read_complete(h, buf, 3) != 3)
return AVERROR(EIO);
@@ -217,11 +218,13 @@ static int rtmp_packet_read_one_chunk(URLContext
*h, RTMPPacket *p,
extra = AV_RL32(buf);
}
}
-if (timestamp == 0xFF) {
-if (ffurl_read_complete(h, buf, 4) != 4)
-return AVERROR(EIO);
-timestamp = AV_RB32(buf);
-}
+}
+if (ts_field == 0xFF) {
+if (ffurl_read_complete(h, buf, 4) != 4)
+return AVERROR(EIO);
+timestamp = AV_RB32(buf);
+} else {
+timestamp = ts_field;
}
if (hdr != RTMP_PS_TWELVEBYTES)
timestamp += prev_pkt[channel_id].timestamp;
@@ -232,8 +235,7 @@ static int rtmp_packet_read_one_chunk(URLContext
*h, RTMPPacket *p,
return ret;
p-read = written;
p-offset = 0;
-prev_pkt[channel_id].ts_delta   = timestamp -
-  prev_pkt[channel_id].timestamp;
+prev_pkt[channel_id].ts_delta   = ts_field;
prev_pkt[channel_id].timestamp  = timestamp;
} else {
// previous packet in this channel hasn't completed reading


These parts so far look ok, I'll separate out them to a patch for adding 
support for this behaviour in the receiving half of the code.



@@ -303,18 +305,30 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket 

[libav-devel] [PATCH 3/4] rtmppkt: Properly handle extended timestamps when writing

2014-03-05 Thread Martin Storsjö
From: Martin Panter vadm...@gmail.com

---
 libavformat/rtmppkt.c | 35 ---
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index a8432c8..241a521 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -305,18 +305,30 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt,
 int written = 0;
 int ret;
 RTMPPacket *prev_pkt;
+int use_delta; // flag if using timestamp delta, not RTMP_PS_TWELVEBYTES
+uint32_t timestamp; // full 32-bit timestamp or delta value
 
 if ((ret = ff_rtmp_check_alloc_array(prev_pkt_ptr, nb_prev_pkt,
  pkt-channel_id))  0)
 return ret;
 prev_pkt = *prev_pkt_ptr;
 
-pkt-ts_delta = pkt-timestamp - prev_pkt[pkt-channel_id].timestamp;
-
 //if channel_id = 0, this is first presentation of prev_pkt, send full hdr.
-if (prev_pkt[pkt-channel_id].channel_id 
+use_delta = prev_pkt[pkt-channel_id].channel_id 
 pkt-extra == prev_pkt[pkt-channel_id].extra 
-pkt-timestamp = prev_pkt[pkt-channel_id].timestamp) {
+pkt-timestamp = prev_pkt[pkt-channel_id].timestamp;
+
+timestamp = pkt-timestamp;
+if (use_delta) {
+timestamp -= prev_pkt[pkt-channel_id].timestamp;
+}
+if (timestamp = 0xFF) {
+pkt-ts_delta = 0xFF;
+} else {
+pkt-ts_delta = timestamp;
+}
+
+if (use_delta) {
 if (pkt-type == prev_pkt[pkt-channel_id].type 
 pkt-size == prev_pkt[pkt-channel_id].size) {
 mode = RTMP_PS_FOURBYTES;
@@ -337,29 +349,22 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt,
 bytestream_put_le16(p, pkt-channel_id - 64);
 }
 if (mode != RTMP_PS_ONEBYTE) {
-uint32_t timestamp = pkt-timestamp;
-if (mode != RTMP_PS_TWELVEBYTES)
-timestamp = pkt-ts_delta;
-bytestream_put_be24(p, timestamp = 0xFF ? 0xFF : timestamp);
+bytestream_put_be24(p, pkt-ts_delta);
 if (mode != RTMP_PS_FOURBYTES) {
 bytestream_put_be24(p, pkt-size);
 bytestream_put_byte(p, pkt-type);
 if (mode == RTMP_PS_TWELVEBYTES)
 bytestream_put_le32(p, pkt-extra);
 }
-if (timestamp = 0xFF)
-bytestream_put_be32(p, timestamp);
 }
+if (pkt-ts_delta == 0xFF)
+bytestream_put_be32(p, timestamp);
 // save history
 prev_pkt[pkt-channel_id].channel_id = pkt-channel_id;
 prev_pkt[pkt-channel_id].type   = pkt-type;
 prev_pkt[pkt-channel_id].size   = pkt-size;
 prev_pkt[pkt-channel_id].timestamp  = pkt-timestamp;
-if (mode != RTMP_PS_TWELVEBYTES) {
-prev_pkt[pkt-channel_id].ts_delta   = pkt-ts_delta;
-} else {
-prev_pkt[pkt-channel_id].ts_delta   = pkt-timestamp;
-}
+prev_pkt[pkt-channel_id].ts_delta   = pkt-ts_delta;
 prev_pkt[pkt-channel_id].extra  = pkt-extra;
 
 if ((ret = ffurl_write(h, pkt_hdr, p - pkt_hdr))  0)
-- 
1.8.3.4 (Apple Git-47)

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


[libav-devel] [PATCH 2/4] rtmppkt: Add a descriptive comment

2014-03-05 Thread Martin Storsjö
From: Martin Panter vadm...@gmail.com

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

diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index fb3726b..a8432c8 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -194,7 +194,7 @@ static int rtmp_packet_read_one_chunk(URLContext *h, 
RTMPPacket *p,
 type  = prev_pkt[channel_id].type;
 extra = prev_pkt[channel_id].extra;
 
-hdr = 6;
+hdr = 6; // header size indicator
 if (hdr == RTMP_PS_ONEBYTE) {
 ts_field = prev_pkt[channel_id].ts_delta;
 } else {
-- 
1.8.3.4 (Apple Git-47)

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


[libav-devel] [PATCH 4/4] rtmppkt: Rename the ts_delta field to ts_field

2014-03-05 Thread Martin Storsjö
Based on a suggestion by Martin Panter. This is more descriptive,
since it's the actual timestamp field from the RTMP packet,
which might or might not be a delta depending on context (in
some packets it's a delta, in some packets it's an absolute
timestamp, and in some packets it's 0xff to indicate that
the actual delta or absolute timestamp is transmitted separately).
---
 libavformat/rtmppkt.c | 20 ++--
 libavformat/rtmppkt.h |  2 +-
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index 241a521..306a243 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -196,7 +196,7 @@ static int rtmp_packet_read_one_chunk(URLContext *h, 
RTMPPacket *p,
 
 hdr = 6; // header size indicator
 if (hdr == RTMP_PS_ONEBYTE) {
-ts_field = prev_pkt[channel_id].ts_delta;
+ts_field = prev_pkt[channel_id].ts_field;
 } else {
 if (ffurl_read_complete(h, buf, 3) != 3)
 return AVERROR(EIO);
@@ -235,7 +235,7 @@ static int rtmp_packet_read_one_chunk(URLContext *h, 
RTMPPacket *p,
 return ret;
 p-read = written;
 p-offset = 0;
-prev_pkt[channel_id].ts_delta   = ts_field;
+prev_pkt[channel_id].ts_field   = ts_field;
 prev_pkt[channel_id].timestamp  = timestamp;
 } else {
 // previous packet in this channel hasn't completed reading
@@ -244,7 +244,7 @@ static int rtmp_packet_read_one_chunk(URLContext *h, 
RTMPPacket *p,
 p-size  = prev-size;
 p-channel_id= prev-channel_id;
 p-type  = prev-type;
-p-ts_delta  = prev-ts_delta;
+p-ts_field  = prev-ts_field;
 p-extra = prev-extra;
 p-offset= prev-offset;
 p-read  = prev-read + written;
@@ -323,16 +323,16 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt,
 timestamp -= prev_pkt[pkt-channel_id].timestamp;
 }
 if (timestamp = 0xFF) {
-pkt-ts_delta = 0xFF;
+pkt-ts_field = 0xFF;
 } else {
-pkt-ts_delta = timestamp;
+pkt-ts_field = timestamp;
 }
 
 if (use_delta) {
 if (pkt-type == prev_pkt[pkt-channel_id].type 
 pkt-size == prev_pkt[pkt-channel_id].size) {
 mode = RTMP_PS_FOURBYTES;
-if (pkt-ts_delta == prev_pkt[pkt-channel_id].ts_delta)
+if (pkt-ts_field == prev_pkt[pkt-channel_id].ts_field)
 mode = RTMP_PS_ONEBYTE;
 } else {
 mode = RTMP_PS_EIGHTBYTES;
@@ -349,7 +349,7 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt,
 bytestream_put_le16(p, pkt-channel_id - 64);
 }
 if (mode != RTMP_PS_ONEBYTE) {
-bytestream_put_be24(p, pkt-ts_delta);
+bytestream_put_be24(p, pkt-ts_field);
 if (mode != RTMP_PS_FOURBYTES) {
 bytestream_put_be24(p, pkt-size);
 bytestream_put_byte(p, pkt-type);
@@ -357,14 +357,14 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt,
 bytestream_put_le32(p, pkt-extra);
 }
 }
-if (pkt-ts_delta == 0xFF)
+if (pkt-ts_field == 0xFF)
 bytestream_put_be32(p, timestamp);
 // save history
 prev_pkt[pkt-channel_id].channel_id = pkt-channel_id;
 prev_pkt[pkt-channel_id].type   = pkt-type;
 prev_pkt[pkt-channel_id].size   = pkt-size;
 prev_pkt[pkt-channel_id].timestamp  = pkt-timestamp;
-prev_pkt[pkt-channel_id].ts_delta   = pkt-ts_delta;
+prev_pkt[pkt-channel_id].ts_field   = pkt-ts_field;
 prev_pkt[pkt-channel_id].extra  = pkt-extra;
 
 if ((ret = ffurl_write(h, pkt_hdr, p - pkt_hdr))  0)
@@ -398,7 +398,7 @@ int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, 
RTMPPacketType type,
 pkt-type   = type;
 pkt-timestamp  = timestamp;
 pkt-extra  = 0;
-pkt-ts_delta   = 0;
+pkt-ts_field   = 0;
 
 return 0;
 }
diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h
index 3ccc6b4..e973684 100644
--- a/libavformat/rtmppkt.h
+++ b/libavformat/rtmppkt.h
@@ -78,7 +78,7 @@ typedef struct RTMPPacket {
 intchannel_id; /// RTMP channel ID (nothing to do with 
audio/video channels though)
 RTMPPacketType type;   /// packet payload type
 uint32_t   timestamp;  /// packet full timestamp
-uint32_t   ts_delta;   /// 24-bit timestamp or increment to the 
previous one, in milliseconds (latter only for media packets). Clipped to a 
maximum of 0xFF, indicating an extended timestamp field.
+uint32_t   ts_field;   /// 24-bit timestamp or increment to the 
previous one, in milliseconds (latter only for media packets). Clipped to a 
maximum of 0xFF, indicating an extended timestamp field.
 uint32_t   extra;  /// probably an additional channel ID used 
during streaming data
 uint8_t*data;  /// packet payload
 int

[libav-devel] [PATCH 1/4] rtmppkt: handle extended timestamp field even for one-byte header

2014-03-05 Thread Martin Storsjö
From: Martin Panter vadm...@gmail.com

Related fix in rtmpdump:
https://repo.or.cz/w/rtmpdump.git/commitdiff/79459a2

Adobe's RTMP specification (21 Dec 2012), section 5.3.1.3 (Extended
Timestamp), says this field is present in Type 3 chunks. Type 3 chunks are
those with the one-byte header size.

This resolves intermittent hangs and segfaults caused by the read function,
and also includes an untested fix for the write function.

The read function was tested with ABC (Australia) News 24 streams, however
they are probably restricted to only Australian internet addresses. Some of
the packets at the start of these streams seem to contain junk timestamp
fields, often requiring the extended field. Test command:

ffplay rtmp://cp81899.live.edgefcs.net/live/news24-med@28772
---
 libavformat/rtmppkt.c | 20 +++-
 libavformat/rtmppkt.h |  2 +-
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index 81621b1..fb3726b 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -169,6 +169,7 @@ static int rtmp_packet_read_one_chunk(URLContext *h, 
RTMPPacket *p,
 
 uint8_t buf[16];
 int channel_id, timestamp, size;
+uint32_t ts_field; // non-extended timestamp or delta field
 uint32_t extra = 0;
 enum RTMPPacketType type;
 int written = 0;
@@ -195,12 +196,12 @@ static int rtmp_packet_read_one_chunk(URLContext *h, 
RTMPPacket *p,
 
 hdr = 6;
 if (hdr == RTMP_PS_ONEBYTE) {
-timestamp = prev_pkt[channel_id].ts_delta;
+ts_field = prev_pkt[channel_id].ts_delta;
 } else {
 if (ffurl_read_complete(h, buf, 3) != 3)
 return AVERROR(EIO);
 written += 3;
-timestamp = AV_RB24(buf);
+ts_field = AV_RB24(buf);
 if (hdr != RTMP_PS_FOURBYTES) {
 if (ffurl_read_complete(h, buf, 3) != 3)
 return AVERROR(EIO);
@@ -217,11 +218,13 @@ static int rtmp_packet_read_one_chunk(URLContext *h, 
RTMPPacket *p,
 extra = AV_RL32(buf);
 }
 }
-if (timestamp == 0xFF) {
-if (ffurl_read_complete(h, buf, 4) != 4)
-return AVERROR(EIO);
-timestamp = AV_RB32(buf);
-}
+}
+if (ts_field == 0xFF) {
+if (ffurl_read_complete(h, buf, 4) != 4)
+return AVERROR(EIO);
+timestamp = AV_RB32(buf);
+} else {
+timestamp = ts_field;
 }
 if (hdr != RTMP_PS_TWELVEBYTES)
 timestamp += prev_pkt[channel_id].timestamp;
@@ -232,8 +235,7 @@ static int rtmp_packet_read_one_chunk(URLContext *h, 
RTMPPacket *p,
 return ret;
 p-read = written;
 p-offset = 0;
-prev_pkt[channel_id].ts_delta   = timestamp -
-  prev_pkt[channel_id].timestamp;
+prev_pkt[channel_id].ts_delta   = ts_field;
 prev_pkt[channel_id].timestamp  = timestamp;
 } else {
 // previous packet in this channel hasn't completed reading
diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h
index 7121d7e..3ccc6b4 100644
--- a/libavformat/rtmppkt.h
+++ b/libavformat/rtmppkt.h
@@ -78,7 +78,7 @@ typedef struct RTMPPacket {
 intchannel_id; /// RTMP channel ID (nothing to do with 
audio/video channels though)
 RTMPPacketType type;   /// packet payload type
 uint32_t   timestamp;  /// packet full timestamp
-uint32_t   ts_delta;   /// timestamp increment to the previous one in 
milliseconds (latter only for media packets)
+uint32_t   ts_delta;   /// 24-bit timestamp or increment to the 
previous one, in milliseconds (latter only for media packets). Clipped to a 
maximum of 0xFF, indicating an extended timestamp field.
 uint32_t   extra;  /// probably an additional channel ID used 
during streaming data
 uint8_t*data;  /// packet payload
 intsize;   /// packet payload size
-- 
1.8.3.4 (Apple Git-47)

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


Re: [libav-devel] [PATCH] avfilter: Add missing emms_c when needed

2014-03-05 Thread Anton Khirnov

On Wed, 05 Mar 2014 08:56:52 -0500, Justin Ruggles justin.rugg...@gmail.com 
wrote:
 On 03/05/2014 04:43 AM, Luca Barbato wrote:
  diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
  index 12d496e..2cdfe23 100644
  --- a/libavfilter/af_volume.c
  +++ b/libavfilter/af_volume.c
  @@ -262,6 +262,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
  *buf)
   vol-scale_samples(out_buf-extended_data[p],
  buf-extended_data[p], plane_samples,
  vol-volume_i);
  +emms_c();
   }
   } else if (av_get_packed_sample_fmt(vol-sample_fmt) == 
  AV_SAMPLE_FMT_FLT) {
   for (p = 0; p  vol-planes; p++) {
 
 Neither of the dsp functions used in af_volume utilize MMX registers.
 Adding emms_c() is completely pointless.
 

That requires the caller to know this.

And we might add such functions in the future (unlikely, but still possible)

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


Re: [libav-devel] [PATCH] avfilter: Add missing emms_c when needed

2014-03-05 Thread Janne Grunau
On 2014-03-05 15:25:40 +0100, Anton Khirnov wrote:
 
 On Wed, 05 Mar 2014 08:56:52 -0500, Justin Ruggles justin.rugg...@gmail.com 
 wrote:
  On 03/05/2014 04:43 AM, Luca Barbato wrote:
   diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
   index 12d496e..2cdfe23 100644
   --- a/libavfilter/af_volume.c
   +++ b/libavfilter/af_volume.c
   @@ -262,6 +262,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
   *buf)
vol-scale_samples(out_buf-extended_data[p],
   buf-extended_data[p], plane_samples,
   vol-volume_i);
   +emms_c();
}
} else if (av_get_packed_sample_fmt(vol-sample_fmt) == 
   AV_SAMPLE_FMT_FLT) {
for (p = 0; p  vol-planes; p++) {
  
  Neither of the dsp functions used in af_volume utilize MMX registers.
  Adding emms_c() is completely pointless.
  
 
 That requires the caller to know this.
 
 And we might add such functions in the future (unlikely, but still possible)

is there a reason we don't use the the libavcodec approach and just call
emms_c in ff_filter_frame?

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


Re: [libav-devel] [PATCH] avfilter: Add missing emms_c when needed

2014-03-05 Thread Kostya Shishkov
On Wed, Mar 05, 2014 at 04:01:15PM +0100, Janne Grunau wrote:
 On 2014-03-05 15:25:40 +0100, Anton Khirnov wrote:
  
  On Wed, 05 Mar 2014 08:56:52 -0500, Justin Ruggles 
  justin.rugg...@gmail.com wrote:
   On 03/05/2014 04:43 AM, Luca Barbato wrote:
diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
index 12d496e..2cdfe23 100644
--- a/libavfilter/af_volume.c
+++ b/libavfilter/af_volume.c
@@ -262,6 +262,7 @@ static int filter_frame(AVFilterLink *inlink, 
AVFrame *buf)
 vol-scale_samples(out_buf-extended_data[p],
buf-extended_data[p], 
plane_samples,
vol-volume_i);
+emms_c();
 }
 } else if (av_get_packed_sample_fmt(vol-sample_fmt) == 
AV_SAMPLE_FMT_FLT) {
 for (p = 0; p  vol-planes; p++) {
   
   Neither of the dsp functions used in af_volume utilize MMX registers.
   Adding emms_c() is completely pointless.
   
  
  That requires the caller to know this.
  
  And we might add such functions in the future (unlikely, but still possible)
 
 is there a reason we don't use the the libavcodec approach and just call
 emms_c in ff_filter_frame?

You can have chain of filters.
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel


Re: [libav-devel] [PATCH] avfilter: Add missing emms_c when needed

2014-03-05 Thread Justin Ruggles

On 03/05/2014 09:25 AM, Anton Khirnov wrote:

On Wed, 05 Mar 2014 08:56:52 -0500, Justin Ruggles justin.rugg...@gmail.com 
wrote:

On 03/05/2014 04:43 AM, Luca Barbato wrote:

diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
index 12d496e..2cdfe23 100644
--- a/libavfilter/af_volume.c
+++ b/libavfilter/af_volume.c
@@ -262,6 +262,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
  vol-scale_samples(out_buf-extended_data[p],
 buf-extended_data[p], plane_samples,
 vol-volume_i);
+emms_c();
  }
  } else if (av_get_packed_sample_fmt(vol-sample_fmt) == 
AV_SAMPLE_FMT_FLT) {
  for (p = 0; p  vol-planes; p++) {

Neither of the dsp functions used in af_volume utilize MMX registers.
Adding emms_c() is completely pointless.


That requires the caller to know this.

And we might add such functions in the future (unlikely, but still possible)



What caller are you referring to, and why would they have to know 
anything? Littering the code with unnecessary emms seems pretty silly to 
me. If someone happens to add more MMX/3DNow functions (they better have 
a very good reason...) it's up to them to add the required emms either 
in their function or in the appropriate places where that function is used.


-Justin

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


Re: [libav-devel] [PATCH] avfilter: Add missing emms_c when needed

2014-03-05 Thread Anton Khirnov

On Wed, 05 Mar 2014 10:59:20 -0500, Justin Ruggles justin.rugg...@gmail.com 
wrote:
 On 03/05/2014 09:25 AM, Anton Khirnov wrote:
  On Wed, 05 Mar 2014 08:56:52 -0500, Justin Ruggles 
  justin.rugg...@gmail.com wrote:
  On 03/05/2014 04:43 AM, Luca Barbato wrote:
  diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
  index 12d496e..2cdfe23 100644
  --- a/libavfilter/af_volume.c
  +++ b/libavfilter/af_volume.c
  @@ -262,6 +262,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
  *buf)
vol-scale_samples(out_buf-extended_data[p],
   buf-extended_data[p], plane_samples,
   vol-volume_i);
  +emms_c();
}
} else if (av_get_packed_sample_fmt(vol-sample_fmt) == 
  AV_SAMPLE_FMT_FLT) {
for (p = 0; p  vol-planes; p++) {
  Neither of the dsp functions used in af_volume utilize MMX registers.
  Adding emms_c() is completely pointless.
 
  That requires the caller to know this.
 
  And we might add such functions in the future (unlikely, but still possible)
 
 
 What caller are you referring to, and why would they have to know 
 anything? Littering the code with unnecessary emms seems pretty silly to 
 me. If someone happens to add more MMX/3DNow functions (they better have 
 a very good reason...) it's up to them to add the required emms either 
 in their function or in the appropriate places where that function is used.
 

I mean the caller of float_dsp does not know what kind of functions are used in
it. Or we should document it that functions requiring emms are not used and
ban them forever.

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


Re: [libav-devel] [PATCH] avfilter: Add missing emms_c when needed

2014-03-05 Thread Hendrik Leppkes
On Wed, Mar 5, 2014 at 6:11 PM, Anton Khirnov an...@khirnov.net wrote:

 On Wed, 05 Mar 2014 10:59:20 -0500, Justin Ruggles justin.rugg...@gmail.com 
 wrote:
 On 03/05/2014 09:25 AM, Anton Khirnov wrote:
  On Wed, 05 Mar 2014 08:56:52 -0500, Justin Ruggles 
  justin.rugg...@gmail.com wrote:
  On 03/05/2014 04:43 AM, Luca Barbato wrote:
  diff --git a/libavfilter/af_volume.c b/libavfilter/af_volume.c
  index 12d496e..2cdfe23 100644
  --- a/libavfilter/af_volume.c
  +++ b/libavfilter/af_volume.c
  @@ -262,6 +262,7 @@ static int filter_frame(AVFilterLink *inlink, 
  AVFrame *buf)
vol-scale_samples(out_buf-extended_data[p],
   buf-extended_data[p], 
  plane_samples,
   vol-volume_i);
  +emms_c();
}
} else if (av_get_packed_sample_fmt(vol-sample_fmt) == 
  AV_SAMPLE_FMT_FLT) {
for (p = 0; p  vol-planes; p++) {
  Neither of the dsp functions used in af_volume utilize MMX registers.
  Adding emms_c() is completely pointless.
 
  That requires the caller to know this.
 
  And we might add such functions in the future (unlikely, but still 
  possible)
 

 What caller are you referring to, and why would they have to know
 anything? Littering the code with unnecessary emms seems pretty silly to
 me. If someone happens to add more MMX/3DNow functions (they better have
 a very good reason...) it's up to them to add the required emms either
 in their function or in the appropriate places where that function is used.


 I mean the caller of float_dsp does not know what kind of functions are used 
 in
 it. Or we should document it that functions requiring emms are not used and
 ban them forever.


Is it very likely to get MMX code written these days, and not at least SSE/SSE2?
Maybe put a notice in float_dsp to warn people. :p

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


Re: [libav-devel] [PATCH 2/2] arm: get_cabac inline asm

2014-03-05 Thread Martin Storsjö

On Sun, 2 Mar 2014, Janne Grunau wrote:


Based on the aarch64 asm. CPU cycle counts on cortex-a9 compared to
gcc 4.8.2:
before: 475 decicycles in get_cabac_noinline, 67106035 runs, 2829 skips
after:  393 decicycles in get_cabac_noinline, 67106474 runs, 2390 skips

Overall speedup is above 2%. Code generated by clang 3.4 is slower on
the same hardware and the relative change is a little larger.
---
libavcodec/arm/cabac.h   | 102 +++
libavcodec/cabac_functions.h |   3 ++
2 files changed, 105 insertions(+)
create mode 100644 libavcodec/arm/cabac.h


Both this and the aarch64 version look ok after a very cursory 
readthrough.


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


Re: [libav-devel] [PATCH] x86: dcadsp: Fix linking with yasm and optimizations disabled

2014-03-05 Thread Janne Grunau
On 2014-03-05 14:10:24 +0100, Diego Biurrun wrote:
 Some optimized functions reference optimized symbols, so the functions
 must be explicitly disabled when those symbols are unavailable.
 ---
 
 Now with a more general #if, as suggested by James.

I think --disable-optimizations --disable-sse2 would still fail with
this conditions. If that's the common pattern we use that will fail
in other places too. I don't think it's worth changing and I would
prefer adding dead code elimiation (-fdce for gcc) to cflags_noopt.

  libavcodec/x86/dcadsp_init.c |4 
  1 file changed, 4 insertions(+)
 
 diff --git a/libavcodec/x86/dcadsp_init.c b/libavcodec/x86/dcadsp_init.c
 index 3821892..65e3db5 100644
 --- a/libavcodec/x86/dcadsp_init.c
 +++ b/libavcodec/x86/dcadsp_init.c
 @@ -60,6 +60,7 @@ void ff_synth_filter_inner_sse2(float *synth_buf_ptr, float 
 synth_buf2[32],
  const float window[512],
  float out[32], intptr_t offset, float scale);
  
 +#if HAVE_YASM
  static void synth_filter_sse2(FFTContext *imdct,
float *synth_buf_ptr, int *synth_buf_offset,
float synth_buf2[32], const float window[512],
 @@ -74,12 +75,15 @@ static void synth_filter_sse2(FFTContext *imdct,
  
  *synth_buf_offset = (*synth_buf_offset - 32)  511;
  }
 +#endif /* HAVE_YASM */
  
  av_cold void ff_synth_filter_init_x86(SynthFilterContext *s)
  {
 +#if HAVE_YASM
  int cpu_flags = av_get_cpu_flags();
  
  if (EXTERNAL_SSE2(cpu_flags)) {
  s-synth_filter_float = synth_filter_sse2;
  }
 +#endif /* HAVE_YASM */
  }

patch ok

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


Re: [libav-devel] [PATCH] avfilter: Add missing emms_c when needed

2014-03-05 Thread Tim Walker
On 05 Mar 2014, at 18:29, Hendrik Leppkes h.lepp...@gmail.com wrote:

 
 Is it very likely to get MMX code written these days, and not at least 
 SSE/SSE2?
 Maybe put a notice in float_dsp to warn people. :p
 
 - Hendrik

How much MMX do we still have? Port it to SSE* and drop support for it :P

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


[libav-devel] [RFC 0/3] lavf/http: import HTTP implementation from ffmpeg

2014-03-05 Thread Alessandro Ghedini
This imports the HTTP implementation from ffmpeg. It also includes the
av_strtok() and av_asprintf() functions (again from ffmpeg) which are necessary
to build.

Except for the av_strtok() and av_asprintf() patches (for which I used more or
less the original patches) I included a list of the IDs of the original ffmpeg
commits that introduced some of the changes, but it's obviously incomplete,
since I couldn't track everything (it's also worth noting that I initially tried
to import the commits as-is from ffmpeg.git, but that turned out to be a much
more difficult strategy, since most of them don't even apply to libav.git and
many of the new features includes many fixes introduced by following commits).

This would fix, among other things, a couple of issues we are seeing in Debian's
mpv package, namely #740421 [0] (really slow HTTP audio streaming) and #739936
[1] (missing support for ICY stream metadata).

[0] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=740421
[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=739936

Alessandro Ghedini (1):
  lavf/http: import HTTP implementation from ffmpeg

Clément Bœsch (1):
  lavu: add av_asprintf()

Stefano Sabatini (1):
  lavu: add av_strtok()

 doc/APIchanges   |   6 ++
 doc/protocols.texi   |  66 ++
 libavformat/http.c   | 248 ---
 libavutil/avstring.c |  55 
 libavutil/avstring.h |  34 +++
 libavutil/version.h  |   2 +-
 6 files changed, 397 insertions(+), 14 deletions(-)

-- 
1.9.0

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

[libav-devel] [RFC 2/3] lavu: add av_strtok()

2014-03-05 Thread Alessandro Ghedini
From: Stefano Sabatini stefa...@gmail.com

The function strtok_r() is part of the POSIX.1 specification, but is not
available on some platforms. We provide an internal implementation, so we
do not need to rely on a platform implementation.
---
 doc/APIchanges   |  3 +++
 libavutil/avstring.c | 29 +
 libavutil/avstring.h | 24 
 libavutil/version.h  |  2 +-
 4 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index f8ce3b0..1bb9f1c 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2013-12-xx
 
 API changes, most recent first:
 
+2014-03-xx - xxx - lavu 53.07.0 - avstring.h
+  Add av_strtok().
+
 2014-03-xx - xxx - lavu 53.06.0 - avstring.h
   Add av_asprintf().
 
diff --git a/libavutil/avstring.c b/libavutil/avstring.c
index a292731..edcb511 100644
--- a/libavutil/avstring.c
+++ b/libavutil/avstring.c
@@ -260,6 +260,35 @@ int av_isxdigit(int c)
 return av_isdigit(c) || (c = 'a'  c = 'f');
 }
 
+char *av_strtok(char *s, const char *delim, char **saveptr)
+{
+char *tok;
+
+if (!s  !(s = *saveptr))
+return NULL;
+
+/* skip leading delimiters */
+s += strspn(s, delim);
+
+/* s now points to the first non delimiter char, or to the end of the 
string */
+if (!*s) {
+*saveptr = NULL;
+return NULL;
+}
+tok = s++;
+
+/* skip non delimiters */
+s += strcspn(s, delim);
+if (*s) {
+*s = 0;
+*saveptr = s+1;
+} else {
+*saveptr = NULL;
+}
+
+return tok;
+}
+
 #ifdef TEST
 
 int main(void)
diff --git a/libavutil/avstring.h b/libavutil/avstring.h
index 4789cd5..33b9cdc 100644
--- a/libavutil/avstring.h
+++ b/libavutil/avstring.h
@@ -233,4 +233,28 @@ const char *av_dirname(char *path);
  * @}
  */
 
+/**
+ * Split the string into several tokens which can be accessed by
+ * successive calls to av_strtok().
+ *
+ * A token is defined as a sequence of characters not belonging to the
+ * set specified in delim.
+ *
+ * On the first call to av_strtok(), s should point to the string to
+ * parse, and the value of saveptr is ignored. In subsequent calls, s
+ * should be NULL, and saveptr should be unchanged since the previous
+ * call.
+ *
+ * This function is similar to strtok_r() defined in POSIX.1.
+ *
+ * @param s the string to parse, may be NULL
+ * @param delim 0-terminated list of token delimiters, must be non-NULL
+ * @param saveptr user-provided pointer which points to stored
+ * information necessary for av_strtok() to continue scanning the same
+ * string. saveptr is updated to point to the next character after the
+ * first delimiter found, or to NULL if the string was terminated
+ * @return the found token, or NULL when no token is found
+ */
+char *av_strtok(char *s, const char *delim, char **saveptr);
+
 #endif /* AVUTIL_AVSTRING_H */
diff --git a/libavutil/version.h b/libavutil/version.h
index 36070b2..d680979 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,7 +54,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 53
-#define LIBAVUTIL_VERSION_MINOR  6
+#define LIBAVUTIL_VERSION_MINOR  7
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
1.9.0

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


[libav-devel] [RFC 3/3] lavf/http: import HTTP implementation from ffmpeg

2014-03-05 Thread Alessandro Ghedini
This patch imports the HTTP implementation from ffmpeg.

Incomplete list of new features and fixes:

 * Support for HTTP seeking (intial ffmpeg commit e05655f)
 * Custom user agent (initial ffmpeg commit 2bb1c71)
 * Support for reading ICY metadata (initial ffmpeg commit a92fbe1)
 * Support for reading and setting cookies (initial ffmpeg commit 0b80a12)
 * Support for setting initial and ending offsets (initial ffmpeg commit 
d52882fa)
 * Improve options descriptions (initial ffmpeg commit 255ec768)

Note that the commit ID specifies when the feature was originally introduced in
ffmpeg, but doesn't account for subsequent changes and fixes.

Bug-Debian: https://bugs.debian.org/740421
Bug-Debian: https://bugs.debian.org/739936
---
 doc/protocols.texi |  66 ++
 libavformat/http.c | 248 ++---
 2 files changed, 301 insertions(+), 13 deletions(-)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index 1a9f575..cc3b4b6 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -89,6 +89,72 @@ m3u8 files.
 
 HTTP (Hyper Text Transfer Protocol).
 
+This protocol accepts the following options.
+
+@table @option
+@item seekable
+Control seekability of connection. If set to 1 the resource is
+supposed to be seekable, if set to 0 it is assumed not to be seekable,
+if set to -1 it will try to autodetect if it is seekable. Default
+value is -1.
+
+@item chunked_post
+If set to 1 use chunked transfer-encoding for posts, default is 1.
+
+@item headers
+Set custom HTTP headers, can override built in default headers. The
+value must be a string encoding the headers.
+
+@item content_type
+Force a content type.
+
+@item user-agent
+Override User-Agent header. If not specified the protocol will use a
+string describing the libavformat build.
+
+@item multiple_requests
+Use persistent connections if set to 1. By default it is 0.
+
+@item post_data
+Set custom HTTP post data.
+
+@item timeout
+Set timeout of socket I/O operations used by the underlying low level
+operation. By default it is set to -1, which means that the timeout is
+not specified.
+
+@item mime_type
+Set MIME type.
+
+@item icy
+If set to 1 request ICY (SHOUTcast) metadata from the server. If the server
+supports this, the metadata has to be retrieved by the application by reading
+the @option{icy_metadata_headers} and @option{icy_metadata_packet} options.
+The default is 0.
+
+@item icy_metadata_headers
+If the server supports ICY metadata, this contains the ICY specific HTTP reply
+headers, separated with newline characters.
+
+@item icy_metadata_packet
+If the server supports ICY metadata, and @option{icy} was set to 1, this
+contains the last non-empty metadata packet sent by the server.
+
+@item cookies
+Set the cookies to be sent in future requests. The format of each cookie is the
+same as the value of a Set-Cookie HTTP response field. Multiple cookies can be
+delimited by a newline character.
+@end table
+
+@subsection HTTP Cookies
+
+Some HTTP requests will be denied unless cookie values are passed in with the
+request. The @option{cookies} option allows these cookies to be specified. At
+the very least, each cookie must specify a value along with a path and domain.
+HTTP requests that match both the domain and path will automatically include 
the
+cookie value in the HTTP Cookie header field. Multiple cookies can be delimited
+by a newline.
+
 @section mmst
 
 MMS (Microsoft Media Server) protocol over TCP.
diff --git a/libavformat/http.c b/libavformat/http.c
index 96f56f8..f9ce2c3 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -50,18 +50,30 @@ typedef struct {
 int line_count;
 int http_code;
 int64_t chunksize;  /** Used if Transfer-Encoding: chunked 
otherwise -1. */
-int64_t off, filesize;
+char *content_type;
+char *user_agent;
+int64_t off, filesize, req_end_offset;
+int icy_data_read;  /// how much data was read since last ICY 
metadata packet
+int icy_metaint;/// after how many bytes of read data a new 
metadata packet will be found
 char *location;
 HTTPAuthState auth_state;
 HTTPAuthState proxy_auth_state;
 char *headers;
 int willclose;  /** Set if the server correctly handles 
Connection: close and will close the connection after feeding us the content. */
+int seekable;   /** Control seekability, 0 = disable, 1 = enable, 
-1 = probe. */
 int chunked_post;
 int end_chunked_post;   /** A flag which indicates if the end of chunked 
encoding has been sent. */
 int end_header; /** A flag which indicates we have finished to 
read POST reply. */
 int multiple_requests;  /** A flag which indicates if we use persistent 
connections. */
 uint8_t *post_data;
 int post_datalen;
+int is_akamai;
+int is_mediagateway;
+char *mime_type;
+char *cookies;  /// holds newline (\n) delimited Set-Cookie 
header field values (without the 

[libav-devel] [RFC 1/3] lavu: add av_asprintf()

2014-03-05 Thread Alessandro Ghedini
From: Clément Bœsch ubi...@gmail.com

---
 doc/APIchanges   |  3 +++
 libavutil/avstring.c | 26 ++
 libavutil/avstring.h | 10 ++
 libavutil/version.h  |  2 +-
 4 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index d6134f9..f8ce3b0 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,9 @@ libavutil: 2013-12-xx
 
 API changes, most recent first:
 
+2014-03-xx - xxx - lavu 53.06.0 - avstring.h
+  Add av_asprintf().
+
 2014-xx-xx - xxx - lavu 53.05.0 - frame.h
   Add av_frame_copy() for copying the frame data.
 
diff --git a/libavutil/avstring.c b/libavutil/avstring.c
index 3ea7be0..a292731 100644
--- a/libavutil/avstring.c
+++ b/libavutil/avstring.c
@@ -108,6 +108,32 @@ size_t av_strlcatf(char *dst, size_t size, const char 
*fmt, ...)
 return len;
 }
 
+char *av_asprintf(const char *fmt, ...)
+{
+char *p = NULL;
+va_list va;
+int len;
+
+va_start(va, fmt);
+len = vsnprintf(NULL, 0, fmt, va);
+va_end(va);
+if (len  0)
+goto end;
+
+p = av_malloc(len + 1);
+if (!p)
+goto end;
+
+va_start(va, fmt);
+len = vsnprintf(p, len + 1, fmt, va);
+va_end(va);
+if (len  0)
+av_freep(p);
+
+end:
+return p;
+}
+
 char *av_d2str(double d)
 {
 char *str = av_malloc(16);
diff --git a/libavutil/avstring.h b/libavutil/avstring.h
index b7d1098..4789cd5 100644
--- a/libavutil/avstring.h
+++ b/libavutil/avstring.h
@@ -131,6 +131,16 @@ size_t av_strlcat(char *dst, const char *src, size_t size);
 size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) 
av_printf_format(3, 4);
 
 /**
+ * Print arguments following specified format into a large enough auto
+ * allocated buffer. It is similar to GNU asprintf().
+ * @param fmt printf-compatible format string, specifying how the
+ *following parameters are used.
+ * @return the allocated string
+ * @note You have to free the string yourself with av_free().
+ */
+char *av_asprintf(const char *fmt, ...) av_printf_format(1, 2);
+
+/**
  * Convert a number to a av_malloced string.
  */
 char *av_d2str(double d);
diff --git a/libavutil/version.h b/libavutil/version.h
index cd0981c..36070b2 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -54,7 +54,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 53
-#define LIBAVUTIL_VERSION_MINOR  5
+#define LIBAVUTIL_VERSION_MINOR  6
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
1.9.0

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

Re: [libav-devel] [PATCH] x86: dcadsp: Fix linking with yasm and optimizations disabled

2014-03-05 Thread Diego Biurrun
On Wed, Mar 05, 2014 at 08:12:27PM +0100, Janne Grunau wrote:
 On 2014-03-05 14:10:24 +0100, Diego Biurrun wrote:
  Some optimized functions reference optimized symbols, so the functions
  must be explicitly disabled when those symbols are unavailable.
  ---
  
  Now with a more general #if, as suggested by James.
 
 I think --disable-optimizations --disable-sse2 would still fail with
 this conditions.

No, it does not fail.

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


[libav-devel] [PATCH 2/5] mxf: Set audio packets pts

2014-03-05 Thread Luca Barbato
From: Matthieu Bouron matthieu.bou...@gmail.com

Extrapolate audio timestamps based on the number of samples demuxed.

Deal with some MXF nastiness involving fractional number of
samples per EditUnit when seeking (the specs handwave this away).

Further fixes from Tomas Härdin.

Signed-off-by: Luca Barbato lu_z...@gentoo.org
---
 libavformat/mxfdec.c| 111 ++--
 tests/ref/seek/lavf-mxf |   2 +-
 tests/ref/seek/lavf-mxf_d10 |   2 +-
 3 files changed, 108 insertions(+), 7 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 158e866..8591f69 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -122,6 +122,8 @@ typedef struct {
 uint8_t track_number[4];
 AVRational edit_rate;
 int intra_only;
+uint64_t sample_count;
+int64_t original_duration; /* st-duration in SampleRate/EditRate units */
 } MXFTrack;
 
 typedef struct {
@@ -1424,7 +1426,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
 }
 st-id = source_track-track_id;
 st-priv_data = source_track;
-st-duration = component-duration;
+source_track-original_duration = st-duration = component-duration;
 if (st-duration == -1)
 st-duration = AV_NOPTS_VALUE;
 st-start_time = component-start_position;
@@ -1439,6 +1441,10 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
 }
 avpriv_set_pts_info(st, 64, material_track-edit_rate.den, 
material_track-edit_rate.num);
 
+/* ensure SourceTrack EditRate == MaterialTrack EditRate since only
+ * the former is accessible via st-priv_data */
+source_track-edit_rate = material_track-edit_rate;
+
 PRINT_KEY(mxf-fc, data definition   ul, 
source_track-sequence-data_definition_ul);
 codec_ul = mxf_get_codec_ul(ff_mxf_data_definition_uls, 
source_track-sequence-data_definition_ul);
 st-codec-codec_type = codec_ul-id;
@@ -1569,6 +1575,12 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
 avpriv_set_pts_info(st, 64, 1, 48000);
 }
 
+/* if duration is set, rescale it from EditRate to SampleRate */
+if (st-duration != AV_NOPTS_VALUE)
+st-duration = av_rescale_q(st-duration,
+
av_inv_q(material_track-edit_rate),
+st-time_base);
+
 /* TODO: implement AV_CODEC_ID_RAWAUDIO */
 if (st-codec-codec_id == AV_CODEC_ID_PCM_S16LE) {
 if (descriptor-bits_per_sample  16  
descriptor-bits_per_sample = 24)
@@ -2037,6 +2049,63 @@ static int64_t mxf_set_current_edit_unit(MXFContext 
*mxf, int64_t current_offset
 return next_ofs;
 }
 
+static int mxf_compute_sample_count(MXFContext *mxf, int stream_index,
+uint64_t *sample_count)
+{
+int i, total = 0, size = 0;
+AVStream *st = mxf-fc-streams[stream_index];
+MXFTrack *track = st-priv_data;
+AVRational time_base = av_inv_q(track-edit_rate);
+AVRational sample_rate = av_inv_q(st-time_base);
+const MXFSamplesPerFrame *spf = NULL;
+
+if ((sample_rate.num / sample_rate.den) == 48000)
+spf = ff_mxf_get_samples_per_frame(mxf-fc, time_base);
+if (!spf) {
+int remainder = (sample_rate.num * time_base.num) %
+(time_base.den * sample_rate.den);
+*sample_count = av_q2d(av_mul_q((AVRational){mxf-current_edit_unit, 
1},
+av_mul_q(sample_rate, time_base)));
+if (remainder)
+av_log(mxf-fc, AV_LOG_WARNING,
+   seeking detected on stream #%d with time base (%d/%d) and 
+   sample rate (%d/%d), audio pts won't be accurate.\n,
+   stream_index, time_base.num, time_base.den,
+   sample_rate.num, sample_rate.den);
+return 0;
+}
+
+while (spf-samples_per_frame[size]) {
+total += spf-samples_per_frame[size];
+size++;
+}
+
+if (!size)
+return 0;
+
+*sample_count = (mxf-current_edit_unit / size) * (uint64_t)total;
+for (i = 0; i  mxf-current_edit_unit % size; i++) {
+*sample_count += spf-samples_per_frame[i];
+}
+
+return 0;
+}
+
+static int mxf_set_audio_pts(MXFContext *mxf, AVCodecContext *codec,
+ AVPacket *pkt)
+{
+MXFTrack *track = mxf-fc-streams[pkt-stream_index]-priv_data;
+int64_t bits_per_sample = av_get_bits_per_sample(codec-codec_id);
+
+pkt-pts = track-sample_count;
+
+if (codec-channels = 0 || codec-channels * bits_per_sample  8)
+return AVERROR_INVALIDDATA;
+
+track-sample_count += pkt-size / (codec-channels * bits_per_sample / 8);
+return 0;
+}
+
 static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt)
 {
 KLVPacket klv;
@@ -2061,6 +2130,7 @@ static int 

[libav-devel] [PATCH 5/5] mxf: Return meaningful errors

2014-03-05 Thread Luca Barbato
---
 libavformat/mxfdec.c | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index dcae26d..27f996f 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -2263,17 +2263,18 @@ static int mxf_read_packet_old(AVFormatContext *s, 
AVPacket *pkt)
 {
 KLVPacket klv;
 MXFContext *mxf = s-priv_data;
+int ret;
 
 while (!s-pb-eof_reached) {
-if (klv_read_packet(klv, s-pb)  0)
-return -1;
+if ((ret = klv_read_packet(klv, s-pb))  0)
+return ret;
 PRINT_KEY(s, read packet, klv.key);
 av_dlog(s, size %PRIu64 offset %#PRIx64\n, klv.length, 
klv.offset);
 if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key)) {
-int res = mxf_decrypt_triplet(s, pkt, klv);
-if (res  0) {
+ret = mxf_decrypt_triplet(s, pkt, klv);
+if (ret  0) {
 av_log(s, AV_LOG_ERROR, invalid encoded triplet\n);
-return -1;
+return ret;
 }
 return 0;
 }
@@ -2313,12 +2314,14 @@ static int mxf_read_packet_old(AVFormatContext *s, 
AVPacket *pkt)
 
 /* check for 8 channels AES3 element */
 if (klv.key[12] == 0x06  klv.key[13] == 0x01  klv.key[14] == 
0x10) {
-if (mxf_get_d10_aes3_packet(s-pb, s-streams[index], pkt, 
klv.length)  0) {
+ret = mxf_get_d10_aes3_packet(s-pb, s-streams[index],
+  pkt, klv.length);
+if (ret  0) {
 av_log(s, AV_LOG_ERROR, error reading D-10 aes3 frame\n);
-return -1;
+return ret;
 }
 } else {
-int ret = av_get_packet(s-pb, pkt, klv.length);
+ret = av_get_packet(s-pb, pkt, klv.length);
 if (ret  0)
 return ret;
 }
@@ -2343,7 +2346,7 @@ static int mxf_read_packet_old(AVFormatContext *s, 
AVPacket *pkt)
 pkt-pts = mxf-current_edit_unit;
 }
 } else if (codec-codec_type == AVMEDIA_TYPE_AUDIO) {
-int ret = mxf_set_audio_pts(mxf, codec, pkt);
+ret = mxf_set_audio_pts(mxf, codec, pkt);
 if (ret  0)
 return ret;
 }
-- 
1.8.5.1

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


[libav-devel] [PATCH 3/5] mxf: Handle identification metadata

2014-03-05 Thread Luca Barbato
From: Matthieu Bouron matthieu.bou...@gmail.com

Signed-off-by: Luca Barbato lu_z...@gentoo.org
---
 libavformat/mxfdec.c | 115 +++
 1 file changed, 115 insertions(+)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 8591f69..d8bfb46 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1618,6 +1618,120 @@ fail_and_free:
 return ret;
 }
 
+static int mxf_read_utf16_string(AVIOContext *pb, int size, char** str)
+{
+int ret;
+size_t buf_size;
+
+if (size  0)
+return AVERROR(EINVAL);
+
+buf_size = size + size / 2 + 1;
+*str = av_malloc(buf_size);
+if (!*str)
+return AVERROR(ENOMEM);
+
+if ((ret = avio_get_str16be(pb, size, *str, buf_size))  0) {
+av_freep(str);
+return ret;
+}
+
+return ret;
+}
+
+static int mxf_uid_to_str(UID uid, char **str)
+{
+int i;
+char *p;
+p = *str = av_mallocz(sizeof(UID) * 2 + 4 + 1);
+if (!p)
+return AVERROR(ENOMEM);
+for (i = 0; i  sizeof(UID); i++) {
+snprintf(p, 2 + 1, %.2x, uid[i]);
+p += 2;
+if (i == 3 || i == 5 || i == 7 || i == 9) {
+snprintf(p, 1 + 1, -);
+p++;
+}
+}
+return 0;
+}
+
+static int mxf_timestamp_to_str(uint64_t timestamp, char **str)
+{
+struct tm time = { 0 };
+time.tm_year = (timestamp  48) - 1900;
+time.tm_mon  = (timestamp  40  0xFF) - 1;
+time.tm_mday = (timestamp  32  0xFF);
+time.tm_hour = (timestamp  24  0xFF);
+time.tm_min  = (timestamp  16  0xFF);
+time.tm_sec  = (timestamp  8   0xFF);
+
+*str = av_mallocz(32);
+if (!*str)
+return AVERROR(ENOMEM);
+strftime(*str, 32, %Y-%m-%d %H:%M:%S, time);
+
+return 0;
+}
+
+#define SET_STR_METADATA(pb, name, str) do { \
+if ((ret = mxf_read_utf16_string(pb, size, str))  0) \
+return ret; \
+av_dict_set(s-metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
+} while (0)
+
+#define SET_UID_METADATA(pb, name, var, str) do { \
+avio_read(pb, var, 16); \
+if ((ret = mxf_uid_to_str(var, str))  0) \
+return ret; \
+av_dict_set(s-metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
+} while (0)
+
+#define SET_TS_METADATA(pb, name, var, str) do { \
+var = avio_rb64(pb); \
+if ((ret = mxf_timestamp_to_str(var, str))  0) \
+return ret; \
+av_dict_set(s-metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
+} while (0)
+
+static int mxf_read_identification_metadata(void *arg, AVIOContext *pb, int 
tag, int size, UID _uid, int64_t klv_offset)
+{
+MXFContext *mxf = arg;
+AVFormatContext *s = mxf-fc;
+int ret;
+UID uid = { 0 };
+char *str = NULL;
+uint64_t ts;
+switch (tag) {
+case 0x3C01:
+SET_STR_METADATA(pb, company_name, str);
+break;
+case 0x3C02:
+SET_STR_METADATA(pb, product_name, str);
+break;
+case 0x3C04:
+SET_STR_METADATA(pb, product_version, str);
+break;
+case 0x3C05:
+SET_UID_METADATA(pb, product_uid, uid, str);
+break;
+case 0x3C06:
+SET_TS_METADATA(pb, modification_date, ts, str);
+break;
+case 0x3C08:
+SET_STR_METADATA(pb, application_platform, str);
+break;
+case 0x3C09:
+SET_UID_METADATA(pb, generation_uid, uid, str);
+break;
+case 0x3C0A:
+SET_UID_METADATA(pb, uid, uid, str);
+break;
+}
+return 0;
+}
+
 static const MXFMetadataReadTableEntry mxf_metadata_read_table[] = {
 { { 
0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x05,0x01,0x00 
}, mxf_read_primer_pack },
 { { 
0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 
}, mxf_read_partition_pack },
@@ -1630,6 +1744,7 @@ static const MXFMetadataReadTableEntry 
mxf_metadata_read_table[] = {
 { { 
0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x04,0x00 
}, mxf_read_partition_pack },
 { { 
0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x02,0x00 
}, mxf_read_partition_pack },
 { { 
0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x04,0x00 
}, mxf_read_partition_pack },
+{ { 
0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x30,0x00 
}, mxf_read_identification_metadata },
 { { 
0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 
}, mxf_read_content_storage, 0, AnyType },
 { { 
0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x37,0x00 
}, mxf_read_source_package, sizeof(MXFPackage), SourcePackage },
 { { 
0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x36,0x00 
}, mxf_read_material_package, sizeof(MXFPackage), MaterialPackage },
-- 
1.8.5.1

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


[libav-devel] Pending mxf patches

2014-03-05 Thread Luca Barbato
After those I will try to make easier to hack this codebase in 
various ways e.g it is completely wasteful having 3 different
formats to describe 16 byte strings and none of them match the 
specifications.

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


[libav-devel] [PATCH 1/5] mxf: Introduce ff_mxf_get_samples_per_frame

2014-03-05 Thread Luca Barbato
From: Matthieu Bouron matthieu.bou...@gmail.com

Signed-off-by: Luca Barbato lu_z...@gentoo.org
---
 libavformat/mxf.c | 40 
 libavformat/mxf.h |  7 +++
 2 files changed, 47 insertions(+)

diff --git a/libavformat/mxf.c b/libavformat/mxf.c
index d3798cd..e99f31a 100644
--- a/libavformat/mxf.c
+++ b/libavformat/mxf.c
@@ -106,3 +106,43 @@ int ff_mxf_decode_pixel_layout(const char 
pixel_layout[16], enum AVPixelFormat *
 
 return -1;
 }
+
+static const MXFSamplesPerFrame mxf_spf[] = {
+{ { 1001, 24000 }, { 2002, 0,0,0,0,0 } }, // FILM 23.976
+{ { 1, 24},{ 2000, 0,0,0,0,0 } }, // FILM 24
+{ { 1001, 3 }, { 1602, 1601, 1602, 1601, 1602, 0 } }, // NTSC 29.97
+{ { 1001, 6 }, { 801,  801,  801,  801,  800,  0 } }, // NTSC 59.94
+{ { 1, 25 },   { 1920, 0,0,0,0,0 } }, // PAL 25
+{ { 1, 50 },   { 960,  0,0,0,0,0 } }, // PAL 50
+};
+
+static const AVRational mxf_time_base[] = {
+{ 1001, 24000 },
+{ 1, 24},
+{ 1001, 3 },
+{ 1001, 6 },
+{ 1, 25 },
+{ 1, 50 },
+{ 0, 0}
+};
+
+const MXFSamplesPerFrame *ff_mxf_get_samples_per_frame(AVFormatContext *s,
+   AVRational time_base)
+{
+int idx = av_find_nearest_q_idx(time_base, mxf_time_base);
+AVRational diff = av_sub_q(time_base, mxf_time_base[idx]);
+
+diff.num = abs(diff.num);
+
+if (av_cmp_q(diff, (AVRational){1, 1000})  0)
+return NULL;
+
+if (av_cmp_q(time_base, mxf_time_base[idx]))
+av_log(s, AV_LOG_WARNING,
+   %d/%d input time base matched %d/%d container time base\n,
+   time_base.num, time_base.den,
+   mxf_spf[idx].time_base.num,
+   mxf_spf[idx].time_base.den);
+
+return mxf_spf[idx];
+}
diff --git a/libavformat/mxf.h b/libavformat/mxf.h
index 773f30f..265b0cf 100644
--- a/libavformat/mxf.h
+++ b/libavformat/mxf.h
@@ -21,6 +21,7 @@
 #ifndef AVFORMAT_MXF_H
 #define AVFORMAT_MXF_H
 
+#include avformat.h
 #include libavcodec/avcodec.h
 #include stdint.h
 
@@ -66,11 +67,17 @@ typedef struct MXFCodecUL {
 int id;
 } MXFCodecUL;
 
+typedef struct MXFSamplesPerFrame {
+struct AVRational time_base;
+int samples_per_frame[6];
+} MXFSamplesPerFrame;
+
 extern const MXFCodecUL ff_mxf_data_definition_uls[];
 extern const MXFCodecUL ff_mxf_codec_uls[];
 extern const MXFCodecUL ff_mxf_pixel_format_uls[];
 
 int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat 
*pix_fmt);
+const MXFSamplesPerFrame *ff_mxf_get_samples_per_frame(AVFormatContext *s, 
AVRational time_base);
 
 #define PRINT_KEY(pc, s, x) av_dlog(pc, %s %02X %02X %02X %02X %02X %02X %02X 
%02X %02X %02X %02X %02X %02X %02X %02X %02X\n, s, \
  (x)[0], (x)[1], (x)[2], (x)[3], (x)[4], (x)[5], 
(x)[6], (x)[7], (x)[8], (x)[9], (x)[10], (x)[11], (x)[12], (x)[13], (x)[14], 
(x)[15])
-- 
1.8.5.1

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


[libav-devel] [PATCH 4/5] mxf: Parse random index pack

2014-03-05 Thread Luca Barbato
From: Paul B Mahol one...@gmail.com

Get the last partition offset and use it when footer partition
offset is missing.

Footer partition may not be present and even if present footer
partition offset may not be set in any partition except last one.

Signed-off-by: Luca Barbato lu_z...@gentoo.org
---
 libavformat/mxfdec.c | 54 
 1 file changed, 46 insertions(+), 8 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index d8bfb46..dcae26d 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -206,6 +206,7 @@ typedef struct {
 struct AVAES *aesc;
 uint8_t *local_tags;
 int local_tags_count;
+uint64_t last_partition;
 uint64_t footer_partition;
 KLVPacket current_klv_data;
 int current_klv_index;
@@ -245,6 +246,7 @@ static const uint8_t mxf_klv_key[] 
= { 0x06,0x0e,0x2b,0x
 static const uint8_t mxf_crypto_source_container_ul[]  = { 
0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x02,0x02,0x00,0x00,0x00 
};
 static const uint8_t mxf_encrypted_triplet_key[]   = { 
0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 
};
 static const uint8_t mxf_encrypted_essence_container[] = { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 
};
+static const uint8_t mxf_random_index_pack_key[]   = { 
0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0D,0x01,0x02,0x01,0x01,0x11,0x01,0x00 
};
 static const uint8_t mxf_sony_mpeg4_extradata[]= { 
0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 
};
 
 #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
@@ -1850,25 +1852,30 @@ static int mxf_parse_handle_essence(MXFContext *mxf)
 if (mxf-parsing_backward) {
 return mxf_seek_to_previous_partition(mxf);
 } else {
-if (!mxf-footer_partition) {
-av_dlog(mxf-fc, no footer\n);
+uint64_t offset = mxf-footer_partition ? mxf-footer_partition
+: mxf-last_partition;
+
+if (!offset) {
+av_dlog(mxf-fc, no last partition\n);
 return 0;
 }
 
-av_dlog(mxf-fc, seeking to footer\n);
+av_dlog(mxf-fc, seeking to last partition\n);
 
 /* remember where we were so we don't end up seeking further back than 
this */
 mxf-last_forward_tell = avio_tell(pb);
 
 if (!pb-seekable) {
-av_log(mxf-fc, AV_LOG_INFO, file is not seekable - not parsing 
footer\n);
+av_log(mxf-fc, AV_LOG_INFO, file is not seekable - not parsing 
last partition\n);
 return -1;
 }
 
-/* seek to footer partition and parse backward */
-if ((ret = avio_seek(pb, mxf-run_in + mxf-footer_partition, 
SEEK_SET))  0) {
-av_log(mxf-fc, AV_LOG_ERROR, failed to seek to footer @ 
0x%PRIx64 (%PRId64) - partial file?\n,
-   mxf-run_in + mxf-footer_partition, ret);
+/* seek to last partition and parse backward */
+if ((ret = avio_seek(pb, mxf-run_in + offset, SEEK_SET))  0) {
+av_log(mxf-fc, AV_LOG_ERROR,
+   failed to seek to last partition @ 0x% PRIx64
+(%PRId64) - partial file?\n,
+   mxf-run_in + offset, ret);
 return ret;
 }
 
@@ -1998,6 +2005,34 @@ static void mxf_handle_small_eubc(AVFormatContext *s)
 mxf-edit_units_per_packet = 1920;
 }
 
+static void mxf_read_random_index_pack(AVFormatContext *s)
+{
+MXFContext *mxf = s-priv_data;
+uint32_t length;
+int64_t file_size;
+KLVPacket klv;
+
+if (!s-pb-seekable)
+return;
+
+file_size = avio_size(s-pb);
+avio_seek(s-pb, file_size - 4, SEEK_SET);
+length = avio_rb32(s-pb);
+if (length = 32 || length = FFMIN(file_size, INT_MAX))
+goto end;
+avio_seek(s-pb, file_size - length, SEEK_SET);
+if (klv_read_packet(klv, s-pb)  0 ||
+!IS_KLV_KEY(klv.key, mxf_random_index_pack_key) ||
+klv.length != length - 20)
+goto end;
+
+avio_skip(s-pb, klv.length - 12);
+mxf-last_partition = avio_rb64(s-pb);
+
+end:
+avio_seek(s-pb, mxf-run_in, SEEK_SET);
+}
+
 static int mxf_read_header(AVFormatContext *s)
 {
 MXFContext *mxf = s-priv_data;
@@ -2016,7 +2051,10 @@ static int mxf_read_header(AVFormatContext *s)
 mxf-fc = s;
 mxf-run_in = avio_tell(s-pb);
 
+mxf_read_random_index_pack(s);
+
 while (!s-pb-eof_reached) {
+
 const MXFMetadataReadTableEntry *metadata;
 
 if (klv_read_packet(klv, s-pb)  0) {
-- 
1.8.5.1

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


Re: [libav-devel] [PATCH 10/12] mpegvideo: move ff_draw_horiz_band() in utils.c

2014-03-05 Thread Diego Biurrun
On Tue, Mar 04, 2014 at 07:24:40PM +0100, Vittorio Giovara wrote:
 ---
  libavcodec/internal.h  |  7 +++
  libavcodec/mpegvideo.c | 50 ---
  libavcodec/mpegvideo.h |  3 ---
  libavcodec/utils.c | 53 
 ++
  4 files changed, 60 insertions(+), 53 deletions(-)

move to

You move x from a to b.

The tiger moves in its cage.

 --- a/libavcodec/mpegvideo.c
 +++ b/libavcodec/mpegvideo.c
 @@ -2315,56 +2315,6 @@ void ff_MPV_decode_mb(MpegEncContext *s, int16_t 
 block[12][64]){
  /**
   * @param h is the normal height, this will be reduced automatically if 
 needed for the last row
   */
 -void ff_draw_horiz_band(AVCodecContext *avctx,
 -AVFrame *cur, AVFrame *last,
 -int y, int h, int picture_structure,
 -int first_field, int low_delay)
 -{
 -}
 -
  void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
  {
  ff_draw_horiz_band(s-avctx, s-current_picture.f,

The Doxygen comment suddenly applies to a different function.

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


Re: [libav-devel] [PATCH 3/4] float_dsp: add test program for float dsp

2014-03-05 Thread Diego Biurrun
On Tue, Mar 04, 2014 at 12:42:09AM +0100, Janne Grunau wrote:
 Not hooked up to FATE due to fear of random failures due to float
 instability.

Why don't you try it on Oracle?

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


Re: [libav-devel] [PATCH 3/4] float_dsp: add test program for float dsp

2014-03-05 Thread Anton Khirnov

On Tue,  4 Mar 2014 00:42:09 +0100, Janne Grunau janne-li...@jannau.net wrote:
 Not hooked up to FATE due to fear of random failures due to float
 instability.
 
 float_dsp-test: use 16 * 3 * 5 as length
 ---
  libavutil/Makefile|   1 +
  libavutil/float_dsp.c | 274 
 ++
  2 files changed, 275 insertions(+)
 
 diff --git a/libavutil/Makefile b/libavutil/Makefile
 index f663f18..5869e67 100644
 --- a/libavutil/Makefile
 +++ b/libavutil/Makefile
 @@ -122,6 +122,7 @@ TESTPROGS = adler32   
   \
  des \
  eval\
  fifo\
 +float_dsp   \
  hmac\
  lfg \
  lls \
 diff --git a/libavutil/float_dsp.c b/libavutil/float_dsp.c
 index 3707e06..22c3c15 100644
 --- a/libavutil/float_dsp.c
 +++ b/libavutil/float_dsp.c
 @@ -132,3 +132,277 @@ av_cold void avpriv_float_dsp_init(AVFloatDSPContext 
 *fdsp, int bit_exact)
  ff_float_dsp_init_x86(fdsp);
  #endif
  }
 +
 +#ifdef TEST
 +
 +#include float.h
 +#include math.h
 +#include stdint.h
 +#include string.h
 +
 +#include cpu.h
 +#include lfg.h
 +#include log.h
 +#include mem.h
 +#include random_seed.h
 +
 +#define LEN 240
 +
 +static void fill_float_array(AVLFG *lfg, float *a, int len)
 +{
 +int i;
 +double bmg[2], stddev = 10.0, mean = 0.0;
 +
 +for (i = 0; i  len; i += 2) {
 +av_bmg_get(lfg, bmg);
 +a[i] = bmg[0] * stddev + mean;
 +a[i + 1] = bmg[1] * stddev + mean;
 +}

Other than the excessive indentation here and below, the patch looks sane enough
to me

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


Re: [libav-devel] [PATCH 4/5] mxf: Parse random index pack

2014-03-05 Thread Anton Khirnov

On Wed,  5 Mar 2014 23:26:27 +0100, Luca Barbato lu_z...@gentoo.org wrote:
 From: Paul B Mahol one...@gmail.com
 
 Get the last partition offset and use it when footer partition
 offset is missing.
 
 Footer partition may not be present and even if present footer
 partition offset may not be set in any partition except last one.
 
 Signed-off-by: Luca Barbato lu_z...@gentoo.org
 ---

I've approved this one already, did you change anything?

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


Re: [libav-devel] [PATCH 5/5] mxf: Return meaningful errors

2014-03-05 Thread Anton Khirnov

On Wed,  5 Mar 2014 23:26:28 +0100, Luca Barbato lu_z...@gentoo.org wrote:
 ---
  libavformat/mxfdec.c | 21 -
  1 file changed, 12 insertions(+), 9 deletions(-)

This one has also been approved previously -- did you change anything?

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


Re: [libav-devel] [PATCH 1/5] mxf: Introduce ff_mxf_get_samples_per_frame

2014-03-05 Thread Anton Khirnov

On Wed,  5 Mar 2014 23:26:24 +0100, Luca Barbato lu_z...@gentoo.org wrote:
 From: Matthieu Bouron matthieu.bou...@gmail.com
 
 Signed-off-by: Luca Barbato lu_z...@gentoo.org
 ---
  libavformat/mxf.c | 40 
  libavformat/mxf.h |  7 +++
  2 files changed, 47 insertions(+)
 
 diff --git a/libavformat/mxf.c b/libavformat/mxf.c
 index d3798cd..e99f31a 100644
 --- a/libavformat/mxf.c
 +++ b/libavformat/mxf.c
 @@ -106,3 +106,43 @@ int ff_mxf_decode_pixel_layout(const char 
 pixel_layout[16], enum AVPixelFormat *
  
  return -1;
  }
 +
 +static const MXFSamplesPerFrame mxf_spf[] = {
 +{ { 1001, 24000 }, { 2002, 0,0,0,0,0 } }, // FILM 23.976
 +{ { 1, 24},{ 2000, 0,0,0,0,0 } }, // FILM 24
 +{ { 1001, 3 }, { 1602, 1601, 1602, 1601, 1602, 0 } }, // NTSC 29.97
 +{ { 1001, 6 }, { 801,  801,  801,  801,  800,  0 } }, // NTSC 59.94
 +{ { 1, 25 },   { 1920, 0,0,0,0,0 } }, // PAL 25
 +{ { 1, 50 },   { 960,  0,0,0,0,0 } }, // PAL 50
 +};
 +
 +static const AVRational mxf_time_base[] = {
 +{ 1001, 24000 },
 +{ 1, 24},
 +{ 1001, 3 },
 +{ 1001, 6 },
 +{ 1, 25 },
 +{ 1, 50 },
 +{ 0, 0}
 +};
 +
 +const MXFSamplesPerFrame *ff_mxf_get_samples_per_frame(AVFormatContext *s,
 +   AVRational time_base)
 +{
 +int idx = av_find_nearest_q_idx(time_base, mxf_time_base);
 +AVRational diff = av_sub_q(time_base, mxf_time_base[idx]);
 +
 +diff.num = abs(diff.num);
 +
 +if (av_cmp_q(diff, (AVRational){1, 1000})  0)

Shouldn't this be '' ?

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


Re: [libav-devel] [PATCH 2/5] mxf: Set audio packets pts

2014-03-05 Thread Anton Khirnov

On Wed,  5 Mar 2014 23:26:25 +0100, Luca Barbato lu_z...@gentoo.org wrote:
 From: Matthieu Bouron matthieu.bou...@gmail.com
 
 Extrapolate audio timestamps based on the number of samples demuxed.
 
 Deal with some MXF nastiness involving fractional number of
 samples per EditUnit when seeking (the specs handwave this away).
 
 Further fixes from Tomas Härdin.
 
 Signed-off-by: Luca Barbato lu_z...@gentoo.org
 ---

Did you change anything from the last version?

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

Re: [libav-devel] [PATCH 3/5] mxf: Handle identification metadata

2014-03-05 Thread Anton Khirnov

On Wed,  5 Mar 2014 23:26:26 +0100, Luca Barbato lu_z...@gentoo.org wrote:
 From: Matthieu Bouron matthieu.bou...@gmail.com
 
 Signed-off-by: Luca Barbato lu_z...@gentoo.org
 ---
  libavformat/mxfdec.c | 115 
 +++
  1 file changed, 115 insertions(+)
 

Did you change anything?

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


Re: [libav-devel] [PATCH 4/4] rtmppkt: Rename the ts_delta field to ts_field

2014-03-05 Thread Anton Khirnov

From a quick look there's nothing obviously wrong with the set.
So if you think it's ok, feel free to push.

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


[libav-devel] [PATCH] vf_shuffleplanes: fix the type of the mapping indices

2014-03-05 Thread Anton Khirnov
They are TYPE_INT AVOptions, so they must be ints
---
 libavfilter/vf_shuffleplanes.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_shuffleplanes.c b/libavfilter/vf_shuffleplanes.c
index 8422d2f..1bc77b0 100644
--- a/libavfilter/vf_shuffleplanes.c
+++ b/libavfilter/vf_shuffleplanes.c
@@ -34,7 +34,7 @@ typedef struct ShufflePlanesContext {
 int planes;
 
 /* mapping indices */
-uint8_t map[4];
+int map[4];
 
 /* set to 1 if some plane is used more than once, so we need to make a 
copy */
 int copy;
-- 
1.7.10.4

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


Re: [libav-devel] [RFC 3/3] lavf/http: import HTTP implementation from ffmpeg

2014-03-05 Thread Martin Storsjö

On Wed, 5 Mar 2014, Alessandro Ghedini wrote:


This patch imports the HTTP implementation from ffmpeg.

Incomplete list of new features and fixes:

* Support for HTTP seeking (intial ffmpeg commit e05655f)
* Custom user agent (initial ffmpeg commit 2bb1c71)
* Support for reading ICY metadata (initial ffmpeg commit a92fbe1)
* Support for reading and setting cookies (initial ffmpeg commit 0b80a12)
* Support for setting initial and ending offsets (initial ffmpeg commit 
d52882fa)
* Improve options descriptions (initial ffmpeg commit 255ec768)

Note that the commit ID specifies when the feature was originally introduced in
ffmpeg, but doesn't account for subsequent changes and fixes.

Bug-Debian: https://bugs.debian.org/740421
Bug-Debian: https://bugs.debian.org/739936


It would be appreciated if these could be split into one commit per 
feature (subsequent changes/fixes to that feature squashed into it) - it's 
really hard to review them when they're all batched together like this. I 
don't have time to do it myself right now, but if nobody else steps up to 
do it I might have time in a few days.


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