[FFmpeg-devel] A few filter questions

2014-07-17 Thread Gerion Entrup
Good day,

I'm currently working on a video signature filter for ffmpeg. This allows you 
to 
fingerprint videos.
This fingerprint is built up of 9mb/s of bits or 2-3 mb/s bits compressed.

In this context a few questions come into my mind:
- Should I print this whole bitstream to stdout/stderr at the end? Is it maybe 
a better choice to made an own stream out of this. But which type of stream 
this is?
  (btw, the video signature algorithm needs 90 following frames, so I can 
theoretically write every 90 frames something somewhere.)
- If I print the whole bitstream to stdout/stderr (my current implementation), 
is there a possibility to use this later in an external program? The only 
other globally analyze filter I found is volumedetect. This filter at the end 
prints per print_stats the calculated results to the console. Is there a 
possibility within the API for an external program to use these values or do I 
have to grep the output?
  A similar example is AcousticID (a fingerprinting technique for audio). 
Currently chromaprint (the AcousticID library) provides an executable (fpcalc) 
to calculate AcousticID. It therefore uses FFmpeg to decode the audio and then 
its own library to calculate the fingerprint. The better way I think would be 
to have an ffmpeg filter for this. But is it possibly to use the calculated 
number in an external program without grepping the output?

Another thing that came into my mind: Can filter force other filters to go into 
the filterchain? I see it, when I force GREY_8 only in my filter, it 
automatically enables the scale filter, too. The reason I asked is the lookup 
for my filter. Currently my filter analyzes a video and then produces a lot of 
numbers. To compare two videos and decide, wheather they match or not, these 
numbers has to be compared. I see three possibilities:
1. Write an VV-V filter. Reimplement (copy) the code from the V-V signature 
filter and give a boolean as output (match or match not).
2. Take the V-V filter and write a python (or whatever) script that fetch the 
output and calculates then the rest.
3. Write an VV-V filter, but enforce, that the normal signature filter is 
executed first to both streams, use the result and then calculate the matching 
type. Unfortunately I have no idea, how to do this and whether it is possible 
at all. Can you give me an advice?

The last possibility also would allow something like twopass volume 
normalisation. Currently there is a volumedetect and volume filter. To 
normalize once could run volumedetect, then fetch the output, and put the 
values into the volume filter, but I currently don't see a way to do this 
automatically directly in ffmpeg.

(Once the filter is in a good state, I will try to bring it upstream.)

Best,
Gerion

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


Re: [FFmpeg-devel] A few filter questions

2014-07-17 Thread Clément Bœsch
On Thu, Jul 17, 2014 at 12:33:41PM +0200, Gerion Entrup wrote:
 Good day,
 
 I'm currently working on a video signature filter for ffmpeg. This allows you 
 to 
 fingerprint videos.

Oh, nice.

 This fingerprint is built up of 9mb/s of bits or 2-3 mb/s bits compressed.
 
 In this context a few questions come into my mind:
 - Should I print this whole bitstream to stdout/stderr at the end? Is it 
 maybe 
 a better choice to made an own stream out of this. But which type of stream 
 this is?

How does the fingerprint looks like? Could it make sense as a gray video
output fractal, or maybe some kind of audio signal?

Also, you still have the string metadata possibility (git grep SET_META
libavfilter).

   (btw, the video signature algorithm needs 90 following frames, so I can 
 theoretically write every 90 frames something somewhere.)

Do you cache all these frames or just update your caches/stats  drop
them?

 - If I print the whole bitstream to stdout/stderr (my current 
 implementation), 
 is there a possibility to use this later in an external program? The only 
 other globally analyze filter I found is volumedetect. This filter at the end 
 prints per print_stats the calculated results to the console. Is there a 
 possibility within the API for an external program to use these values or do 
 I 
 have to grep the output?

stdout/stderr really isn't a good thing. Using metadata is way better
because you can output them from ffprobe, and parse them according to
various outputs (XML, CSV, JSON, ...).

Another solution I can now think of is to simply pass an output file as
option to the filter. That's typically how we do the 2-pass thing with
vidstab filter.

[...]
 Another thing that came into my mind: Can filter force other filters to go 
 into 
 the filterchain? I see it, when I force GREY_8 only in my filter, it 
 automatically enables the scale filter, too.

Some filter are inserted automatically for conversion  constraints, but
that's not decided by the filters but the framework itself.

  The reason I asked is the lookup 
 for my filter. Currently my filter analyzes a video and then produces a lot 
 of 
 numbers. To compare two videos and decide, wheather they match or not, these 
 numbers has to be compared. I see three possibilities:
 1. Write an VV-V filter. Reimplement (copy) the code from the V-V signature 
 filter and give a boolean as output (match or match not).
 2. Take the V-V filter and write a python (or whatever) script that fetch 
 the 
 output and calculates then the rest.
 3. Write an VV-V filter, but enforce, that the normal signature filter is 
 executed first to both streams, use the result and then calculate the 
 matching 
 type. Unfortunately I have no idea, how to do this and whether it is possible 
 at all. Can you give me an advice?
 

So if you output a file in the filter itself:
  ffmpeg -i video   -vf fingerprint=video.sig -f null -
  ffmpeg -i another -vf fingerprint=video.sig:check=1 -f null -

Or if you save the signature stream in a video (in gray8 for instance):
  ffmpeg -i video   -vf fingerprint -c:v ffv1 sig.nut
  ffmpeg -i another -i sig.nut -vf '[0][1] fingerprint=mode=check' -f null -

The 2nd method is better because it doesn't require file handling in the
library, and it also allows stuff like using a diff filter (if you also
apply fingerprint - not with mode=check - on `another`)

Am I understanding right your wondering?

 The last possibility also would allow something like twopass volume 
 normalisation. Currently there is a volumedetect and volume filter. To 
 normalize once could run volumedetect, then fetch the output, and put the 
 values into the volume filter, but I currently don't see a way to do this 
 automatically directly in ffmpeg.

Check tools/normalize.py, it's using ebur128 and the metadata system.

 
 (Once the filter is in a good state, I will try to bring it upstream.)
 

Cool

 Best,
 Gerion
 

-- 
Clément B.


pgpIUcBGsdmql.pgp
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavu/eval: add clip function

2014-07-17 Thread Stefano Sabatini
On date Monday 2014-07-07 20:58:50 +0200, Michael Niedermayer encoded:
 On Fri, Jul 04, 2014 at 04:40:50PM +0200, Stefano Sabatini wrote:
[...]
  Subject: [PATCH] lavu/eval: add clip function
  
  TODO: bump micro
  ---
   doc/utils.texi  |  3 +++
   libavutil/eval.c| 14 +-
   tests/ref/fate/eval |  9 +
   3 files changed, 25 insertions(+), 1 deletion(-)
  
  diff --git a/doc/utils.texi b/doc/utils.texi
  index 5abfb0c..b92691f 100644
  --- a/doc/utils.texi
  +++ b/doc/utils.texi
  @@ -782,6 +782,9 @@ large numbers (usually 2^53 and larger).
   Round the value of expression @var{expr} upwards to the nearest
   integer. For example, ceil(1.5) is 2.0.
   
  +@item clip(x, min, max)
  +Return the value of @var{x} clipped between @var{min} and @var{max}.
  +
   @item cos(x)
   Compute cosine of @var{x}.
   
  diff --git a/libavutil/eval.c b/libavutil/eval.c
  index 4a313bf..1c53b79 100644
  --- a/libavutil/eval.c
  +++ b/libavutil/eval.c
  @@ -147,7 +147,7 @@ struct AVExpr {
   e_pow, e_mul, e_div, e_add,
   e_last, e_st, e_while, e_taylor, e_root, e_floor, e_ceil, e_trunc,
   e_sqrt, e_not, e_random, e_hypot, e_gcd,
  -e_if, e_ifnot, e_print, e_bitand, e_bitor, e_between,
  +e_if, e_ifnot, e_print, e_bitand, e_bitor, e_between, e_clip
   } type;
   double value; // is sign in other types
   union {
  @@ -187,6 +187,13 @@ static double eval_expr(Parser *p, AVExpr *e)
 e-param[2] ? eval_expr(p, 
  e-param[2]) : 0);
   case e_ifnot:  return e-value * (!eval_expr(p, e-param[0]) ? 
  eval_expr(p, e-param[1]) :
 e-param[2] ? eval_expr(p, 
  e-param[2]) : 0);
  +case e_clip: {
  +double x = eval_expr(p, e-param[0]);
  +double min = eval_expr(p, e-param[1]), max = eval_expr(p, 
  e-param[2]);
  +if (isnan(min) || isnan(max) || isnan(x) || min  max)
  +return NAN;
 
  +return e-value * av_clip(eval_expr(p, e-param[0]), min, max);
 
 this should be av_clipd()
 
 should be ok otherwise

Applied, thanks.
-- 
FFmpeg = Frenzy  Fantastic Meaningful Plastic Ephemeral Game
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] drawtext: add expansion function eif()

2014-07-17 Thread Stefano Sabatini
On date Sunday 2014-07-06 13:46:31 +0300, Andrey Utkin encoded:
 2014-07-05 16:19 GMT+03:00 Nicolas George geo...@nsup.org:
  Le sextidi 16 messidor, an CCXXII, Andrey Utkin a écrit :
  +@item eif
 
  I find the name obscure. Where does it come from?
 
 Yes, it is somewhat obscure. It comes from expr_int_format.
 
  +if (!strchr(xXdu, argv[1][0])) {
 
  You should probably check that argv[1][1] is 0.
 
 Can be added to check for stray trailing symbols in passed argument,
 but this doesn't affect the algorithm, it uses only first character.
 
  +feclearexcept(FE_ALL_EXCEPT);
  +intval = res;
  +if ((ret = fetestexcept(FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW))) {
  +av_log(ctx, AV_LOG_ERROR, Conversion of floating-point result to 
  int failed. Control register: 0x%08x. Conversion result: %d\n, ret, 
  intval);
  +return AVERROR(EINVAL);
 
  Is this portable enough? Anyway, AFAIK, we never do that kind of test in the
  code.
 
 This must be coming from C standard. I consulted with this CERT C
 Secure Coding Standards chapter:
 https://www.securecoding.cert.org/confluence/display/seccode/FLP03-C.+Detect+and+handle+floating-point+errors

Patch applied, further tweaking can be done later.
-- 
FFmpeg = Freak and Frenzy Mean Powerful Enchanting God
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/2 v2] drawtext: add fontcolor_expr

2014-07-17 Thread Stefano Sabatini
On date Saturday 2014-07-05 11:59:35 +0200, Stefano Sabatini encoded:
 On date Friday 2014-07-04 21:54:53 +0300, Andrey Utkin encoded:
  An option for fontcolor, dynamically evaluated
  ---
   doc/filters.texi  | 16 
   libavfilter/vf_drawtext.c | 26 +-
   2 files changed, 37 insertions(+), 5 deletions(-)
 
 No more comments from me, I'll apply both drawtext patches if I see no
 comments from other developers in 1/2 days, thank you.

Applied.
-- 
FFmpeg = Faithless Fancy Majestic Political Elastic God
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/dv: implement fallback in dv_extract_pack()

2014-07-17 Thread Dave Rice
On Jul 16, 2014, at 10:57 PM, Michael Niedermayer michae...@gmx.at wrote:

 Fixes Ticket2340
 Fixes Ticket2341

I tested with the samples from tickets 2340 and 2341. In both cases the patch 
fixes the originally reported issue. Thanks!
Dave Rice
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/dv: implement fallback in dv_extract_pack()

2014-07-17 Thread Michael Niedermayer
On Thu, Jul 17, 2014 at 07:37:58AM -0400, Dave Rice wrote:
 On Jul 16, 2014, at 10:57 PM, Michael Niedermayer michae...@gmx.at wrote:
 
  Fixes Ticket2340
  Fixes Ticket2341
 
 I tested with the samples from tickets 2340 and 2341. In both cases the patch 
 fixes the originally reported issue. Thanks!

applied

thx

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

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


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


Re: [FFmpeg-devel] Issue 3052

2014-07-17 Thread Benoit Fouet
Hi,

- Mail original -
 On Wed, Jul 16, 2014 at 05:40:35PM +0200, Benoit Fouet wrote:
  
  
  - Mail original -
   Hi,
   
   I had a look at https://trac.ffmpeg.org/ticket/3052.
   The issue is that the last frame duration is lost. Is there any
   reason why the packet duration is not transmitted from the
   demuxer
   to the muxer?
   Attached is a dumb patch, just to understand a bit more why
   things
   are done the way they are...
   
  
  e.g., by dumb, I mean that the duration should be corrected with
  the right timebase... But I just want to get feedback on the
  forwarding part.
 
 pkt_duration and pkt_timebase where primarly intended for the decoder
 side, they could be used for encoder too but i guess filters dont
 update them currently
 

I'll try to address the filter case as a separate issue anyway, so this 
shouldn't be an issue; at least for now.

 that is:
 
 @@ -2063,6 +2063,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
  avpkt-size = 0;
  else if (!(avctx-codec-capabilities  CODEC_CAP_DELAY))
  avpkt-pts = avpkt-dts = frame-pts;
 +if (frame  av_codec_get_pkt_timebase(avctx).num)
 +avpkt-duration =
 av_rescale_q(av_frame_get_pkt_duration(frame),
 +
   av_codec_get_pkt_timebase(avctx),
 +   avctx-time_base);
 
  if (needs_realloc  avpkt-data) {
  ret = av_buffer_realloc(avpkt-buf, avpkt-size +
  FF_INPUT_BUFFER_PADDING_SIZE);
 

I'll try to add the time_base in the AVFrame then, so that the information is 
there with the duration.
I should post a patch soon to do this, and test it on the GIF issue from issue 
3052

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


Re: [FFmpeg-devel] Issue 3052

2014-07-17 Thread Nicolas George
L'octidi 28 messidor, an CCXXII, Michael Niedermayer a écrit :
 again, i suspect this is not updated by filters currently

You are right, the filters do not update them currently.

I believe changing that policy would not be a convenient way of solving that
issue: the duration information raises consistency problems: what happens if
next_frame-pts is not equal to cur_frame-pts + cur_frame-duration.

Also, that would be abusing a field, since pkt_duration is the duration of a
packet, not a frame.

I believe a better solution would be to send EOF pseudo-frames forward in
the filter chain instead of relying on the backward request_frame() calls to
return EOF: it would solve this particular issue (a pseudo-frame has a
timestamp) and other issues as well.

This is one of the main things I intend to look at during this summer.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] A few filter questions

2014-07-17 Thread Gerion Entrup
Am Donnerstag 17 Juli 2014, 13:00:13 schrieb Clément Bœsch:
 On Thu, Jul 17, 2014 at 12:33:41PM +0200, Gerion Entrup wrote:
  Good day,
  
  I'm currently working on a video signature filter for ffmpeg. This allows
  you to fingerprint videos.
 
 Oh, nice.
 
  This fingerprint is built up of 9mb/s of bits or 2-3 mb/s bits compressed.
Argh, fail, sorry. I meant: 9mb per hour of video (and 2-3 mb per hour).
  
  In this context a few questions come into my mind:
  - Should I print this whole bitstream to stdout/stderr at the end? Is it
  maybe a better choice to made an own stream out of this. But which type
  of stream this is?
 
 How does the fingerprint looks like? Could it make sense as a gray video
 output fractal, or maybe some kind of audio signal?
There a finesignatures per frame and coursesignatures per 90 finesignatures.
coursesignature are binarized histograms (0 or 1 possible as count).
finesignature is mainly a vector of 380 difference values between -128 and 127 
which are ternarized into 0 1 or 2.
(See the MPEG-7 Standard for more details).

I doubt, this is a good video or audio stream.
Definitely, interpreting this as video make sense in some way, but metadata 
looks more useful.

 
 Also, you still have the string metadata possibility (git grep SET_META
 libavfilter).
Hmm, thank you, I will take a look at it. If I see it right, it is used to fill 
a dictionary per frame with some kind of data?

 
(btw, the video signature algorithm needs 90 following frames, so I can
  
  theoretically write every 90 frames something somewhere.)
 
 Do you cache all these frames or just update your caches/stats  drop
 them?
ATM I don't cache the frames, but the whole signature. As said above, the 
coursesignatures (the part, which needs the 90 frames) is calculated only from 
the finesignatures (the finesignatures are cached, anyway).
 
  - If I print the whole bitstream to stdout/stderr (my current
  implementation), is there a possibility to use this later in an external
  program? The only other globally analyze filter I found is volumedetect.
  This filter at the end prints per print_stats the calculated results to
  the console. Is there a possibility within the API for an external
  program to use these values or do I have to grep the output?
 
 stdout/stderr really isn't a good thing. Using metadata is way better
 because you can output them from ffprobe, and parse them according to
 various outputs (XML, CSV, JSON, ...).
Sounds good…
 
 Another solution I can now think of is to simply pass an output file as
 option to the filter. That's typically how we do the 2-pass thing with
 vidstab filter.
I don't like output files. If you want to write a program, that performs a 
lookup to signatures somewhere stored in a database and this program uses 
ffmpeg internally and then always has to write a file and read it again, it's 
not that elegant.
(btw, an example for such a program is Musicbrainz Picard, but for AcousticID 
;))
 
 [...]
 
  Another thing that came into my mind: Can filter force other filters to go
  into the filterchain? I see it, when I force GREY_8 only in my filter, it
  automatically enables the scale filter, too.
 
 Some filter are inserted automatically for conversion  constraints, but
 that's not decided by the filters but the framework itself.
 
   The reason I asked is the
   lookup
  
  for my filter. Currently my filter analyzes a video and then produces a
  lot of numbers. To compare two videos and decide, wheather they match or
  not, these numbers has to be compared. I see three possibilities:
  1. Write an VV-V filter. Reimplement (copy) the code from the V-V
  signature filter and give a boolean as output (match or match not).
  2. Take the V-V filter and write a python (or whatever) script that fetch
  the output and calculates then the rest.
  3. Write an VV-V filter, but enforce, that the normal signature filter is
  executed first to both streams, use the result and then calculate the
  matching type. Unfortunately I have no idea, how to do this and whether
  it is possible at all. Can you give me an advice?
 
 So if you output a file in the filter itself:
   ffmpeg -i video   -vf fingerprint=video.sig -f null -
   ffmpeg -i another -vf fingerprint=video.sig:check=1 -f null -
 
 Or if you save the signature stream in a video (in gray8 for instance):
   ffmpeg -i video   -vf fingerprint -c:v ffv1 sig.nut
   ffmpeg -i another -i sig.nut -vf '[0][1] fingerprint=mode=check' -f null -
 
 The 2nd method is better because it doesn't require file handling in the
 library, and it also allows stuff like using a diff filter (if you also
 apply fingerprint - not with mode=check - on `another`)
 
 Am I understanding right your wondering?
No ;), but anyway thanks for your answer. In your 2nd method your filter is a 
VV-V filter? Am I right, that this filter then also can take only one stream? 

Re: [FFmpeg-devel] [PATCH] lavf/segment: only use reference frames for computing the segment end time

2014-07-17 Thread Stefano Sabatini
On date Thursday 2014-07-17 16:25:26 +0200, Michael Niedermayer encoded:
 On Thu, Jul 17, 2014 at 02:53:43PM +0200, Stefano Sabatini wrote:
  This avoids a systematic overestimate of the segments duration when there
  are several streams.
  
  Fix trac ticket #3724.
  ---
   libavformat/segment.c | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
 
 probably ok

Thanks, applied.
-- 
FFmpeg = Fascinating and Frightening Mere Purposeless Enhanced Glue
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] A few filter questions

2014-07-17 Thread Clément Bœsch
On Thu, Jul 17, 2014 at 04:56:08PM +0200, Gerion Entrup wrote:
[...]
  Also, you still have the string metadata possibility (git grep SET_META
  libavfilter).
 Hmm, thank you, I will take a look at it. If I see it right, it is used to 
 fill 
 a dictionary per frame with some kind of data?
 

Strings only, so you'll have to find a serialization somehow. Maybe simply
an ascii hex string or something. But yeah, it just allows you to map some
key → value string couples to the frames passing by in the filter.

How huge is the information to store per frame?

[...]
  stdout/stderr really isn't a good thing. Using metadata is way better
  because you can output them from ffprobe, and parse them according to
  various outputs (XML, CSV, JSON, ...).
 Sounds good…

tools/normalize.py make use of such feature if you want examples (that's
the -of option of ffprobe)

[...]
  Am I understanding right your wondering?
 No ;), but anyway thanks for your answer. In your 2nd method your filter is a 
 VV-V filter? Am I right, that this filter then also can take only one 
 stream? 
 Said in another way: Can a VV-V filter also behave as a V-V filter?

Yes, fieldmatch is a (complex) example of this. But typically it's simply
a filter with dynamic inputs, based on the user input. The simplest
example would be the split filter. Look at it for an example of dynamic
allocation of the number of inputs based on the user input (-vf split=4 is
a V- filter)

[...]
  Check tools/normalize.py, it's using ebur128 and the metadata system.
 Thats what I mean. Someone has to write an external script, which calls 
 ffmpeg/ffprobe two times, parse stdout of the first call and pass it to the 
 filteroptions of the second call. As I see, there is no direct way. Something 
 like:
 ffmpeg -i foo -f:a volume=mode=autodetect normalized.opus

We add a discussion several time for real time with that filter. If we do
a 2-pass, that's simply because it's more efficient. Typically, doing
some live normalization can be done easily (we had patches for this):
ebur128 already attaches some metadata to frames, so a following filter
such as volume could reuse them, something like -filter_complex
ebur128=metadata=1,volume=metadata.

[...]

-- 
Clément B.


pgporzFGKSof0.pgp
Description: PGP signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavfi: check refcount before merging.

2014-07-17 Thread Nicolas George
Le septidi 27 messidor, an CCXXII, Michael Niedermayer a écrit :
 LGTM

Thanks. Then please merge the following commits from my tree:

a65c0a3 lavd/x11grab: disable drawing mouse without XFixes.
36fbe3c lavd/x11grab: change error code for unsupported visuals.
16c6795 lavd/x11grab: check 32-bits color masks.
1d12df1 lavd/x11grab: add an option to disable MIT-SHM.
099aff5 lavfi: check refcount before merging.
8e29768 lavd/x11grab: reindent after last commit.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] A few filter questions

2014-07-17 Thread Nicolas George
Le nonidi 29 messidor, an CCXXII, Clément Bœsch a écrit :
 We add a discussion several time for real time with that filter. If we do
 a 2-pass, that's simply because it's more efficient. Typically, doing
 some live normalization can be done easily (we had patches for this):
 ebur128 already attaches some metadata to frames, so a following filter
 such as volume could reuse them, something like -filter_complex
 ebur128=metadata=1,volume=metadata.

I believe you are wrong in this paragraph: we do two passes for
normalization because that is the only way of doing it without distortions:
the level of volume adjustment depends on the whole stream.

Normalization can be done in a single pass with distortions, but currently,
no filter is capable of smoothing the measures computed by ebur128 to make
the distortions inaudible. Patch welcome.

Regards,

-- 
  Nicolas George


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


[FFmpeg-devel] [PATCH] lavf/segment: sanitize segment end time in case last packet didn't have a defined duration

2014-07-17 Thread Stefano Sabatini
In particular, avoids to set segments with a 0 duration (e.g. segment
with a single reference frame for which duration is undefined).
---
 libavformat/segment.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index db932f7..33a5558 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -48,6 +48,7 @@ typedef struct SegmentListEntry {
 int64_t offset_pts;
 char *filename;
 struct SegmentListEntry *next;
+int64_t last_duration;
 } SegmentListEntry;
 
 typedef enum {
@@ -720,6 +721,10 @@ static int seg_write_packet(AVFormatContext *s, AVPacket 
*pkt)
  (pkt-pts != AV_NOPTS_VALUE 
   av_compare_ts(pkt-pts, st-time_base,
 end_pts-seg-time_delta, AV_TIME_BASE_Q) = 0))) {
+/* sanitize end time in case last packet didn't have a defined 
duration */
+if (seg-cur_entry.last_duration == 0)
+seg-cur_entry.end_time = (double)pkt-pts * av_q2d(st-time_base);
+
 if ((ret = segment_end(s, seg-individual_header_trailer, 0))  0)
 goto fail;
 
@@ -735,6 +740,7 @@ static int seg_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 } else if (pkt-pts != AV_NOPTS_VALUE  pkt-stream_index == 
seg-reference_stream_index) {
 seg-cur_entry.end_time =
 FFMAX(seg-cur_entry.end_time, (double)(pkt-pts + pkt-duration) 
* av_q2d(st-time_base));
+seg-cur_entry.last_duration = pkt-duration;
 }
 
 if (seg-segment_frame_count == 0) {
-- 
1.8.3.2

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


Re: [FFmpeg-devel] [PATCH]Ignore xing number of frames if filesize is wrong

2014-07-17 Thread Nicolas George
Le nonidi 29 messidor, an CCXXII, Carl Eugen Hoyos a écrit :
 Hi!
 
 Attached patch fixes ticket #3777 for me, analyzed by Oliver Fromme.
 
 Please comment, Carl Eugen

 diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
 index 8335388..cdef6d9 100644
 --- a/libavformat/mp3dec.c
 +++ b/libavformat/mp3dec.c
 @@ -138,6 +138,7 @@ static void mp3_parse_info_tag(AVFormatContext *s, 
 AVStream *st,
  
  MP3DecContext *mp3 = s-priv_data;
  static const int64_t xing_offtbl[2][2] = {{32, 17}, {17,9}};
 +int64_t fsize = avio_size(s-pb);
  
  /* Check for Xing / Info tag */
  avio_skip(s-pb, xing_offtbl[c-lsf == 1][c-nb_channels == 1]);
 @@ -151,6 +152,9 @@ static void mp3_parse_info_tag(AVFormatContext *s, 
 AVStream *st,
  mp3-frames = avio_rb32(s-pb);
  if (v  XING_FLAG_SIZE)
  mp3-header_filesize = avio_rb32(s-pb);

 +if (fsize  0  mp3-header_filesize  0 
 +FFABS(fsize - (int64_t)mp3-header_filesize) / (float)FFMIN(fsize, 
 mp3-header_filesize)  0.05)

I would suggest to avoid floating point arithmetic if possible. Possibly
something like that:

uint64_t min = FFMIN(fsize, mp3-header_filesize);
uint64_t delta = FFMAX(fsize, mp3-header_filesize) - min;
uint64_t tolerance = min / 20;
if (...  min - tolerance  2 * tolerance)

I also find this version easier to understand.

And in any case, someone may correct me, but I believe nowadays double
should always preferred to float unless you need a lot of them and want to
reduce the memory use.

I can not judge on the correctness, though.

 +mp3-frames = 0;
  if (v  XING_FLAG_TOC)
  read_xing_toc(s, mp3-header_filesize, av_rescale_q(mp3-frames,
 (AVRational){spf, c-sample_rate},

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH 1/2] drawtext: add expansion function eif()

2014-07-17 Thread Andrey Utkin
Damn, was just going to resubmit :( However, the only change was to
add more comprehensive alias expr_int_format. Do you think it's
worth to submit such addition?

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


Re: [FFmpeg-devel] [PATCH 1/2] drawtext: add expansion function eif()

2014-07-17 Thread Stefano Sabatini
On date Thursday 2014-07-17 23:38:42 +0300, Andrey Utkin encoded:
 Damn, was just going to resubmit :( However, the only change was to
 add more comprehensive alias expr_int_format. Do you think it's
 worth to submit such addition?

Sure. Also since the patch was committed just today, feel free to send
changes which could affect the interface (the sooner the better).
-- 
FFmpeg = Fostering and Fanciful Merciless Portable Erroneous Guru
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]Ignore xing number of frames if filesize is wrong

2014-07-17 Thread Carl Eugen Hoyos
On Thursday 17 July 2014 09:41:40 pm Nicolas George wrote:
 Le nonidi 29 messidor, an CCXXII, Carl Eugen Hoyos a écrit :
 
  Attached patch fixes ticket #3777 for me, analyzed by Oliver 
  Fromme. 

 I would suggest to avoid floating point arithmetic if possible. 
 Possibly something like that:

 uint64_t min = FFMIN(fsize, mp3-header_filesize);
 uint64_t delta = FFMAX(fsize, mp3-header_filesize) - min;
 uint64_t tolerance = min / 20;
 if (...  min - tolerance  2 * tolerance)

 I also find this version easier to understand.

Thank you, new patch attached.

 I can not judge on the correctness, though.

The logic is copied from asfdec.c.

Please review, Carl Eugen
diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
index 8335388..cf5aa73 100644
--- a/libavformat/mp3dec.c
+++ b/libavformat/mp3dec.c
@@ -138,6 +138,7 @@ static void mp3_parse_info_tag(AVFormatContext *s, AVStream 
*st,
 
 MP3DecContext *mp3 = s-priv_data;
 static const int64_t xing_offtbl[2][2] = {{32, 17}, {17,9}};
+uint64_t min, delta, fsize = avio_size(s-pb);
 
 /* Check for Xing / Info tag */
 avio_skip(s-pb, xing_offtbl[c-lsf == 1][c-nb_channels == 1]);
@@ -151,6 +152,10 @@ static void mp3_parse_info_tag(AVFormatContext *s, 
AVStream *st,
 mp3-frames = avio_rb32(s-pb);
 if (v  XING_FLAG_SIZE)
 mp3-header_filesize = avio_rb32(s-pb);
+min = FFMIN(fsize, mp3-header_filesize);
+delta = FFMAX(fsize, mp3-header_filesize) - min;
+if (fsize  mp3-header_filesize  0  delta  min  4)
+mp3-frames = 0;
 if (v  XING_FLAG_TOC)
 read_xing_toc(s, mp3-header_filesize, av_rescale_q(mp3-frames,
(AVRational){spf, c-sample_rate},
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]Ignore xing number of frames if filesize is wrong

2014-07-17 Thread Nicolas George
Le nonidi 29 messidor, an CCXXII, Carl Eugen Hoyos a écrit :
  if (...  min - tolerance  2 * tolerance)
   ^^^   ^^^
This bit was a leftover from a slightly different version I tried at first,
it was wrong.

  I also find this version easier to understand.
 
 Thank you, new patch attached.
 
  I can not judge on the correctness, though.
 
 The logic is copied from asfdec.c.
 
 Please review, Carl Eugen

 diff --git a/libavformat/mp3dec.c b/libavformat/mp3dec.c
 index 8335388..cf5aa73 100644
 --- a/libavformat/mp3dec.c
 +++ b/libavformat/mp3dec.c
 @@ -138,6 +138,7 @@ static void mp3_parse_info_tag(AVFormatContext *s, 
 AVStream *st,
  
  MP3DecContext *mp3 = s-priv_data;
  static const int64_t xing_offtbl[2][2] = {{32, 17}, {17,9}};
 +uint64_t min, delta, fsize = avio_size(s-pb);
  
  /* Check for Xing / Info tag */
  avio_skip(s-pb, xing_offtbl[c-lsf == 1][c-nb_channels == 1]);
 @@ -151,6 +152,10 @@ static void mp3_parse_info_tag(AVFormatContext *s, 
 AVStream *st,
  mp3-frames = avio_rb32(s-pb);
  if (v  XING_FLAG_SIZE)
  mp3-header_filesize = avio_rb32(s-pb);
 +min = FFMIN(fsize, mp3-header_filesize);
 +delta = FFMAX(fsize, mp3-header_filesize) - min;
 +if (fsize  mp3-header_filesize  0  delta  min  4)
 +mp3-frames = 0;
  if (v  XING_FLAG_TOC)
  read_xing_toc(s, mp3-header_filesize, av_rescale_q(mp3-frames,
 (AVRational){spf, c-sample_rate},

No more remarks from me, but I do not maintain that part of the code.
Thanks.

Regards,

-- 
  Nicolas George


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


[FFmpeg-devel] [PATCH] lavfi/drawtext: add alias expr_int_format to expansion function eif

2014-07-17 Thread Andrey Utkin
---
 doc/filters.texi  | 2 +-
 libavfilter/vf_drawtext.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index 8cde277..a7919a3 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -3916,7 +3916,7 @@ example the text size is not known when evaluating the 
expression, so
 the constants @var{text_w} and @var{text_h} will have an undefined
 value.
 
-@item eif
+@item expr_int_format, eif
 Evaluate the expression's value and output as formatted integer.
 
 First argument is expression to be evaluated, same as for @var{expr} function.
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index c744d93..b7a295f 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -949,7 +949,7 @@ static int func_eval_expr_int_format(AVFilterContext *ctx, 
AVBPrint *bp,
 if (argc == 3) {
 ret = sscanf(argv[2], %u, positions);
 if (ret != 1) {
-av_log(ctx, AV_LOG_ERROR, eif(): Invalid number of positions
+av_log(ctx, AV_LOG_ERROR, expr_int_format(): Invalid number of 
positions
  to print: '%s'\n, argv[2]);
 return AVERROR(EINVAL);
 }
@@ -982,6 +982,7 @@ static const struct drawtext_function {
 } functions[] = {
 { expr,  1, 1, 0,   func_eval_expr },
 { e, 1, 1, 0,   func_eval_expr },
+{ expr_int_format, 2, 3, 0, func_eval_expr_int_format },
 { eif,   2, 3, 0,   func_eval_expr_int_format },
 { pict_type, 0, 0, 0,   func_pict_type },
 { pts,   0, 2, 0,   func_pts  },
-- 
1.8.5.5

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


Re: [FFmpeg-devel] [PATCH] lavfi/drawtext: add alias expr_int_format to expansion function eif

2014-07-17 Thread Nicolas George
Le decadi 30 messidor, an CCXXII, Andrey Utkin a écrit :
 ---
  doc/filters.texi  | 2 +-
  libavfilter/vf_drawtext.c | 3 ++-
  2 files changed, 3 insertions(+), 2 deletions(-)

IMHO, since the function was added extremely recently, it is ok to just
change the name.

May I suggest: format_expr()? That way, if somebody extends it to accept
more versatile format strings, including floats, the name still works.

Regards,

-- 
  Nicolas George


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


Re: [FFmpeg-devel] [PATCH] lavfi/drawtext: add alias expr_int_format to expansion function eif

2014-07-17 Thread Andrey Utkin
2014-07-18 1:05 GMT+03:00 Nicolas George geo...@nsup.org:
 Le decadi 30 messidor, an CCXXII, Andrey Utkin a écrit :
 ---
  doc/filters.texi  | 2 +-
  libavfilter/vf_drawtext.c | 3 ++-
  2 files changed, 3 insertions(+), 2 deletions(-)

 IMHO, since the function was added extremely recently, it is ok to just
 change the name.

Not principal on this, i just think it is natural, as long as we have
e alias for expr. I think eif is good to have, too. Aliases cost
nothing there.

 May I suggest: format_expr()? That way, if somebody extends it to accept
 more versatile format strings, including floats, the name still works.

Floats are output by expr.
And i'm afraid that making the formatting function more generic would
add a lot of complexity (including safety checks). Actually now i
cannot imagine how would it look like, and what are the use cases.

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


[FFmpeg-devel] [PATCH] oss_audio: check all ioctl() return codes

2014-07-17 Thread Timothy Gu
Also uses a macro to simplify.

Signed-off-by: Timothy Gu timothyg...@gmail.com
---

Found with clang's static analyzer.

---
 libavdevice/oss_audio.c | 23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/libavdevice/oss_audio.c b/libavdevice/oss_audio.c
index 734e565..3c5065c 100644
--- a/libavdevice/oss_audio.c
+++ b/libavdevice/oss_audio.c
@@ -87,8 +87,15 @@ static int audio_open(AVFormatContext *s1, int is_output, 
const char *audio_devi
 
 s-frame_size = AUDIO_BLOCK_SIZE;
 
+#define CHECK_IOCTL_ERROR(event)  \
+if (err  0) {\
+av_log(s1, AV_LOG_ERROR, #event : %s\n, strerror(errno)); \
+goto fail;\
+}
+
 /* select format : favour native format */
 err = ioctl(audio_fd, SNDCTL_DSP_GETFMTS, tmp);
+CHECK_IOCTL_ERROR(SNDCTL_DSP_GETFMTS)
 
 #if HAVE_BIGENDIAN
 if (tmp  AFMT_S16_BE) {
@@ -121,24 +128,15 @@ static int audio_open(AVFormatContext *s1, int is_output, 
const char *audio_devi
 return AVERROR(EIO);
 }
 err=ioctl(audio_fd, SNDCTL_DSP_SETFMT, tmp);
-if (err  0) {
-av_log(s1, AV_LOG_ERROR, SNDCTL_DSP_SETFMT: %s\n, strerror(errno));
-goto fail;
-}
+CHECK_IOCTL_ERROR(SNDCTL_DSP_SETFMTS)
 
 tmp = (s-channels == 2);
 err = ioctl(audio_fd, SNDCTL_DSP_STEREO, tmp);
-if (err  0) {
-av_log(s1, AV_LOG_ERROR, SNDCTL_DSP_STEREO: %s\n, strerror(errno));
-goto fail;
-}
+CHECK_IOCTL_ERROR(SNDCTL_DSP_STEREO)
 
 tmp = s-sample_rate;
 err = ioctl(audio_fd, SNDCTL_DSP_SPEED, tmp);
-if (err  0) {
-av_log(s1, AV_LOG_ERROR, SNDCTL_DSP_SPEED: %s\n, strerror(errno));
-goto fail;
-}
+CHECK_IOCTL_ERROR(SNDCTL_DSP_SPEED)
 s-sample_rate = tmp; /* store real sample rate */
 s-fd = audio_fd;
 
@@ -146,6 +144,7 @@ static int audio_open(AVFormatContext *s1, int is_output, 
const char *audio_devi
  fail:
 close(audio_fd);
 return AVERROR(EIO);
+#undef CHECK_IOCTL_ERROR
 }
 
 static int audio_close(AudioData *s)
-- 
1.9.1

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


[FFmpeg-devel] [PATCH 1/2] proresenc_anatoliy: use tables in proresdata.c instead of redefining them

2014-07-17 Thread Timothy Gu
Signed-off-by: Timothy Gu timothyg...@gmail.com
---
 libavcodec/Makefile |  4 ++--
 libavcodec/proresenc_anatoliy.c | 43 ++---
 2 files changed, 16 insertions(+), 31 deletions(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 307ad22..e3f75f5 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -369,8 +369,8 @@ OBJS-$(CONFIG_PPM_DECODER) += pnmdec.o pnm.o
 OBJS-$(CONFIG_PPM_ENCODER) += pnmenc.o
 OBJS-$(CONFIG_PRORES_DECODER)  += proresdec2.o proresdsp.o proresdata.o
 OBJS-$(CONFIG_PRORES_LGPL_DECODER) += proresdec_lgpl.o proresdsp.o 
proresdata.o
-OBJS-$(CONFIG_PRORES_ENCODER)  += proresenc_anatoliy.o
-OBJS-$(CONFIG_PRORES_AW_ENCODER)   += proresenc_anatoliy.o
+OBJS-$(CONFIG_PRORES_ENCODER)  += proresenc_anatoliy.o proresdata.o
+OBJS-$(CONFIG_PRORES_AW_ENCODER)   += proresenc_anatoliy.o proresdata.o
 OBJS-$(CONFIG_PRORES_KS_ENCODER)   += proresenc_kostya.o proresdata.o
 OBJS-$(CONFIG_PTX_DECODER) += ptx.o
 OBJS-$(CONFIG_QCELP_DECODER)   += qcelpdec.o \
diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index f471f49..b8531cd 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -32,6 +32,7 @@
 #include put_bits.h
 #include bytestream.h
 #include fdctdsp.h
+#include proresdata.h
 
 #define DEFAULT_SLICE_MB_WIDTH 8
 
@@ -52,17 +53,6 @@ static const int qp_start_table[4] = { 4, 1, 1, 1 };
 static const int qp_end_table[4]   = { 8, 9, 6, 6 };
 static const int bitrate_table[5]  = { 1000, 2100, 3500, 5400 };
 
-static const uint8_t progressive_scan[64] = {
- 0,  1,  8,  9,  2,  3, 10, 11,
-16, 17, 24, 25, 18, 19, 26, 27,
- 4,  5, 12, 20, 13,  6,  7, 14,
-21, 28, 29, 22, 15, 23, 30, 31,
-32, 33, 40, 48, 41, 34, 35, 42,
-49, 56, 57, 50, 43, 36, 37, 44,
-51, 58, 59, 52, 45, 38, 39, 46,
-53, 60, 61, 54, 47, 55, 62, 63
-};
-
 static const uint8_t QMAT_LUMA[4][64] = {
 {
  4,  7,  9, 11, 13, 14, 15, 63,
@@ -196,10 +186,6 @@ static av_always_inline int get_level(int val)
 return (val ^ sign) - sign;
 }
 
-#define FIRST_DC_CB 0xB8
-
-static const uint8_t dc_codebook[7] = { 0x04, 0x28, 0x28, 0x4D, 0x4D, 0x70, 
0x70};
-
 static void encode_dc_coeffs(PutBitContext *pb, int16_t *in,
 int blocks_per_slice, int *qmat)
 {
@@ -211,48 +197,47 @@ static void encode_dc_coeffs(PutBitContext *pb, int16_t 
*in,
 code = TO_GOLOMB(prev_dc);
 encode_codeword(pb, code, FIRST_DC_CB);
 
-code = 5; sign = 0; idx = 64;
+code = 3; sign = 0; idx = 64;
 for (i = 1; i  blocks_per_slice; i++, idx += 64) {
 new_dc= QSCALE(qmat, 0, in[idx] - 16384);
 delta = new_dc - prev_dc;
 diff_sign = DIFF_SIGN(delta, sign);
 new_code  = TO_GOLOMB2(get_level(delta), diff_sign);
-
-encode_codeword(pb, new_code, dc_codebook[FFMIN(code, 6)]);
-
-code  = new_code;
+encode_codeword(pb, new_code, ff_prores_dc_codebook[code]);
+code  = (new_code + (new_code  1))  1;
+code  = FFMIN(code, 3);
 sign  = delta  31;
 prev_dc   = new_dc;
 }
 }
 
-static const uint8_t run_to_cb[16] = { 0x06, 0x06, 0x05, 0x05, 0x04, 0x29,
-0x29, 0x29, 0x29, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x4C };
-static const uint8_t lev_to_cb[10] = { 0x04, 0x0A, 0x05, 0x06, 0x04, 0x28,
-0x28, 0x28, 0x28, 0x4C };
-
 static void encode_ac_coeffs(AVCodecContext *avctx, PutBitContext *pb,
 int16_t *in, int blocks_per_slice, int *qmat)
 {
 int prev_run = 4;
 int prev_level = 2;
 
-int run = 0, level, code, i, j;
+int run = 0, level, code, i, j, run_cb, lev_cb;
+run_cb = ff_prores_run_to_cb_index[4];
+lev_cb = ff_prores_lev_to_cb_index[2];
+
 for (i = 1; i  64; i++) {
-int indp = progressive_scan[i];
+int indp = ff_prores_progressive_scan[i];
 for (j = 0; j  blocks_per_slice; j++) {
 int val = QSCALE(qmat, indp, in[(j  6) + indp]);
 if (val) {
-encode_codeword(pb, run, run_to_cb[FFMIN(prev_run, 15)]);
+encode_codeword(pb, run, ff_prores_ac_codebook[run_cb]);
 
 prev_run   = run;
 run= 0;
 level  = get_level(val);
 code   = level - 1;
 
-encode_codeword(pb, code, lev_to_cb[FFMIN(prev_level, 9)]);
+encode_codeword(pb, code, ff_prores_ac_codebook[lev_cb]);
 
 prev_level = level;
+run_cb = ff_prores_run_to_cb_index[FFMIN(prev_run,  15)];
+lev_cb = ff_prores_lev_to_cb_index[FFMIN(prev_level, 9)];
 
 put_bits(pb, 1, IS_NEGATIVE(val));
 } else {
-- 
1.9.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org

[FFmpeg-devel] [PATCH 2/2] proresenc: move profile handling to global avcodec options

2014-07-17 Thread Timothy Gu
This allows users to use the two encoders with the same syntax.

Signed-off-by: Timothy Gu timothyg...@gmail.com
---
 libavcodec/avcodec.h|  5 +
 libavcodec/options_table.h  |  5 +
 libavcodec/proresenc_anatoliy.c |  5 -
 libavcodec/proresenc_kostya.c   | 44 +
 4 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 93ba4d0..cd29065 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2862,6 +2862,11 @@ typedef struct AVCodecContext {
 #define FF_PROFILE_JPEG2000_DCINEMA_2K  3
 #define FF_PROFILE_JPEG2000_DCINEMA_4K  4
 
+#define FF_PROFILE_PRORES_PROXY 0
+#define FF_PROFILE_PRORES_LT1
+#define FF_PROFILE_PRORES_STANDARD  2
+#define FF_PROFILE_PRORES_HQ3
+#define FF_PROFILE_PRORES_  4
 
 #define FF_PROFILE_HEVC_MAIN1
 #define FF_PROFILE_HEVC_MAIN_10 2
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index cbefa52..7d0a425 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -338,6 +338,11 @@ static const AVOption avcodec_options[] = {
 {dts_96_24, NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_96_24 }, 
INT_MIN, INT_MAX, A|E, profile},
 {dts_hd_hra, NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_HD_HRA }, 
INT_MIN, INT_MAX, A|E, profile},
 {dts_hd_ma, NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_PROFILE_DTS_HD_MA }, 
INT_MIN, INT_MAX, A|E, profile},
+{prores_proxy, NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_PROXY 
}, INT_MIN, INT_MAX, V|E, profile },
+{prores_lt,NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_LT },  
  INT_MIN, INT_MAX, V|E, profile },
+{prores_standard,NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 
FF_PROFILE_PRORES_STANDARD }, INT_MIN, INT_MAX, V|E, profile },
+{prores_hq,NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_HQ },  
  INT_MIN, INT_MAX, V|E, profile },
+{prores_,  NULL, 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_ 
},  INT_MIN, INT_MAX, V|E, profile },
 {level, NULL, OFFSET(level), AV_OPT_TYPE_INT, {.i64 = FF_LEVEL_UNKNOWN }, 
INT_MIN, INT_MAX, V|A|E, level},
 {unknown, NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_LEVEL_UNKNOWN }, INT_MIN, 
INT_MAX, V|A|E, level},
 {lowres, decode at 1= 1/2, 2=1/4, 3=1/8 resolutions, OFFSET(lowres), 
AV_OPT_TYPE_INT, {.i64 = 0 }, 0, INT_MAX, V|A|D},
diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index b8531cd..b66f405 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -36,11 +36,6 @@
 
 #define DEFAULT_SLICE_MB_WIDTH 8
 
-#define FF_PROFILE_PRORES_PROXY 0
-#define FF_PROFILE_PRORES_LT1
-#define FF_PROFILE_PRORES_STANDARD  2
-#define FF_PROFILE_PRORES_HQ3
-
 static const AVProfile profiles[] = {
 { FF_PROFILE_PRORES_PROXY,apco},
 { FF_PROFILE_PRORES_LT,   apcs},
diff --git a/libavcodec/proresenc_kostya.c b/libavcodec/proresenc_kostya.c
index 93bcde7..9505df0 100644
--- a/libavcodec/proresenc_kostya.c
+++ b/libavcodec/proresenc_kostya.c
@@ -40,14 +40,6 @@
 #define MAX_PLANES 4
 
 enum {
-PRORES_PROFILE_PROXY = 0,
-PRORES_PROFILE_LT,
-PRORES_PROFILE_STANDARD,
-PRORES_PROFILE_HQ,
-PRORES_PROFILE_,
-};
-
-enum {
 QUANT_MAT_PROXY = 0,
 QUANT_MAT_LT,
 QUANT_MAT_STANDARD,
@@ -1214,6 +1206,19 @@ static av_cold int encode_init(AVCodecContext *avctx)
 
 avctx-codec_tag   = ctx-profile_info-tag;
 
+if (avctx-profile == FF_PROFILE_UNKNOWN) {
+avctx-profile = FF_PROFILE_PRORES_STANDARD;
+av_log(avctx, AV_LOG_INFO,
+   no profile specified. encoding with ProRes standard (apcn) 
profile\n);
+} else if (avctx-profile  FF_PROFILE_PRORES_PROXY
+|| avctx-profile  FF_PROFILE_PRORES_) {
+av_log(avctx, AV_LOG_ERROR,
+   unknown profile %d. Supported profiles: prores_proxy, 
prores_lt,\n
+   prores_standard, prores_hq, prores_.\n,
+   avctx-profile);
+return AVERROR(EINVAL);
+}
+
 av_log(avctx, AV_LOG_DEBUG,
profile %d, %d slices, interlacing: %s, %d bits per MB\n,
ctx-profile, ctx-slices_per_picture * ctx-pictures_per_frame,
@@ -1230,19 +1235,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
 static const AVOption options[] = {
 { mbs_per_slice, macroblocks per slice, OFFSET(mbs_per_slice),
 AV_OPT_TYPE_INT, { .i64 = 8 }, 1, MAX_MBS_PER_SLICE, VE },
-{ profile,   NULL, OFFSET(profile), AV_OPT_TYPE_INT,
-{ .i64 = PRORES_PROFILE_STANDARD },
-PRORES_PROFILE_PROXY, PRORES_PROFILE_, VE, profile },
-{ proxy, NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 
PRORES_PROFILE_PROXY },
-0, 0, VE, profile },
-{ lt,NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PRORES_PROFILE_LT 
},
-0, 0, VE, profile },
-{ standard,  

Re: [FFmpeg-devel] [Updated PATCH 2/4] armv6: Accelerate ff_fft_calc for general case (nbits != 4)

2014-07-17 Thread Michael Niedermayer
On Fri, Jul 11, 2014 at 11:32:08AM +0100, Ben Avison wrote:
 The previous implementation targeted DTS Coherent Acoustics, which only
 requires nbits == 4 (fft16()). This case was (and still is) linked directly
 rather than being indirected through ff_fft_calc_vfp(), but now the full
 range from radix-4 up to radix-65536 is available. This benefits other codecs
 such as AAC and AC3.
 
 The implementaion is based upon the C version, with each routine larger than
 radix-16 calling a hierarchy of smaller FFT functions, then performing a
 post-processing pass. This pass benefits a lot from loop unrolling to
 counter the long pipelines in the VFP. A relaxed calling standard also
 reduces the overhead of the call hierarchy, and avoiding the excessive
 inlining performed by GCC probably helps with I-cache utilisation too.
 
 I benchmarked the result by measuring the number of gperftools samples that
 hit anywhere in the AAC decoder (starting from aac_decode_frame()) or
 specifically in the FFT routines (fft4() to fft512() and pass()) for the
 same sample AAC stream:
 
   Before  After
   Mean   StdDev   Mean   StdDev  Confidence  Change
 Audio decode  2245.5 53.1 1599.6 43.8100.0%  +40.4%
 FFT routines  940.6  22.0 348.1  20.8100.0%  +170.2%
 ---
  libavcodec/arm/fft_init_arm.c |8 +-
  libavcodec/arm/fft_vfp.S  |  284 
 +++--
  2 files changed, 275 insertions(+), 17 deletions(-)

merged a variant of this patch

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

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact


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


[FFmpeg-devel] [PATCH] hevc: propagate error code from set_sps()

2014-07-17 Thread Timothy Gu
Signed-off-by: Timothy Gu timothyg...@gmail.com
---
 libavcodec/hevc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/hevc.c b/libavcodec/hevc.c
index afb2baa..d3108d7 100644
--- a/libavcodec/hevc.c
+++ b/libavcodec/hevc.c
@@ -3299,7 +3299,8 @@ static int hevc_update_thread_context(AVCodecContext *dst,
 }
 
 if (s-sps != s0-sps)
-ret = set_sps(s, s0-sps);
+if ((ret = set_sps(s, s0-sps))  0)
+return ret;
 
 s-seq_decode = s0-seq_decode;
 s-seq_output = s0-seq_output;
-- 
1.9.1

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


Re: [FFmpeg-devel] [PATCH 1/2] proresenc_anatoliy: use tables in proresdata.c instead of redefining them

2014-07-17 Thread Michael Niedermayer
On Thu, Jul 17, 2014 at 06:04:06PM -0700, Timothy Gu wrote:
 Signed-off-by: Timothy Gu timothyg...@gmail.com
 ---
  libavcodec/Makefile |  4 ++--
  libavcodec/proresenc_anatoliy.c | 43 
 ++---
  2 files changed, 16 insertions(+), 31 deletions(-)

it appears this makes the code slightly slower

before patch:
233505 decicycles in coeffs, 1048576 runs, 0 skips
233491 decicycles in coeffs, 1048576 runs, 0 skips
233492 decicycles in coeffs, 1048575 runs, 1 skips

with patch:
234461 decicycles in coeffs, 1048576 runs, 0 skips
234602 decicycles in coeffs, 1048576 runs, 0 skips
234546 decicycles in coeffs, 1048576 runs, 0 skips

tested with:
diff --git a/libavcodec/proresenc_anatoliy.c b/libavcodec/proresenc_anatoliy.c
index b8531cd..4f00b5c 100644
--- a/libavcodec/proresenc_anatoliy.c
+++ b/libavcodec/proresenc_anatoliy.c
@@ -290,10 +290,10 @@ static int encode_slice_plane(AVCodecContext *avctx, int 
mb_count,

 blocks_per_slice = mb_count  (2 - chroma);
 init_put_bits(pb, buf, buf_size  3);
-
+START_TIMER
 encode_dc_coeffs(pb, blocks, blocks_per_slice, qmat);
 encode_ac_coeffs(avctx, pb, blocks, blocks_per_slice, qmat);
-
+STOP_TIMER(coeffs)
 flush_put_bits(pb);
 return put_bits_ptr(pb) - pb.buf;
 }

and
./ffmpeg -y -i matrixbench_mpeg2.mpg -an -threads 1 -vcodec prores -f null -


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

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


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


[FFmpeg-devel] [PATCH 3/4] smacker: remove dead code

2014-07-17 Thread Timothy Gu
Signed-off-by: Timothy Gu timothyg...@gmail.com
---
 libavcodec/smacker.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index 644beb3..518bdad 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -438,7 +438,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame,
 bw = avctx-width  2;
 bh = avctx-height  2;
 blocks = bw * bh;
-out = smk-pic-data[0];
 stride = smk-pic-linesize[0];
 while(blk  blocks) {
 int type, run, mode;
@@ -499,7 +498,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame,
 out += stride;
 out[0] = out[1] = pix  0xFF;
 out[2] = out[3] = pix  8;
-out += stride;
 break;
 case 2:
 for(i = 0; i  2; i++) {
-- 
1.9.1

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


[FFmpeg-devel] [PATCH 2/4] kerndeint: remove dead assignments

2014-07-17 Thread Timothy Gu
Signed-off-by: Timothy Gu timothyg...@gmail.com
---
 libavfilter/vf_kerndeint.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavfilter/vf_kerndeint.c b/libavfilter/vf_kerndeint.c
index 1f8e091..5130208 100644
--- a/libavfilter/vf_kerndeint.c
+++ b/libavfilter/vf_kerndeint.c
@@ -154,10 +154,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame 
*inpic)
 h = plane == 0 ? inlink-h : FF_CEIL_RSHIFT(inlink-h, 
kerndeint-vsub);
 bwidth = kerndeint-tmp_bwidth[plane];
 
-srcp = srcp_saved = inpic-data[plane];
+srcp_saved= inpic-data[plane];
 src_linesize  = inpic-linesize[plane];
 psrc_linesize = kerndeint-tmp_linesize[plane];
-dstp = dstp_saved = outpic-data[plane];
+dstp_saved= outpic-data[plane];
 dst_linesize  = outpic-linesize[plane];
 srcp  = srcp_saved + (1 - order) * src_linesize;
 dstp  = dstp_saved + (1 - order) * dst_linesize;
-- 
1.9.1

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


[FFmpeg-devel] [PATCH 1/4] mpeg: remove unused assignment

2014-07-17 Thread Timothy Gu
Signed-off-by: Timothy Gu timothyg...@gmail.com
---
 libavformat/mpeg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index c53bab3..5891cea 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -204,8 +204,8 @@ static long mpegps_psm_parse(MpegDemuxContext *m, 
AVIOContext *pb)
 
 /* skip program_stream_info */
 avio_skip(pb, ps_info_length);
-es_map_length = avio_rb16(pb);
 /* Ignore es_map_length, trust psm_length */
+avio_rb16(pb);
 es_map_length = psm_length - ps_info_length - 10;
 
 /* at least one es available? */
-- 
1.9.1

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


[FFmpeg-devel] [PATCH 4/4] a64multienc: remove dead assignment

2014-07-17 Thread Timothy Gu
Signed-off-by: Timothy Gu timothyg...@gmail.com
---
 libavcodec/a64multienc.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c
index 3067774..9760298 100644
--- a/libavcodec/a64multienc.c
+++ b/libavcodec/a64multienc.c
@@ -351,7 +351,6 @@ static int a64multi_encode_frame(AVCodecContext *avctx, 
AVPacket *pkt,
 
 /* advance pointers */
 buf  += charset_size;
-charset  += charset_size;
 }
 
 /* write x frames to buf */
-- 
1.9.1

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


Re: [FFmpeg-devel] [PATCH 2/2] proresenc: move profile handling to global avcodec options

2014-07-17 Thread Michael Niedermayer
On Thu, Jul 17, 2014 at 06:04:07PM -0700, Timothy Gu wrote:
 This allows users to use the two encoders with the same syntax.
 
 Signed-off-by: Timothy Gu timothyg...@gmail.com
 ---
  libavcodec/avcodec.h|  5 +
  libavcodec/options_table.h  |  5 +
  libavcodec/proresenc_anatoliy.c |  5 -
  libavcodec/proresenc_kostya.c   | 44 
 +

seems to break fate

--- ./tests/ref/vsynth/vsynth1-prores_ks2014-07-17 16:00:41.213032673 
+0200
+++ tests/data/fate/vsynth1-prores_ks   2014-07-18 04:40:34.717993203 +0200
@@ -1,4 +0,0 @@
-fe41a284da97ea5ec8866ca9a55b84da *tests/data/fate/vsynth1-prores_ks.mov
-3858911 tests/data/fate/vsynth1-prores_ks.mov
-100eb002413fe7a632d440dfbdf7e3ff 
*tests/data/fate/vsynth1-prores_ks.out.rawvideo
-stddev:3.17 PSNR: 38.09 MAXDIFF:   39 bytes:  7603200/  7603200


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

The real ebay dictionary, page 1
Used only once- Some unspecified defect prevented a second use
In good condition - Can be repaird by experienced expert
As is - You wouldnt want it even if you were payed for it, if you knew ...


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


[FFmpeg-devel] [PATCH 1/2] alpha/idctdsp: move disabled cruft out of dsputil

2014-07-17 Thread James Almer
Signed-off-by: James Almer jamr...@gmail.com
---
 libavcodec/alpha/dsputil_alpha.c | 72 
 libavcodec/alpha/idctdsp_alpha.c | 72 
 2 files changed, 72 insertions(+), 72 deletions(-)

diff --git a/libavcodec/alpha/dsputil_alpha.c b/libavcodec/alpha/dsputil_alpha.c
index d99a74b..e00497d 100644
--- a/libavcodec/alpha/dsputil_alpha.c
+++ b/libavcodec/alpha/dsputil_alpha.c
@@ -24,78 +24,6 @@
 #include dsputil_alpha.h
 #include asm.h
 
-#if 0
-/* These functions were the base for the optimized assembler routines,
-   and remain here for documentation purposes.  */
-static void put_pixels_clamped_mvi(const int16_t *block, uint8_t *pixels,
-   ptrdiff_t line_size)
-{
-int i = 8;
-uint64_t clampmask = zap(-1, 0xaa); /* 0x00ff00ff00ff00ff */
-
-do {
-uint64_t shorts0, shorts1;
-
-shorts0 = ldq(block);
-shorts0 = maxsw4(shorts0, 0);
-shorts0 = minsw4(shorts0, clampmask);
-stl(pkwb(shorts0), pixels);
-
-shorts1 = ldq(block + 4);
-shorts1 = maxsw4(shorts1, 0);
-shorts1 = minsw4(shorts1, clampmask);
-stl(pkwb(shorts1), pixels + 4);
-
-pixels += line_size;
-block += 8;
-} while (--i);
-}
-
-void add_pixels_clamped_mvi(const int16_t *block, uint8_t *pixels,
-ptrdiff_t line_size)
-{
-int h = 8;
-/* Keep this function a leaf function by generating the constants
-   manually (mainly for the hack value ;-).  */
-uint64_t clampmask = zap(-1, 0xaa); /* 0x00ff00ff00ff00ff */
-uint64_t signmask  = zap(-1, 0x33);
-signmask ^= signmask  1;  /* 0x8000800080008000 */
-
-do {
-uint64_t shorts0, pix0, signs0;
-uint64_t shorts1, pix1, signs1;
-
-shorts0 = ldq(block);
-shorts1 = ldq(block + 4);
-
-pix0= unpkbw(ldl(pixels));
-/* Signed subword add (MMX paddw).  */
-signs0  = shorts0  signmask;
-shorts0 = ~signmask;
-shorts0 += pix0;
-shorts0 ^= signs0;
-/* Clamp. */
-shorts0 = maxsw4(shorts0, 0);
-shorts0 = minsw4(shorts0, clampmask);
-
-/* Next 4.  */
-pix1= unpkbw(ldl(pixels + 4));
-signs1  = shorts1  signmask;
-shorts1 = ~signmask;
-shorts1 += pix1;
-shorts1 ^= signs1;
-shorts1 = maxsw4(shorts1, 0);
-shorts1 = minsw4(shorts1, clampmask);
-
-stl(pkwb(shorts0), pixels);
-stl(pkwb(shorts1), pixels + 4);
-
-pixels += line_size;
-block += 8;
-} while (--h);
-}
-#endif
-
 av_cold void ff_dsputil_init_alpha(DSPContext *c, AVCodecContext *avctx)
 {
 /* amask clears all bits that correspond to present features.  */
diff --git a/libavcodec/alpha/idctdsp_alpha.c b/libavcodec/alpha/idctdsp_alpha.c
index 73f4821..1050697 100644
--- a/libavcodec/alpha/idctdsp_alpha.c
+++ b/libavcodec/alpha/idctdsp_alpha.c
@@ -33,6 +33,78 @@ void (*put_pixels_clamped_axp_p)(const int16_t *block, 
uint8_t *pixels,
 void (*add_pixels_clamped_axp_p)(const int16_t *block, uint8_t *pixels,
  int line_size);
 
+#if 0
+/* These functions were the base for the optimized assembler routines,
+   and remain here for documentation purposes.  */
+static void put_pixels_clamped_mvi(const int16_t *block, uint8_t *pixels,
+   ptrdiff_t line_size)
+{
+int i = 8;
+uint64_t clampmask = zap(-1, 0xaa); /* 0x00ff00ff00ff00ff */
+
+do {
+uint64_t shorts0, shorts1;
+
+shorts0 = ldq(block);
+shorts0 = maxsw4(shorts0, 0);
+shorts0 = minsw4(shorts0, clampmask);
+stl(pkwb(shorts0), pixels);
+
+shorts1 = ldq(block + 4);
+shorts1 = maxsw4(shorts1, 0);
+shorts1 = minsw4(shorts1, clampmask);
+stl(pkwb(shorts1), pixels + 4);
+
+pixels += line_size;
+block += 8;
+} while (--i);
+}
+
+void add_pixels_clamped_mvi(const int16_t *block, uint8_t *pixels,
+ptrdiff_t line_size)
+{
+int h = 8;
+/* Keep this function a leaf function by generating the constants
+   manually (mainly for the hack value ;-).  */
+uint64_t clampmask = zap(-1, 0xaa); /* 0x00ff00ff00ff00ff */
+uint64_t signmask  = zap(-1, 0x33);
+signmask ^= signmask  1;  /* 0x8000800080008000 */
+
+do {
+uint64_t shorts0, pix0, signs0;
+uint64_t shorts1, pix1, signs1;
+
+shorts0 = ldq(block);
+shorts1 = ldq(block + 4);
+
+pix0= unpkbw(ldl(pixels));
+/* Signed subword add (MMX paddw).  */
+signs0  = shorts0  signmask;
+shorts0 = ~signmask;
+shorts0 += pix0;
+shorts0 ^= signs0;
+/* Clamp. */
+shorts0 = maxsw4(shorts0, 0);
+shorts0 = minsw4(shorts0, clampmask);
+
+/* Next 4.  */
+pix1= unpkbw(ldl(pixels + 4));
+signs1  

[FFmpeg-devel] [PATCH 2/2] alpha/me_cmp: move code out of dsputil

2014-07-17 Thread James Almer
Signed-off-by: James Almer jamr...@gmail.com
---
Untested.

 libavcodec/alpha/Makefile  |  5 ++-
 libavcodec/alpha/dsputil_alpha.c   | 40 --
 libavcodec/alpha/dsputil_alpha.h   | 32 -
 .../alpha/{motion_est_alpha.c = me_cmp_alpha.c}   | 27 ---
 .../{motion_est_mvi_asm.S = me_cmp_mvi_asm.S} |  0
 libavcodec/alpha/pixblockdsp_alpha.c   |  1 -
 6 files changed, 24 insertions(+), 81 deletions(-)
 delete mode 100644 libavcodec/alpha/dsputil_alpha.c
 delete mode 100644 libavcodec/alpha/dsputil_alpha.h
 rename libavcodec/alpha/{motion_est_alpha.c = me_cmp_alpha.c} (88%)
 rename libavcodec/alpha/{motion_est_mvi_asm.S = me_cmp_mvi_asm.S} (100%)

diff --git a/libavcodec/alpha/Makefile b/libavcodec/alpha/Makefile
index 42cabfe..796d976 100644
--- a/libavcodec/alpha/Makefile
+++ b/libavcodec/alpha/Makefile
@@ -1,7 +1,6 @@
 OBJS-$(CONFIG_BLOCKDSP) += alpha/blockdsp_alpha.o
-OBJS-$(CONFIG_DSPUTIL)  += alpha/dsputil_alpha.o\
-   alpha/motion_est_alpha.o \
-   alpha/motion_est_mvi_asm.o
+OBJS-$(CONFIG_ME_CMP)   += alpha/me_cmp_alpha.o \
+   alpha/me_cmp_mvi_asm.o
 OBJS-$(CONFIG_HPELDSP)  += alpha/hpeldsp_alpha.o\
alpha/hpeldsp_alpha_asm.o
 OBJS-$(CONFIG_IDCTDSP)  += alpha/idctdsp_alpha.o\
diff --git a/libavcodec/alpha/dsputil_alpha.c b/libavcodec/alpha/dsputil_alpha.c
deleted file mode 100644
index e00497d..000
--- a/libavcodec/alpha/dsputil_alpha.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Alpha optimized DSP utils
- * Copyright (c) 2002 Falk Hueffner f...@debian.org
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include libavutil/attributes.h
-#include libavcodec/dsputil.h
-#include dsputil_alpha.h
-#include asm.h
-
-av_cold void ff_dsputil_init_alpha(DSPContext *c, AVCodecContext *avctx)
-{
-/* amask clears all bits that correspond to present features.  */
-if (amask(AMASK_MVI) == 0) {
-c-sad[0]   = pix_abs16x16_mvi_asm;
-c-sad[1]   = pix_abs8x8_mvi;
-c-pix_abs[0][0]= pix_abs16x16_mvi_asm;
-c-pix_abs[1][0]= pix_abs8x8_mvi;
-c-pix_abs[0][1]= pix_abs16x16_x2_mvi;
-c-pix_abs[0][2]= pix_abs16x16_y2_mvi;
-c-pix_abs[0][3]= pix_abs16x16_xy2_mvi;
-}
-
-}
diff --git a/libavcodec/alpha/dsputil_alpha.h b/libavcodec/alpha/dsputil_alpha.h
deleted file mode 100644
index a48765f..000
--- a/libavcodec/alpha/dsputil_alpha.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * This file is part of FFmpeg.
- *
- * FFmpeg is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * FFmpeg is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_ALPHA_DSPUTIL_ALPHA_H
-#define AVCODEC_ALPHA_DSPUTIL_ALPHA_H
-
-#include stddef.h
-#include stdint.h
-
-int pix_abs8x8_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int 
h);
-int pix_abs16x16_mvi_asm(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, 
int h);
-int pix_abs16x16_x2_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, 
int h);
-int pix_abs16x16_y2_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, 
int h);
-int pix_abs16x16_xy2_mvi(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, 
int h);
-
-
-#endif /* AVCODEC_ALPHA_DSPUTIL_ALPHA_H */
diff --git a/libavcodec/alpha/motion_est_alpha.c 
b/libavcodec/alpha/me_cmp_alpha.c
similarity index 

Re: [FFmpeg-devel] [PATCH 2/4] kerndeint: remove dead assignments

2014-07-17 Thread Michael Niedermayer
On Thu, Jul 17, 2014 at 07:25:41PM -0700, Timothy Gu wrote:
 Signed-off-by: Timothy Gu timothyg...@gmail.com
 ---
  libavfilter/vf_kerndeint.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

applied

thanks

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

I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates


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


Re: [FFmpeg-devel] [PATCH 4/4] a64multienc: remove dead assignment

2014-07-17 Thread Michael Niedermayer
On Thu, Jul 17, 2014 at 07:25:43PM -0700, Timothy Gu wrote:
 Signed-off-by: Timothy Gu timothyg...@gmail.com
 ---
  libavcodec/a64multienc.c | 1 -
  1 file changed, 1 deletion(-)

applied

thanks

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

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


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


Re: [FFmpeg-devel] [PATCH 2/2] alpha/me_cmp: move code out of dsputil

2014-07-17 Thread Michael Niedermayer
On Thu, Jul 17, 2014 at 11:45:35PM -0300, James Almer wrote:
 Signed-off-by: James Almer jamr...@gmail.com
 ---
 Untested.
 
  libavcodec/alpha/Makefile  |  5 ++-
  libavcodec/alpha/dsputil_alpha.c   | 40 
 --
  libavcodec/alpha/dsputil_alpha.h   | 32 -
  .../alpha/{motion_est_alpha.c = me_cmp_alpha.c}   | 27 ---
  .../{motion_est_mvi_asm.S = me_cmp_mvi_asm.S} |  0
  libavcodec/alpha/pixblockdsp_alpha.c   |  1 -
  6 files changed, 24 insertions(+), 81 deletions(-)
  delete mode 100644 libavcodec/alpha/dsputil_alpha.c
  delete mode 100644 libavcodec/alpha/dsputil_alpha.h
  rename libavcodec/alpha/{motion_est_alpha.c = me_cmp_alpha.c} (88%)
  rename libavcodec/alpha/{motion_est_mvi_asm.S = me_cmp_mvi_asm.S} (100%)

tested
applied
thanks

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

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 


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


Re: [FFmpeg-devel] [PATCH] lavfi/drawtext: add alias expr_int_format to expansion function eif

2014-07-17 Thread Stefano Sabatini
On date Friday 2014-07-18 01:00:40 +0300, Andrey Utkin encoded:
 ---
  doc/filters.texi  | 2 +-
  libavfilter/vf_drawtext.c | 3 ++-
  2 files changed, 3 insertions(+), 2 deletions(-)
 
 diff --git a/doc/filters.texi b/doc/filters.texi
 index 8cde277..a7919a3 100644
 --- a/doc/filters.texi
 +++ b/doc/filters.texi
 @@ -3916,7 +3916,7 @@ example the text size is not known when evaluating the 
 expression, so
  the constants @var{text_w} and @var{text_h} will have an undefined
  value.
  
 -@item eif
 +@item expr_int_format, eif
  Evaluate the expression's value and output as formatted integer.
  
  First argument is expression to be evaluated, same as for @var{expr} 
 function.
 diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
 index c744d93..b7a295f 100644
 --- a/libavfilter/vf_drawtext.c
 +++ b/libavfilter/vf_drawtext.c
 @@ -949,7 +949,7 @@ static int func_eval_expr_int_format(AVFilterContext 
 *ctx, AVBPrint *bp,
  if (argc == 3) {
  ret = sscanf(argv[2], %u, positions);
  if (ret != 1) {
 -av_log(ctx, AV_LOG_ERROR, eif(): Invalid number of positions
 +av_log(ctx, AV_LOG_ERROR, expr_int_format(): Invalid number of 
 positions
   to print: '%s'\n, argv[2]);
  return AVERROR(EINVAL);
  }
 @@ -982,6 +982,7 @@ static const struct drawtext_function {
  } functions[] = {
  { expr,  1, 1, 0,   func_eval_expr },
  { e, 1, 1, 0,   func_eval_expr },
 +{ expr_int_format, 2, 3, 0, func_eval_expr_int_format },
  { eif,   2, 3, 0,   func_eval_expr_int_format },
  { pict_type, 0, 0, 0,   func_pict_type },
  { pts,   0, 2, 0,   func_pts  },

LGTM.
-- 
FFmpeg = Frightening  Furious Mega Perfectionist Ermetic Gospel
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel