Re: [FFmpeg-devel] [PATCH] lavf/matroskadec: Set A_QUICKTIME bit depth

2016-01-12 Thread Mats Peterson

On 01/13/2016 12:30 AM, Mats Peterson wrote:

Since mkvmerge doesn't set the bit depth for A_QUICKTIME audio (as far
as I know), the track->audio.bitdepth variable will be zero, and its
value needs to be retrieved from the sound sample description. Also,
confine the 0x to 'raw '/'twos' fourcc mapping to old version 0
sound sample descriptions, since they are the only valid sample
descriptions for this type of mapping.

Mats


I should add that I've limited the setting of track->audio.bitdepth to 
version 0 sound sample descriptions only, since as they can only contain 
8- or 16-bit uncompressed data, setting it here will properly reflect 
the "real" bit depth. The bit depth of version 1 sound sample 
descriptions can be larger than 16 bits.


Mats

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


Re: [FFmpeg-devel] [PATCH v2 7/9] lavc/ccaption_dec: implement musical glyph

2016-01-12 Thread Clément Bœsch
On Tue, Jan 12, 2016 at 05:42:58PM -0800, Aman Gupta wrote:
> From: Aman Gupta 
> 
> This is the most commonly used character from the special north-american
> character set. All the non-standard charsets are "optional" according to
> the spec, and we currently implement none of them. This commit adds
> support for "♪" which very popular (and has no ascii fallback), typically
> used to indicate lyrics in captions.

Why not add all the other at the same time while at it?

[...]

-- 
Clément B.


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


Re: [FFmpeg-devel] [PATCH v2 8/9] lavc/ccaption_dec: implement positioning for closed captions

2016-01-12 Thread Clément Bœsch
On Tue, Jan 12, 2016 at 05:42:59PM -0800, Aman Gupta wrote:
> From: Aman Gupta 
> 
> Positioning math is based on the guidelines in
> https://dvcs.w3.org/hg/text-tracks/raw-file/default/608toVTT/608toVTT.html#positioning-in-cea-608
> ---
>  libavcodec/ccaption_dec.c | 29 +
>  1 file changed, 25 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
[...]
> +x = ASS_DEFAULT_PLAYRESX * (0.1 + 0.0250 * j);
> +y = ASS_DEFAULT_PLAYRESY * (0.1 + 0.0533 * i);
> +av_bprintf(>buffer, "{\\an7}{\\pos(%d,%d)}", x, y);
> +

I'd be happier if the default alignment could be passed to
ff_ass_subtitle_header() instead.

Also, how confident are you about the support of the position? Because if
it's incorrect in some cases, the default positioning is probably much
better.

[...]

-- 
Clément B.


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


Re: [FFmpeg-devel] have some major changes for nvenc support

2016-01-12 Thread Roger Pack
On 1/8/16, Andrey Turkin  wrote:
> In my opinion this proliferation of various filters which do the same thing
> in different way is a configuration headache. There's CPU filters: one for
> scaling/format conversion, one for padding, one  for cropping, like 5
> different filters for deinterlacing. And now there would be nvresize for
> scaling, and we gotta add CUDA-based nvpad and nvdeint if we want to do
> some transcoding. Maybe add overlaying too - so nvoverlay. Then there is
> OpenCL which can do everything - so 4 more filters for that. And there is
> quicksync which I think can do those things, so there would be qsvscale and
> qsvdeint. And there is D3D11 video processor which can do those things too
> (simultaneously in fact), so there's gotta be
> d3d11vascaledeintpadcropoverlay. And then we've got a whole bunch of video
> filters which can only do their job on a specific hwaccel platform. Want to
> try different hwaccel? Rewrite damn filter string. Want to do something
> generic that can be used over different platforms? Can't be done.
> Maybe it's just my wishful thinking, but I was wondering for some time if
> there can be one "smart" filter to do one specific thing?

Yes a smart wrapper might be nice.
I'm all for different ways to resize, though, I used to wonder why
there wasn't a filter option liek

-filter_complex "convert_to_opengl; opengl_resize=1000x1000;
opengl_rotate=90;convert_from_opengl;" that type of thing, I think
based on similar functionality gstreamer has.
Cheers!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavc/mlpdec: report presence of Atmos substreams as a profile

2016-01-12 Thread Rodger Combs
---
 libavcodec/avcodec.h| 2 ++
 libavcodec/mlp_parser.c | 5 +
 libavcodec/mlpdec.c | 2 ++
 libavcodec/profiles.c   | 6 ++
 libavcodec/profiles.h   | 1 +
 5 files changed, 16 insertions(+)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index f365775..81f1e9a 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3125,6 +3125,8 @@ typedef struct AVCodecContext {
 #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE  3
 #define FF_PROFILE_HEVC_REXT4
 
+#define FF_PROFILE_TRUEHD   0
+#define FF_PROFILE_TRUEHD_ATMOS 1
 /**
  * level
  * - encoding: Set by user.
diff --git a/libavcodec/mlp_parser.c b/libavcodec/mlp_parser.c
index 23601c8..5edb27f 100644
--- a/libavcodec/mlp_parser.c
+++ b/libavcodec/mlp_parser.c
@@ -31,6 +31,7 @@
 #include "libavutil/internal.h"
 #include "get_bits.h"
 #include "parser.h"
+#include "profiles.h"
 #include "mlp_parser.h"
 #include "mlp.h"
 
@@ -392,6 +393,10 @@ static int mlp_parse(AVCodecParserContext *s,
 avctx->bit_rate = mh.peak_bitrate;
 
 mp->num_substreams = mh.num_substreams;
+
+if (avctx->codec_id == AV_CODEC_ID_TRUEHD)
+avctx->profile = (mh.num_substreams > 3) ? FF_PROFILE_TRUEHD_ATMOS 
:
+   FF_PROFILE_TRUEHD;
 }
 
 *poutbuf = buf;
diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c
index c93b058..ccb59d2 100644
--- a/libavcodec/mlpdec.c
+++ b/libavcodec/mlpdec.c
@@ -34,6 +34,7 @@
 #include "internal.h"
 #include "libavutil/crc.h"
 #include "parser.h"
+#include "profiles.h"
 #include "mlp_parser.h"
 #include "mlpdsp.h"
 #include "mlp.h"
@@ -1314,5 +1315,6 @@ AVCodec ff_truehd_decoder = {
 .init   = mlp_decode_init,
 .decode = read_access_unit,
 .capabilities   = AV_CODEC_CAP_DR1,
+.profiles   = NULL_IF_CONFIG_SMALL(ff_truehd_profiles),
 };
 #endif /* CONFIG_TRUEHD_DECODER */
diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c
index 94069fd..ec33248 100644
--- a/libavcodec/profiles.c
+++ b/libavcodec/profiles.c
@@ -129,4 +129,10 @@ const AVProfile ff_vp9_profiles[] = {
 { FF_PROFILE_UNKNOWN },
 };
 
+const AVProfile ff_truehd_profiles[] = {
+{ FF_PROFILE_TRUEHD,   "TrueHD" },
+{ FF_PROFILE_TRUEHD_ATMOS, "Atmos" },
+{ FF_PROFILE_UNKNOWN },
+};
+
 #endif /* !CONFIG_SMALL */
diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h
index 7e1f74d..676a40e 100644
--- a/libavcodec/profiles.h
+++ b/libavcodec/profiles.h
@@ -31,5 +31,6 @@ extern const AVProfile ff_mpeg2_video_profiles[];
 extern const AVProfile ff_mpeg4_video_profiles[];
 extern const AVProfile ff_vc1_profiles[];
 extern const AVProfile ff_vp9_profiles[];
+extern const AVProfile ff_truehd_profiles[];
 
 #endif
-- 
2.6.4

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


Re: [FFmpeg-devel] [PATCH 00/13] check all fclose usage

2016-01-12 Thread Reynaldo H. Verdejo Pinochet
Hi Ganesh

Somehow I'm missing your ffserver patches on this thread, had
to check them on gmame. Probably something odd with my local
filters. Commenting offline for the time being:

09/13 Its OK but actually introduces the error (-  }) you fix on
10/13... clean up accordingly
11, 12 & 13 LGTM


Bests,

-- 
Reynaldo H. Verdejo Pinochet
Open Source Group
Samsung Research America / Silicon Valley
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavf/matroskadec: Set A_QUICKTIME bit depth

2016-01-12 Thread Mats Peterson

On 01/13/2016 08:35 AM, Mats Peterson wrote:

I should add that I've limited the setting of track->audio.bitdepth to
version 0 sound sample descriptions only, since as they can only contain
8- or 16-bit uncompressed data



The samples can only be 8- or 16-bit uncompressed, rather.

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


Re: [FFmpeg-devel] [PATCH 05/13] lavfi/vf_psnr: check fclose return value

2016-01-12 Thread Paul B Mahol
On 1/12/16, Ganesh Ajjanagadde  wrote:
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  libavfilter/vf_psnr.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
> index bce5c51..b6e7f06 100644
> --- a/libavfilter/vf_psnr.c
> +++ b/libavfilter/vf_psnr.c
> @@ -339,7 +339,10 @@ static av_cold void uninit(AVFilterContext *ctx)
>  ff_dualinput_uninit(>dinput);
>
>  if (s->stats_file && s->stats_file != stdout)
> -fclose(s->stats_file);
> +if (fclose(s->stats_file))
> +av_log(NULL, AV_LOG_ERROR,
> +   "Unable to close file '%s', loss of information
> possible: %s\n",
> +   s->stats_file_str, av_err2str(AVERROR(errno)));
>  }
>
>  static const AVFilterPad psnr_inputs[] = {
> --
> 2.7.0
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Please use context for av_log here and in other patches if available.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 00/13] check all fclose usage

2016-01-12 Thread wm4
On Mon, 11 Jan 2016 23:25:02 -0500
Ganesh Ajjanagadde  wrote:

> Some preliminary work has already been done on fclose checking. This completes
> the work, modulo a few exceptions:

1. Printing warnings is completely useless unless maybe in ffmpeg.c
interactive usage (if the user has good eyes). For API users or
ffmpeg.c automated shell scripts this helps absolutely nothing.
2. There are some "theoretical" checks for fclose() on files opened in
read-only mode. This makes no sense. Even if fclose() should fail for
whatever obscure reasons there might be, reading already worked
without errors, and thus closing failure has no meaning to use.

Just what is the point?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH]lavc/mjpeg2jpeg: Accept more mjpeg streams as input

2016-01-12 Thread Carl Eugen Hoyos
Hi!

I guess that attached patch fixes ticket #5151.
It is the user's responsibility to know if the input stream 
is suitable for the bitstream filter or not.

Please comment, Carl Eugen
diff --git a/libavcodec/mjpeg2jpeg_bsf.c b/libavcodec/mjpeg2jpeg_bsf.c
index 68640db..b29039e 100644
--- a/libavcodec/mjpeg2jpeg_bsf.c
+++ b/libavcodec/mjpeg2jpeg_bsf.c
@@ -31,6 +31,7 @@
 
 #include "avcodec.h"
 #include "jpegtables.h"
+#include "mjpeg.h"
 
 static const uint8_t jpeg_header[] = {
 0xff, 0xd8, // SOI
@@ -88,11 +89,11 @@ static int mjpeg2jpeg_filter(AVBitStreamFilterContext *bsfc,
 av_log(avctx, AV_LOG_ERROR, "input is truncated\n");
 return AVERROR_INVALIDDATA;
 }
-if (memcmp("AVI1", buf + 6, 4)) {
-av_log(avctx, AV_LOG_ERROR, "input is not MJPEG/AVI1\n");
-return AVERROR_INVALIDDATA;
+if (buf[2] == 0xff && buf[3] == APP0) {
+input_skip = (buf[4] << 8) + buf[5] + 4;
+} else {
+input_skip = 2;
 }
-input_skip = (buf[4] << 8) + buf[5] + 4;
 if (buf_size < input_skip) {
 av_log(avctx, AV_LOG_ERROR, "input is truncated\n");
 return AVERROR_INVALIDDATA;
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 02/13] lavfi/vf_deshake: check fclose return value

2016-01-12 Thread Michael Niedermayer
On Mon, Jan 11, 2016 at 11:25:04PM -0500, Ganesh Ajjanagadde wrote:
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  libavfilter/vf_deshake.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)

LGTM

thx

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

The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates


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


[FFmpeg-devel] [PATCH]lavf/icodec: Improve probe function

2016-01-12 Thread Carl Eugen Hoyos
Hi!

Attached patch improves ico probing, previously mpeg-2 frames could be 
detected.

Please comment, Carl Eugen
diff --git a/libavformat/icodec.c b/libavformat/icodec.c
index 22e2099..c3e87ea 100644
--- a/libavformat/icodec.c
+++ b/libavformat/icodec.c
@@ -44,8 +44,12 @@ typedef struct {
 
 static int probe(AVProbeData *p)
 {
-if (AV_RL16(p->buf) == 0 && AV_RL16(p->buf + 2) == 1 && AV_RL16(p->buf + 
4))
-return AVPROBE_SCORE_MAX / 4;
+if (   AV_RL16(p->buf) == 0
+&& AV_RL16(p->buf + 2) == 1
+&& AV_RL16(p->buf + 4)
+&& AV_RL16(p->buf + 10) == 1
+&& !p->buf[13])
+return AVPROBE_SCORE_MAX / 4 + 1;
 return 0;
 }
 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavc/mjpeg2jpeg: Accept more mjpeg streams as input

2016-01-12 Thread Carl Eugen Hoyos
On Tuesday 12 January 2016 02:16:52 pm Michael Niedermayer wrote:
> On Tue, Jan 12, 2016 at 09:58:53AM +0100, Carl Eugen Hoyos wrote:

> > -if (memcmp("AVI1", buf + 6, 4)) {
> > -av_log(avctx, AV_LOG_ERROR, "input is not MJPEG/AVI1\n");
> > -return AVERROR_INVALIDDATA;
> > +if (buf[2] == 0xff && buf[3] == APP0) {
> > +input_skip = (buf[4] << 8) + buf[5] + 4;
> > +} else {
> > +input_skip = 2;
>
> shouldnt the first 2 bytes that are being skiped be checked ?

I don't know (possibly) but it seems unrelated to this patch: 
They are not checked now.

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


Re: [FFmpeg-devel] [PATCH] lavf/avi: pull stream durations from index, when available

2016-01-12 Thread Michael Niedermayer
On Mon, Jan 11, 2016 at 06:41:39PM -0600, Rodger Combs wrote:
> This fixes files that have an incorrect nb_frames but a valid index
> ---
>  libavformat/avidec.c | 1 +
>  1 file changed, 1 insertion(+)

can you share such a file ?

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

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


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


Re: [FFmpeg-devel] [PATCH] lavf/matroskadec: Use av_realloc() in get_qt_codec()

2016-01-12 Thread Michael Niedermayer
On Mon, Jan 11, 2016 at 07:43:29AM +0100, Mats Peterson wrote:
> Use av_realloc() rather than av_malloc() when normalizing noncompliant
> private data in get_qt_codec(). Based on your comments, Michael, it
> seems to be OK,

> and is more "elegant" in my book than using
> av_malloc()/memcpy()/av_free().

yes

appplied

thanks

[...]

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


Re: [FFmpeg-devel] [PATCH]lavc/x264: Improve level setting

2016-01-12 Thread Carl Eugen Hoyos
On Tuesday 12 January 2016 02:31:48 pm Michael Niedermayer wrote:
> > > > +level_id = atoi(x4->level);
> > >
> > > this should check that teres no "tail" after the integer
> >
> > For which command line will this make a difference?
> > I didn't find one...
>
> didnt try but i was thinking of something like 11.8

ffmpeg -f lavfi -i testsrc=s=hd1080 -pix_fmt yuv420p -t 1 
-level 11.8 -preset veryslow out.mov
ffmpeg version N-77804-gd64d6ed Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.7 (SUSE Linux)
  configuration: --enable-gpl --enable-libx264
  libavutil  55. 13.100 / 55. 13.100
  libavcodec 57. 22.100 / 57. 22.100
  libavformat57. 21.101 / 57. 21.101
  libavdevice57.  0.100 / 57.  0.100
  libavfilter 6. 23.100 /  6. 23.100
  libswscale  4.  0.100 /  4.  0.100
  libswresample   2.  0.101 /  2.  0.101
  libpostproc54.  0.100 / 54.  0.100
Input #0, lavfi, from 'testsrc=s=hd1080':
  Duration: N/A, start: 0.00, bitrate: N/A
Stream #0:0: Video: rawvideo (RGB[24] / 0x18424752), rgb24, 1920x1080 [SAR 
1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
[libx264 @ 0x29335c0] Error parsing option 'level' with value '11.8'.
Output #0, mov, to 'out.mov':
Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, SAR 1:1 DAR 0:0, 25 fps
Metadata:
  encoder : Lavc57.22.100 libx264
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Error while opening encoder for output stream #0:0 - maybe incorrect 
parameters such as bit_rate, rate, width or height

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


Re: [FFmpeg-devel] [PATCH]lavc/mjpeg2jpeg: Accept more mjpeg streams as input

2016-01-12 Thread Michael Niedermayer
On Tue, Jan 12, 2016 at 02:41:12PM +0100, Carl Eugen Hoyos wrote:
> On Tuesday 12 January 2016 02:28:28 pm Michael Niedermayer wrote:
> > On Tue, Jan 12, 2016 at 02:19:53PM +0100, Carl Eugen Hoyos wrote:
> > > On Tuesday 12 January 2016 02:16:52 pm Michael Niedermayer wrote:
> > > > On Tue, Jan 12, 2016 at 09:58:53AM +0100, Carl Eugen Hoyos wrote:
> > > > > -if (memcmp("AVI1", buf + 6, 4)) {
> > > > > -av_log(avctx, AV_LOG_ERROR, "input is not MJPEG/AVI1\n");
> > > > > -return AVERROR_INVALIDDATA;
> > > > > +if (buf[2] == 0xff && buf[3] == APP0) {
> > > > > +input_skip = (buf[4] << 8) + buf[5] + 4;
> > > > > +} else {
> > > > > +input_skip = 2;
> > > >
> > > > shouldnt the first 2 bytes that are being skiped be checked ?
> > >
> > > I don't know (possibly) but it seems unrelated to this patch:
> > > They are not checked now.
> >
> > true
> >
> > still before the patch 4 bytes are checked, afterwards none
> > these 4 bytes sort of imply that the previous bytes arent arbitrary
> >
> > if the 2 bytes are different from what is expected then the code
> > would potentially generate invalid output, or do i miss some check
> > elsewhere that would prevent that ?
> 
> New patch attached.
> 
> Please comment, Carl Eugen

>  mjpeg2jpeg_bsf.c |5 +
>  1 file changed, 5 insertions(+)
> a261f4350cbfeefc9c011cfc93fc39e5c4f7fe7c  patchmjpeg2jpgffd8.diff
> diff --git a/libavcodec/mjpeg2jpeg_bsf.c b/libavcodec/mjpeg2jpeg_bsf.c

LGTM

thx


[...]


-- 
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]lavc/mjpeg2jpeg: Accept more mjpeg streams as input

2016-01-12 Thread Michael Niedermayer
On Tue, Jan 12, 2016 at 02:19:53PM +0100, Carl Eugen Hoyos wrote:
> On Tuesday 12 January 2016 02:16:52 pm Michael Niedermayer wrote:
> > On Tue, Jan 12, 2016 at 09:58:53AM +0100, Carl Eugen Hoyos wrote:
> 
> > > -if (memcmp("AVI1", buf + 6, 4)) {
> > > -av_log(avctx, AV_LOG_ERROR, "input is not MJPEG/AVI1\n");
> > > -return AVERROR_INVALIDDATA;
> > > +if (buf[2] == 0xff && buf[3] == APP0) {
> > > +input_skip = (buf[4] << 8) + buf[5] + 4;
> > > +} else {
> > > +input_skip = 2;
> >
> > shouldnt the first 2 bytes that are being skiped be checked ?
> 
> I don't know (possibly) but it seems unrelated to this patch: 
> They are not checked now.

true

still before the patch 4 bytes are checked, afterwards none
these 4 bytes sort of imply that the previous bytes arent arbitrary

if the 2 bytes are different from what is expected then the code
would potentially generate invalid output, or do i miss some check
elsewhere that would prevent that ?


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

Everything should be made as simple as possible, but not simpler.
-- Albert Einstein


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


Re: [FFmpeg-devel] [PATCH]lavc/x264: Improve level setting

2016-01-12 Thread Michael Niedermayer
On Tue, Jan 12, 2016 at 02:10:08PM +0100, Carl Eugen Hoyos wrote:
> On Tuesday 12 January 2016 01:55:30 pm Michael Niedermayer wrote:
> > On Mon, Jan 11, 2016 at 10:58:55AM +0100, Carl Eugen Hoyos wrote:
> > > Hi!
> > >
> > > I guess that attached patch fixes the additional issue in ticket #3307.
> > >
> > > Please comment, Carl Eugen
> > >
> > >  libx264.c |2 ++
> > >  1 file changed, 2 insertions(+)
> > > cea8163693a2a78b9dc2d1929082e7c76ac542ac  patchx264level.diff
> > > diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> > > index 88406a3..c1e52a1 100644
> > > --- a/libavcodec/libx264.c
> > > +++ b/libavcodec/libx264.c
> > > @@ -559,6 +559,8 @@ static av_cold int X264_init(AVCodecContext *avctx)
> > >
> > >  if (!strcmp(x4->level, "1b")) {
> > >  level_id = 9;
> 
> > > +} else if (atoi(x4->level) > 9) {
> 
> Should be "> 8".
> 
> > > +level_id = atoi(x4->level);
> >
> > this should check that teres no "tail" after the integer
> 
> For which command line will this make a difference?
> I didn't find one...

didnt try but i was thinking of something like 11.8
whatever the user meant by that it likely shouldnt silently be
interpreted as 1.1, that could be rather confusing


> 
> New patch attached, Carl Eugen

>  libx264.c |2 ++
>  1 file changed, 2 insertions(+)
> 00dbf2a3deee89c56aaa0743c3f5cb90f2e4b5e0  patchx264level.diff
> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> index 88406a3..abb6985 100644
> --- a/libavcodec/libx264.c
> +++ b/libavcodec/libx264.c
> @@ -559,6 +559,8 @@ static av_cold int X264_init(AVCodecContext *avctx)
>  
>  if (!strcmp(x4->level, "1b")) {
>  level_id = 9;
> +} else if (av_strtod(x4->level, ) > 8.0 && !*tail) {

strtol or something


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides


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


Re: [FFmpeg-devel] [PATCH] lavf/matroskadec: Use av_realloc() in get_qt_codec()

2016-01-12 Thread Mats Peterson

On 01/12/2016 02:32 PM, Michael Niedermayer wrote:

On Mon, Jan 11, 2016 at 07:43:29AM +0100, Mats Peterson wrote:

Use av_realloc() rather than av_malloc() when normalizing noncompliant
private data in get_qt_codec(). Based on your comments, Michael, it
seems to be OK,



and is more "elegant" in my book than using
av_malloc()/memcpy()/av_free().


yes

appplied

thanks


Thanks, Michael.

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


Re: [FFmpeg-devel] [PATCH]lavc/mjpeg2jpeg: Accept more mjpeg streams as input

2016-01-12 Thread Michael Niedermayer
On Tue, Jan 12, 2016 at 09:58:53AM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> I guess that attached patch fixes ticket #5151.
> It is the user's responsibility to know if the input stream 
> is suitable for the bitstream filter or not.
> 
> Please comment, Carl Eugen

>  mjpeg2jpeg_bsf.c |9 +
>  1 file changed, 5 insertions(+), 4 deletions(-)
> 6d36c24e50d0ba2484b959c5f315de919c57ae5f  patchmjpeg2jpg.diff
> diff --git a/libavcodec/mjpeg2jpeg_bsf.c b/libavcodec/mjpeg2jpeg_bsf.c
> index 68640db..b29039e 100644
> --- a/libavcodec/mjpeg2jpeg_bsf.c
> +++ b/libavcodec/mjpeg2jpeg_bsf.c
> @@ -31,6 +31,7 @@
>  
>  #include "avcodec.h"
>  #include "jpegtables.h"
> +#include "mjpeg.h"
>  
>  static const uint8_t jpeg_header[] = {
>  0xff, 0xd8, // SOI
> @@ -88,11 +89,11 @@ static int mjpeg2jpeg_filter(AVBitStreamFilterContext 
> *bsfc,
>  av_log(avctx, AV_LOG_ERROR, "input is truncated\n");
>  return AVERROR_INVALIDDATA;
>  }
> -if (memcmp("AVI1", buf + 6, 4)) {
> -av_log(avctx, AV_LOG_ERROR, "input is not MJPEG/AVI1\n");
> -return AVERROR_INVALIDDATA;
> +if (buf[2] == 0xff && buf[3] == APP0) {
> +input_skip = (buf[4] << 8) + buf[5] + 4;
> +} else {
> +input_skip = 2;

shouldnt the first 2 bytes that are being skiped be checked ?


[...]


-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.


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


Re: [FFmpeg-devel] [PATCH]lavc/mjpeg2jpeg: Accept more mjpeg streams as input

2016-01-12 Thread Carl Eugen Hoyos
On Tuesday 12 January 2016 02:28:28 pm Michael Niedermayer wrote:
> On Tue, Jan 12, 2016 at 02:19:53PM +0100, Carl Eugen Hoyos wrote:
> > On Tuesday 12 January 2016 02:16:52 pm Michael Niedermayer wrote:
> > > On Tue, Jan 12, 2016 at 09:58:53AM +0100, Carl Eugen Hoyos wrote:
> > > > -if (memcmp("AVI1", buf + 6, 4)) {
> > > > -av_log(avctx, AV_LOG_ERROR, "input is not MJPEG/AVI1\n");
> > > > -return AVERROR_INVALIDDATA;
> > > > +if (buf[2] == 0xff && buf[3] == APP0) {
> > > > +input_skip = (buf[4] << 8) + buf[5] + 4;
> > > > +} else {
> > > > +input_skip = 2;
> > >
> > > shouldnt the first 2 bytes that are being skiped be checked ?
> >
> > I don't know (possibly) but it seems unrelated to this patch:
> > They are not checked now.
>
> true
>
> still before the patch 4 bytes are checked, afterwards none
> these 4 bytes sort of imply that the previous bytes arent arbitrary
>
> if the 2 bytes are different from what is expected then the code
> would potentially generate invalid output, or do i miss some check
> elsewhere that would prevent that ?

New patch attached.

Please comment, Carl Eugen
diff --git a/libavcodec/mjpeg2jpeg_bsf.c b/libavcodec/mjpeg2jpeg_bsf.c
index 68640db..71f0154 100644
--- a/libavcodec/mjpeg2jpeg_bsf.c
+++ b/libavcodec/mjpeg2jpeg_bsf.c
@@ -28,6 +28,7 @@
 
 #include "libavutil/error.h"
 #include "libavutil/mem.h"
+#include "libavutil/intreadwrite.h"
 
 #include "avcodec.h"
 #include "jpegtables.h"
@@ -88,6 +89,10 @@ static int mjpeg2jpeg_filter(AVBitStreamFilterContext *bsfc,
 av_log(avctx, AV_LOG_ERROR, "input is truncated\n");
 return AVERROR_INVALIDDATA;
 }
+if (AV_RB16(buf) != 0xffd8) {
+av_log(avctx, AV_LOG_ERROR, "input is not MJPEG\n");
+return AVERROR_INVALIDDATA;
+}
 if (memcmp("AVI1", buf + 6, 4)) {
 av_log(avctx, AV_LOG_ERROR, "input is not MJPEG/AVI1\n");
 return AVERROR_INVALIDDATA;
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libvpxdec: fix 'ISO C90 forbids mixed declarations and code' warning

2016-01-12 Thread Ronald S. Bultje
Hi,

On Tue, Jan 12, 2016 at 1:43 AM, James Zern  wrote:

> since:
> cbcc88c libvpx: Support setting color range for vp9.
>
> Signed-off-by: James Zern 
> ---
>  libavcodec/libvpxdec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavcodec/libvpxdec.c b/libavcodec/libvpxdec.c
> index de72be9..b51bfa2 100644
> --- a/libavcodec/libvpxdec.c
> +++ b/libavcodec/libvpxdec.c
> @@ -68,13 +68,13 @@ static int set_pix_fmt(AVCodecContext *avctx, struct
> vpx_image *img)
>  AVCOL_SPC_UNSPECIFIED, AVCOL_SPC_BT470BG, AVCOL_SPC_BT709,
> AVCOL_SPC_SMPTE170M,
>  AVCOL_SPC_SMPTE240M, AVCOL_SPC_BT2020_NCL, AVCOL_SPC_RESERVED,
> AVCOL_SPC_RGB,
>  };
> -avctx->colorspace = colorspaces[img->cs];
>  #if VPX_IMAGE_ABI_VERSION >= 4
>  static const enum AVColorRange color_ranges[] = {
>  AVCOL_RANGE_MPEG, AVCOL_RANGE_JPEG
>  };
>  avctx->color_range = color_ranges[img->range];
>  #endif
> +avctx->colorspace = colorspaces[img->cs];
>  #endif
>  if (avctx->codec_id == AV_CODEC_ID_VP8 && img->fmt !=
> VPX_IMG_FMT_I420)
>  return AVERROR_INVALIDDATA;
> --
> 2.6.0.rc2.230.g3dd15c0


lgtm, thanks.

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


Re: [FFmpeg-devel] [PATCH]lavf/icodec: Improve probe function

2016-01-12 Thread Michael Niedermayer
On Tue, Jan 12, 2016 at 01:49:37PM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> On Tuesday 12 January 2016 01:33:53 pm Carl Eugen Hoyos wrote:
> >
> > Attached patch improves ico probing, previously mpeg-2 frames could be
> > detected.
> 
> Wikipedia claims that planes can be 0, new patch attached.
> 
> Carl Eugen

>  icodec.c |8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 5587972d12000a679757c9b42947869eb1cee0f5  patchico.diff
> diff --git a/libavformat/icodec.c b/libavformat/icodec.c
> index 22e2099..4d6e6dc 100644

tools/probetest 256 4096
testing size=1
testing size=2
testing size=4
testing size=8
Failure of ico probing code with score=26 type=1 p=EA6 size=8
testing size=16

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus


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


Re: [FFmpeg-devel] [PATCH 00/13] check all fclose usage

2016-01-12 Thread Ganesh Ajjanagadde
On Tue, Jan 12, 2016 at 1:18 PM, Paul B Mahol  wrote:
> On 1/12/16, Ganesh Ajjanagadde  wrote:
>> On Tue, Jan 12, 2016 at 10:29 AM, Ronald S. Bultje 
>> wrote:
>>> Hi,
>>>
>>> On Tue, Jan 12, 2016 at 10:07 AM, Ganesh Ajjanagadde 
>>> wrote:
>>>
 On Tue, Jan 12, 2016 at 9:43 AM, Ronald S. Bultje 
 wrote:
 > Hi,
 >
 > On Tue, Jan 12, 2016 at 7:52 AM, Ganesh Ajjanagadde 
 > wrote:
 >
 >> On Tue, Jan 12, 2016 at 4:38 AM, wm4  wrote:
 >> > This makes no sense. Even if fclose() should fail for
 >> > whatever obscure reasons there might be, reading already worked
 >> > without errors, and thus closing failure has no meaning to use.
 >>
 >> Well, reading may not have worked, and the fclose may have been called
 >> in a failure path.
 >
 >
 > Then the error should be in the code path of fread(), not fclose().
 > Displaying an error (in whatever way) related to close while the actual
 > problem was reading data is going to be confusing to the user.

 Read the rest of it; checking for every fread/fseek is not productive;
 there are at least 3 of fread/fseek in the example I gave. Printing at
 the time of closure is a natural means of doing things, again see:
 https://www.gnu.org/ghm/2011/paris/slides/jim-meyering-goodbye-world.pdf
 (particularly slide 7).
>>>
>>>
>>> He's very smart, but you still have to see his advice in context, also see
>>> [1].
>>
>> The question of his smartness is irrelevant, as is the appeal to
>> authority definition here.
>>
>>>
>>> Most production uses of ffmpeg involve long-running processes in a
>>> multi-component pipeline, where fail-to-read will cause errors downstream.
>>> Reading the file from disk is only one small component. Let's say that I
>>> read a buffer of 10 bytes but I only got 5 because whatever went wrong. I
>>> parse the input buffer of 5 bytes, it's obviously corrupt, decoding stream
>>> goes wrong, and the decoder displays error ("ffvp9: corrupt input stream,
>>> failed to decode"). Note how this is the topmost error in stderr,
>>> therefore
>>> the user (logically) thinks: "FFmpeg's decoder sucks. FFmpeg sucks."
>>> That's
>>> bad. [2]
>>
>> If the fread is unchecked, that is a separate issue. At least for the
>> example I gave, the fread is checked. However, there is little (if
>> anything) that gets logged, since only the return value is set. The
>> question is where/what to log, if any.
>>
>> Instead of making such generic statements, please post comments to the
>> actual patches; the discussion will be more productive.
>>
>>>
>>> The first error should (ideally) be indicative of the actual problem. So,
>>> if the read is the error, the error should be associated with that read
>>> early on to help the user diagnose the actual source of the problem.
>>
>> Well, how about littering the code all over the place for every
>> read/seek/puts, etc so that your "ideal" can be met.
>>
>>>
>>> Ronald
>>>
>>> [1] https://en.wikipedia.org/wiki/Argument_from_authority
>>> [2] 10s or 1000s of bytes or frames failing to decode later, there's some
>>> little error saying the file descriptor failed to close. Did you ever look
>>> at line 1000 in your error log?
>>
>> There is something called grep. And ironically your proposed idea of
>> logging at the fread does not help with this either.
>
> Why the stuff I post have no comments at all?
> But this marginal functionality is commented so much.

It takes almost no effort to write endlesslessly on simple things.
More complex patches take greater effort on the part of the reviewer,
and will draw fewer replies.

It also is in the nature of the work I have taken up, and the quite
different perspective I have from many others here. This draws noise.
I try not to react to the useless flame bait, but unfortunately fail
at that sometimes. As a zeroth order approximation, one can say that I
am a technical purist and many others here are pragmatists. Nothing on
ffmpeg-devel or IRC so far has convinced me of the superiority of the
"pragmatist" approach. If anything, things like
https://ffmpeg.org/pipermail/ffmpeg-devel/2015-December/186109.html,
https://ffmpeg.org/pipermail/ffmpeg-devel/2016-January/186363.html vs
https://lists.ffmpeg.org/pipermail/ffmpeg-devel-irc/2015-December/003293.html
(first comment from atomnuker) make me value technical purity.

I wish I could simply let go of these things and work on actual stuff.
The problem is that I have too many silly things like this on my todo
list that are extremely low hanging, and trouble me when I see them. I
don't like working on them at all, and still less dealing with useless
comments. The problem is that very few work on it and it troubles me,
so I take it upon myself.

What astonishes me is that when essentially every C/systems
programming resource asks 

Re: [FFmpeg-devel] [PATCH] qtpalette: make the color_* variables unsigned again

2016-01-12 Thread Andreas Cadhalpun
On 12.01.2016 03:26, Ronald S. Bultje wrote:
> On Mon, Jan 11, 2016 at 12:06 AM, Mats Peterson <
>> On 01/10/2016 11:56 AM, Andreas Cadhalpun wrote:
>>> --- a/libavformat/qtpalette.c
>>> +++ b/libavformat/qtpalette.c
>>> @@ -48,7 +48,7 @@ int ff_get_qtpalette(int codec_id, AVIOContext *pb,
>>> uint32_t *palette)
>>>
>>>   /* If the depth is 1, 2, 4, or 8 bpp, file is palettized. */
>>>   if ((bit_depth == 1 || bit_depth == 2 || bit_depth == 4 ||
>>> bit_depth == 8)) {
>>> -int color_count, color_start, color_end;
>>> +uint32_t color_count, color_start, color_end;
>>>   uint32_t a, r, g, b;
>>>
>>>   /* Ignore the greyscale bit for 1-bit video and sample
>>>
>>>
>> ping
> 
> 
> Why are we using stdint types for non-vector data here? Our custom has
> always been to used sized (stdint-style) data only for vector data (arrays
> etc.), and use native-sized types (e.g. unsigned, int, whatever) for scalar
> values. Why are we making exceptions here?

I can't find this convention in our coding rules[1].
The main reason why I used uint32_t instead of unsigned here was consistency
with the line below. But as Ganesh explained it makes prefect sense to use
uint32_t at least for color_start.

Best regards,
Andreas


1: https://ffmpeg.org/developer.html#Coding-Rules-1

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


Re: [FFmpeg-devel] [PATCH]lavf/icodec: Improve probe function

2016-01-12 Thread Carl Eugen Hoyos
Hi!

On Tuesday 12 January 2016 01:33:53 pm Carl Eugen Hoyos wrote:
>
> Attached patch improves ico probing, previously mpeg-2 frames could be
> detected.

Wikipedia claims that planes can be 0, new patch attached.

Carl Eugen
diff --git a/libavformat/icodec.c b/libavformat/icodec.c
index 22e2099..4d6e6dc 100644
--- a/libavformat/icodec.c
+++ b/libavformat/icodec.c
@@ -44,8 +44,12 @@ typedef struct {
 
 static int probe(AVProbeData *p)
 {
-if (AV_RL16(p->buf) == 0 && AV_RL16(p->buf + 2) == 1 && AV_RL16(p->buf + 
4))
-return AVPROBE_SCORE_MAX / 4;
+if (   AV_RL16(p->buf) == 0
+&& AV_RL16(p->buf + 2) == 1
+&& AV_RL16(p->buf + 4)
+&& !(AV_RL16(p->buf + 10) & ~1)
+&& !p->buf[13])
+return AVPROBE_SCORE_MAX / 4 + 1;
 return 0;
 }
 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavc/x264: Improve level setting

2016-01-12 Thread Michael Niedermayer
On Mon, Jan 11, 2016 at 10:58:55AM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> I guess that attached patch fixes the additional issue in ticket #3307.
> 
> Please comment, Carl Eugen

>  libx264.c |2 ++
>  1 file changed, 2 insertions(+)
> cea8163693a2a78b9dc2d1929082e7c76ac542ac  patchx264level.diff
> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> index 88406a3..c1e52a1 100644
> --- a/libavcodec/libx264.c
> +++ b/libavcodec/libx264.c
> @@ -559,6 +559,8 @@ static av_cold int X264_init(AVCodecContext *avctx)
>  
>  if (!strcmp(x4->level, "1b")) {
>  level_id = 9;
> +} else if (atoi(x4->level) > 9) {
> +level_id = atoi(x4->level);

this should check that teres no "tail" after the integer

[...]

-- 
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] ffmpeg_opt: check fclose return value

2016-01-12 Thread Michael Niedermayer
On Mon, Jan 11, 2016 at 05:35:17PM -0500, Ganesh Ajjanagadde wrote:
> This one may be slightly more theoretical, since the preset file is opened in 
> a
> read-only mode. Nevertheless, it is a good idea to check its return value.
> 
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  ffmpeg_opt.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)

probably ok

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

No great genius has ever existed without some touch of madness. -- Aristotle


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


Re: [FFmpeg-devel] [PATCH]lavc/x264: Improve level setting

2016-01-12 Thread Carl Eugen Hoyos
On Tuesday 12 January 2016 01:55:30 pm Michael Niedermayer wrote:
> On Mon, Jan 11, 2016 at 10:58:55AM +0100, Carl Eugen Hoyos wrote:
> > Hi!
> >
> > I guess that attached patch fixes the additional issue in ticket #3307.
> >
> > Please comment, Carl Eugen
> >
> >  libx264.c |2 ++
> >  1 file changed, 2 insertions(+)
> > cea8163693a2a78b9dc2d1929082e7c76ac542ac  patchx264level.diff
> > diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
> > index 88406a3..c1e52a1 100644
> > --- a/libavcodec/libx264.c
> > +++ b/libavcodec/libx264.c
> > @@ -559,6 +559,8 @@ static av_cold int X264_init(AVCodecContext *avctx)
> >
> >  if (!strcmp(x4->level, "1b")) {
> >  level_id = 9;

> > +} else if (atoi(x4->level) > 9) {

Should be "> 8".

> > +level_id = atoi(x4->level);
>
> this should check that teres no "tail" after the integer

For which command line will this make a difference?
I didn't find one...

New patch attached, Carl Eugen
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 88406a3..abb6985 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -559,6 +559,8 @@ static av_cold int X264_init(AVCodecContext *avctx)
 
 if (!strcmp(x4->level, "1b")) {
 level_id = 9;
+} else if (av_strtod(x4->level, ) > 8.0 && !*tail) {
+level_id = atoi(x4->level);
 } else if (strlen(x4->level) <= 3){
 level_id = av_strtod(x4->level, ) * 10 + 0.5;
 if (*tail)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 05/13] lavfi/vf_psnr: check fclose return value

2016-01-12 Thread Ganesh Ajjanagadde
On Tue, Jan 12, 2016 at 3:32 AM, Paul B Mahol  wrote:
> On 1/12/16, Ganesh Ajjanagadde  wrote:
>> Signed-off-by: Ganesh Ajjanagadde 
>> ---
>>  libavfilter/vf_psnr.c | 5 -
>>  1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavfilter/vf_psnr.c b/libavfilter/vf_psnr.c
>> index bce5c51..b6e7f06 100644
>> --- a/libavfilter/vf_psnr.c
>> +++ b/libavfilter/vf_psnr.c
>> @@ -339,7 +339,10 @@ static av_cold void uninit(AVFilterContext *ctx)
>>  ff_dualinput_uninit(>dinput);
>>
>>  if (s->stats_file && s->stats_file != stdout)
>> -fclose(s->stats_file);
>> +if (fclose(s->stats_file))
>> +av_log(NULL, AV_LOG_ERROR,
>> +   "Unable to close file '%s', loss of information
>> possible: %s\n",
>> +   s->stats_file_str, av_err2str(AVERROR(errno)));
>>  }
>>
>>  static const AVFilterPad psnr_inputs[] = {
>> --
>> 2.7.0
>>
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>
> Please use context for av_log here and in other patches if available.

Forgot about this in some of the patches. Noted, thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v2] libi264: Add Hardware Accelerated H.264 Encoder based on libVA

2016-01-12 Thread Hendrik Leppkes
On Tue, Jan 12, 2016 at 9:26 PM, compn  wrote:
> On Tue, 12 Jan 2016 10:44:18 -0600
> Will Kelleher  wrote:
>
>> That said, it doesn't look like any of the previous review comments
>> (which I agree with) were addressed in this second version.  Let me
>> know if there is anything I can do to help.
>
> some devs made comments that it cannot use colorspace conversion,
> because colorspace conversion code belongs in swscale.
>
> now they complain that there is a swscale dep.
>
> so what do these devs want? heh.

We want it to define its native input format, and let the generic code
in ffmpeg.c etc handle conversion to the appropriate format.

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


[FFmpeg-devel] [PATCH] avfilter: add spectrumsynth filter

2016-01-12 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 doc/filters.texi|  25 +++
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vaf_spectrumsynth.c | 447 
 4 files changed, 474 insertions(+)
 create mode 100644 libavfilter/vaf_spectrumsynth.c

diff --git a/doc/filters.texi b/doc/filters.texi
index 45d22f4..2f4b6ee 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -15003,6 +15003,31 @@ ffmpeg -i audio.mp3 -filter_complex 
"showwavespic,colorchannelmixer=rr=66/255:gg
 @end example
 @end itemize
 
+@section spectrumsynth
+
+Sythesize audio from 2 input video spectrums, first input stream represents
+magnitude across time and second represents phase across time.
+The filter will transform from frequency domain as displayed in videos back
+to time domain as presented in audio output.
+
+The filter accepts the following options:
+
+@table @option
+@item sample_rate
+Specify sample rate of output audio, the sample rate of audio from which
+spectrum was generated may differ.
+
+@item channels
+Set number of channels represented in input video spectrums.
+
+@item win_func
+Set window function used for resynthesis.
+
+@item overlap
+Set window overlap. In range @code{[0, 1]}. Default is @code{1},
+which means optimal overlap for selected window function will be picked.
+@end table
+
 @section split, asplit
 
 Split input into several identical outputs.
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 689da73..9257a92 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -290,6 +290,7 @@ OBJS-$(CONFIG_SHOWSPECTRUMPIC_FILTER)+= 
avf_showspectrum.o window_func.o
 OBJS-$(CONFIG_SHOWVOLUME_FILTER) += avf_showvolume.o
 OBJS-$(CONFIG_SHOWWAVES_FILTER)  += avf_showwaves.o
 OBJS-$(CONFIG_SHOWWAVESPIC_FILTER)   += avf_showwaves.o
+OBJS-$(CONFIG_SPECTRUMSYNTH_FILTER)  += vaf_spectrumsynth.o 
window_func.o
 
 # multimedia sources
 OBJS-$(CONFIG_AMOVIE_FILTER) += src_movie.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 2267e88..d4815d6 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -310,6 +310,7 @@ void avfilter_register_all(void)
 REGISTER_FILTER(SHOWVOLUME, showvolume, avf);
 REGISTER_FILTER(SHOWWAVES,  showwaves,  avf);
 REGISTER_FILTER(SHOWWAVESPIC,   showwavespic,   avf);
+REGISTER_FILTER(SPECTRUMSYNTH,  spectrumsynth,  vaf);
 
 /* multimedia sources */
 REGISTER_FILTER(AMOVIE, amovie, avsrc);
diff --git a/libavfilter/vaf_spectrumsynth.c b/libavfilter/vaf_spectrumsynth.c
new file mode 100644
index 000..6f09614
--- /dev/null
+++ b/libavfilter/vaf_spectrumsynth.c
@@ -0,0 +1,447 @@
+/*
+ * Copyright (c) 2016 Paul B Mahol
+ *
+ * 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 "libavcodec/avfft.h"
+#include "libavutil/avassert.h"
+#include "libavutil/channel_layout.h"
+#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "audio.h"
+#include "video.h"
+#include "internal.h"
+#include "window_func.h"
+
+enum MagnitudeScale { LINEAR, LOG, NB_SCALES };
+
+typedef struct SpectrumSynthContext {
+const AVClass *class;
+int sample_rate;
+int channels;
+int scale;
+int win_func;
+
+AVFrame *magnitude, *phase;
+FFTContext *fft;///< Fast Fourier Transform context
+int fft_bits;   ///< number of bits (FFT window size = 
1<

Re: [FFmpeg-devel] [PATCH v2] libi264: Add Hardware Accelerated H.264 Encoder based on libVA

2016-01-12 Thread compn
On Tue, 12 Jan 2016 10:44:18 -0600
Will Kelleher  wrote:

> That said, it doesn't look like any of the previous review comments
> (which I agree with) were addressed in this second version.  Let me
> know if there is anything I can do to help.

some devs made comments that it cannot use colorspace conversion,
because colorspace conversion code belongs in swscale.

now they complain that there is a swscale dep.

so what do these devs want? heh.

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


Re: [FFmpeg-devel] [PATCH] diracdec: Add slice threading to HQ profile

2016-01-12 Thread Michael Niedermayer
On Tue, Jan 12, 2016 at 01:01:24AM +, Kieran Kunhya wrote:
> 

>  diracdec.c |   38 ++
>  1 file changed, 30 insertions(+), 8 deletions(-)
> 73ce8405d52477db0faa2a2b76daca698a49bff2  
> 0001-diracdec-Add-slice-threading-to-HQ-profile.patch
> From f01ac52d8f5bddeb4bb23f41e883776e25406597 Mon Sep 17 00:00:00 2001
> From: Kieran Kunhya 
> Date: Tue, 12 Jan 2016 00:51:49 +
> Subject: [PATCH] diracdec: Add slice threading to HQ profile

LGTM

the loop could be factored out though 

thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus


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


Re: [FFmpeg-devel] [PATCH 00/13] check all fclose usage

2016-01-12 Thread Ronald S. Bultje
Hi,

On Tue, Jan 12, 2016 at 7:52 AM, Ganesh Ajjanagadde 
wrote:

> On Tue, Jan 12, 2016 at 4:38 AM, wm4  wrote:
> > This makes no sense. Even if fclose() should fail for
> > whatever obscure reasons there might be, reading already worked
> > without errors, and thus closing failure has no meaning to use.
>
> Well, reading may not have worked, and the fclose may have been called
> in a failure path.


Then the error should be in the code path of fread(), not fclose().
Displaying an error (in whatever way) related to close while the actual
problem was reading data is going to be confusing to the user.

> Just what is the point?
>
> Can you please stop trolling patches with such gratuitous statements at
> the end?


... Can we not be defensive, please? ...

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


Re: [FFmpeg-devel] [PATCH 00/13] check all fclose usage

2016-01-12 Thread Ganesh Ajjanagadde
On Tue, Jan 12, 2016 at 9:43 AM, Ronald S. Bultje  wrote:
> Hi,
>
> On Tue, Jan 12, 2016 at 7:52 AM, Ganesh Ajjanagadde 
> wrote:
>
>> On Tue, Jan 12, 2016 at 4:38 AM, wm4  wrote:
>> > This makes no sense. Even if fclose() should fail for
>> > whatever obscure reasons there might be, reading already worked
>> > without errors, and thus closing failure has no meaning to use.
>>
>> Well, reading may not have worked, and the fclose may have been called
>> in a failure path.
>
>
> Then the error should be in the code path of fread(), not fclose().
> Displaying an error (in whatever way) related to close while the actual
> problem was reading data is going to be confusing to the user.

Read the rest of it; checking for every fread/fseek is not productive;
there are at least 3 of fread/fseek in the example I gave. Printing at
the time of closure is a natural means of doing things, again see:
https://www.gnu.org/ghm/2011/paris/slides/jim-meyering-goodbye-world.pdf
(particularly slide 7).

Again, this is more important for write than read. Or put in other
words: if the approach of checking at close is going to be nacked no
matter what the contents of the message is; I will wash my hands off
this issue wrt files opened read-only.

>
>> Just what is the point?
>>
>> Can you please stop trolling patches with such gratuitous statements at
>> the end?
>
>
> ... Can we not be defensive, please? ...

There was nothing "defensive" here. Can you stop dismissing technical
comments as "defensive"? This is not the first time you are doing
this, and not the first time wm4 has added such useless, provocative
statements...

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


Re: [FFmpeg-devel] [PATCH]lavc/mjpeg2jpeg: Accept more mjpeg streams as input

2016-01-12 Thread Carl Eugen Hoyos
On Tuesday 12 January 2016 03:19:24 pm Michael Niedermayer wrote:
> >  mjpeg2jpeg_bsf.c |5 +
> >  1 file changed, 5 insertions(+)
> > a261f4350cbfeefc9c011cfc93fc39e5c4f7fe7c  patchmjpeg2jpgffd8.diff
> > diff --git a/libavcodec/mjpeg2jpeg_bsf.c b/libavcodec/mjpeg2jpeg_bsf.c
>
> LGTM

Patch applied.

New patch attached that fixes ticket #5151.

Thank you, Carl Eugen
diff --git a/libavcodec/mjpeg2jpeg_bsf.c b/libavcodec/mjpeg2jpeg_bsf.c
index 71f0154..92dc3ca 100644
--- a/libavcodec/mjpeg2jpeg_bsf.c
+++ b/libavcodec/mjpeg2jpeg_bsf.c
@@ -32,6 +32,7 @@
 
 #include "avcodec.h"
 #include "jpegtables.h"
+#include "mjpeg.h"
 
 static const uint8_t jpeg_header[] = {
 0xff, 0xd8, // SOI
@@ -93,11 +94,11 @@ static int mjpeg2jpeg_filter(AVBitStreamFilterContext *bsfc,
 av_log(avctx, AV_LOG_ERROR, "input is not MJPEG\n");
 return AVERROR_INVALIDDATA;
 }
-if (memcmp("AVI1", buf + 6, 4)) {
-av_log(avctx, AV_LOG_ERROR, "input is not MJPEG/AVI1\n");
-return AVERROR_INVALIDDATA;
+if (buf[2] == 0xff && buf[3] == APP0) {
+input_skip = (buf[4] << 8) + buf[5] + 4;
+} else {
+input_skip = 2;
 }
-input_skip = (buf[4] << 8) + buf[5] + 4;
 if (buf_size < input_skip) {
 av_log(avctx, AV_LOG_ERROR, "input is truncated\n");
 return AVERROR_INVALIDDATA;
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 00/13] check all fclose usage

2016-01-12 Thread Ronald S. Bultje
Hi,

On Tue, Jan 12, 2016 at 10:07 AM, Ganesh Ajjanagadde 
wrote:

> On Tue, Jan 12, 2016 at 9:43 AM, Ronald S. Bultje 
> wrote:
> > Hi,
> >
> > On Tue, Jan 12, 2016 at 7:52 AM, Ganesh Ajjanagadde 
> > wrote:
> >
> >> On Tue, Jan 12, 2016 at 4:38 AM, wm4  wrote:
> >> > This makes no sense. Even if fclose() should fail for
> >> > whatever obscure reasons there might be, reading already worked
> >> > without errors, and thus closing failure has no meaning to use.
> >>
> >> Well, reading may not have worked, and the fclose may have been called
> >> in a failure path.
> >
> >
> > Then the error should be in the code path of fread(), not fclose().
> > Displaying an error (in whatever way) related to close while the actual
> > problem was reading data is going to be confusing to the user.
>
> Read the rest of it; checking for every fread/fseek is not productive;
> there are at least 3 of fread/fseek in the example I gave. Printing at
> the time of closure is a natural means of doing things, again see:
> https://www.gnu.org/ghm/2011/paris/slides/jim-meyering-goodbye-world.pdf
> (particularly slide 7).


He's very smart, but you still have to see his advice in context, also see
[1].

Most production uses of ffmpeg involve long-running processes in a
multi-component pipeline, where fail-to-read will cause errors downstream.
Reading the file from disk is only one small component. Let's say that I
read a buffer of 10 bytes but I only got 5 because whatever went wrong. I
parse the input buffer of 5 bytes, it's obviously corrupt, decoding stream
goes wrong, and the decoder displays error ("ffvp9: corrupt input stream,
failed to decode"). Note how this is the topmost error in stderr, therefore
the user (logically) thinks: "FFmpeg's decoder sucks. FFmpeg sucks." That's
bad. [2]

The first error should (ideally) be indicative of the actual problem. So,
if the read is the error, the error should be associated with that read
early on to help the user diagnose the actual source of the problem.

Ronald

[1] https://en.wikipedia.org/wiki/Argument_from_authority
[2] 10s or 1000s of bytes or frames failing to decode later, there's some
little error saying the file descriptor failed to close. Did you ever look
at line 1000 in your error log?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavf/icodec: Improve probe function

2016-01-12 Thread Carl Eugen Hoyos
On Tuesday 12 January 2016 02:49:59 pm Michael Niedermayer wrote:
> On Tue, Jan 12, 2016 at 01:49:37PM +0100, Carl Eugen Hoyos wrote:
> > Hi!
> >
> > On Tuesday 12 January 2016 01:33:53 pm Carl Eugen Hoyos wrote:
> > > Attached patch improves ico probing, previously mpeg-2 frames could be
> > > detected.
> >
> > Wikipedia claims that planes can be 0, new patch attached.
> >
> > Carl Eugen
> >
> >  icodec.c |8 ++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> > 5587972d12000a679757c9b42947869eb1cee0f5  patchico.diff
> > diff --git a/libavformat/icodec.c b/libavformat/icodec.c
> > index 22e2099..4d6e6dc 100644
>
> tools/probetest 256 4096
> testing size=1
> testing size=2
> testing size=4
> testing size=8
> Failure of ico probing code with score=26 type=1 p=EA6 size=8

Before the old patch, 32 bits were tested and return a value of 25, 
after the patch, 55 bits were tested and returned 26.
Imo, this just shows that probetest cannot see every possible issue.

Improved patch attached.

Carl Eugen
diff --git a/libavformat/icodec.c b/libavformat/icodec.c
index 22e2099..9cf3dca 100644
--- a/libavformat/icodec.c
+++ b/libavformat/icodec.c
@@ -27,6 +27,7 @@
 #include "libavutil/intreadwrite.h"
 #include "libavcodec/bytestream.h"
 #include "libavcodec/bmp.h"
+#include "libavcodec/png.h"
 #include "avformat.h"
 #include "internal.h"
 
@@ -44,9 +45,30 @@ typedef struct {
 
 static int probe(AVProbeData *p)
 {
-if (AV_RL16(p->buf) == 0 && AV_RL16(p->buf + 2) == 1 && AV_RL16(p->buf + 
4))
-return AVPROBE_SCORE_MAX / 4;
-return 0;
+unsigned i, frames = AV_RL16(p->buf + 4);
+
+if (AV_RL16(p->buf) || AV_RL16(p->buf + 2) != 1 || !frames)
+return 0;
+for (i = 0; i < frames; i++) {
+unsigned offset;
+if (AV_RL16(p->buf + 10 + i * 16) & ~1)
+return FFMIN(i, AVPROBE_SCORE_MAX / 4);
+if (p->buf[13 + i * 16])
+return FFMIN(i, AVPROBE_SCORE_MAX / 4);
+if (AV_RL32(p->buf + 14 + i * 16) < 40)
+return FFMIN(i, AVPROBE_SCORE_MAX / 4);
+offset = AV_RL32(p->buf + 18 + i * 16);
+if (offset < 22)
+return FFMIN(i, AVPROBE_SCORE_MAX / 4);
+if (offset + 8 > p->buf_size)
+return AVPROBE_SCORE_MAX / 4 + FFMIN(i, 1);
+if (p->buf[offset] != 40 && AV_RB64(p->buf + offset) != PNGSIG)
+return FFMIN(i, AVPROBE_SCORE_MAX / 4);
+if (i * 16 + 6 > p->buf_size)
+return AVPROBE_SCORE_MAX / 4;
+}
+
+return AVPROBE_SCORE_MAX / 4 + 1;
 }
 
 static int read_header(AVFormatContext *s)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 00/13] check all fclose usage

2016-01-12 Thread Ganesh Ajjanagadde
On Tue, Jan 12, 2016 at 10:29 AM, Ronald S. Bultje  wrote:
> Hi,
>
> On Tue, Jan 12, 2016 at 10:07 AM, Ganesh Ajjanagadde 
> wrote:
>
>> On Tue, Jan 12, 2016 at 9:43 AM, Ronald S. Bultje 
>> wrote:
>> > Hi,
>> >
>> > On Tue, Jan 12, 2016 at 7:52 AM, Ganesh Ajjanagadde 
>> > wrote:
>> >
>> >> On Tue, Jan 12, 2016 at 4:38 AM, wm4  wrote:
>> >> > This makes no sense. Even if fclose() should fail for
>> >> > whatever obscure reasons there might be, reading already worked
>> >> > without errors, and thus closing failure has no meaning to use.
>> >>
>> >> Well, reading may not have worked, and the fclose may have been called
>> >> in a failure path.
>> >
>> >
>> > Then the error should be in the code path of fread(), not fclose().
>> > Displaying an error (in whatever way) related to close while the actual
>> > problem was reading data is going to be confusing to the user.
>>
>> Read the rest of it; checking for every fread/fseek is not productive;
>> there are at least 3 of fread/fseek in the example I gave. Printing at
>> the time of closure is a natural means of doing things, again see:
>> https://www.gnu.org/ghm/2011/paris/slides/jim-meyering-goodbye-world.pdf
>> (particularly slide 7).
>
>
> He's very smart, but you still have to see his advice in context, also see
> [1].

The question of his smartness is irrelevant, as is the appeal to
authority definition here.

>
> Most production uses of ffmpeg involve long-running processes in a
> multi-component pipeline, where fail-to-read will cause errors downstream.
> Reading the file from disk is only one small component. Let's say that I
> read a buffer of 10 bytes but I only got 5 because whatever went wrong. I
> parse the input buffer of 5 bytes, it's obviously corrupt, decoding stream
> goes wrong, and the decoder displays error ("ffvp9: corrupt input stream,
> failed to decode"). Note how this is the topmost error in stderr, therefore
> the user (logically) thinks: "FFmpeg's decoder sucks. FFmpeg sucks." That's
> bad. [2]

If the fread is unchecked, that is a separate issue. At least for the
example I gave, the fread is checked. However, there is little (if
anything) that gets logged, since only the return value is set. The
question is where/what to log, if any.

Instead of making such generic statements, please post comments to the
actual patches; the discussion will be more productive.

>
> The first error should (ideally) be indicative of the actual problem. So,
> if the read is the error, the error should be associated with that read
> early on to help the user diagnose the actual source of the problem.

Well, how about littering the code all over the place for every
read/seek/puts, etc so that your "ideal" can be met.

>
> Ronald
>
> [1] https://en.wikipedia.org/wiki/Argument_from_authority
> [2] 10s or 1000s of bytes or frames failing to decode later, there's some
> little error saying the file descriptor failed to close. Did you ever look
> at line 1000 in your error log?

There is something called grep. And ironically your proposed idea of
logging at the fread does not help with this either.

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


Re: [FFmpeg-devel] [PATCH] rtmpdh: Initialize gcrypt before using it

2016-01-12 Thread Ricardo Constantino
On 12 January 2016 at 05:05, Timothy Gu  wrote:

> Are you sure you want to initialize libgcrypt unconditionally as you are
> doing here?
>

I don't think it's unconditional. It only tries to initialize gcrypt if
it's not been initialized already.

>+if (!gcry_control(GCRYCTL_INITIALIZATION_FINISHED_P)) { \

But I'm not knowledgeable with C enough to argument that.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 02/13] lavfi/vf_deshake: check fclose return value

2016-01-12 Thread Ganesh Ajjanagadde
On Tue, Jan 12, 2016 at 10:53 AM, Tobias Rapp  wrote:
> On 12.01.2016 05:25, Ganesh Ajjanagadde wrote:
>>
>> Signed-off-by: Ganesh Ajjanagadde 
>> ---
>>   libavfilter/vf_deshake.c | 5 -
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
>> index e7ece44..a89506b 100644
>> --- a/libavfilter/vf_deshake.c
>> +++ b/libavfilter/vf_deshake.c
>> @@ -423,7 +423,10 @@ static av_cold void uninit(AVFilterContext *ctx)
>>   av_freep(>angles);
>>   deshake->angles_size = 0;
>>   if (deshake->fp)
>> -fclose(deshake->fp);
>> +if (fclose(deshake->fp))
>> +av_log(ctx, AV_LOG_WARNING,
>> +   "Unable to close motion search log \"%s\": %s\n",
>> +   deshake->filename, av_err2str(AVERROR(errno)));
>>   }
>>
>>   static int filter_frame(AVFilterLink *link, AVFrame *in)
>>
>
> Nit-pick: Maybe put the inner "if" inside braces?

sure, noted.

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


Re: [FFmpeg-devel] [PATCH 02/13] lavfi/vf_deshake: check fclose return value

2016-01-12 Thread Tobias Rapp

On 12.01.2016 05:25, Ganesh Ajjanagadde wrote:

Signed-off-by: Ganesh Ajjanagadde 
---
  libavfilter/vf_deshake.c | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_deshake.c b/libavfilter/vf_deshake.c
index e7ece44..a89506b 100644
--- a/libavfilter/vf_deshake.c
+++ b/libavfilter/vf_deshake.c
@@ -423,7 +423,10 @@ static av_cold void uninit(AVFilterContext *ctx)
  av_freep(>angles);
  deshake->angles_size = 0;
  if (deshake->fp)
-fclose(deshake->fp);
+if (fclose(deshake->fp))
+av_log(ctx, AV_LOG_WARNING,
+   "Unable to close motion search log \"%s\": %s\n",
+   deshake->filename, av_err2str(AVERROR(errno)));
  }

  static int filter_frame(AVFilterLink *link, AVFrame *in)



Nit-pick: Maybe put the inner "if" inside braces?

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


Re: [FFmpeg-devel] [PATCH]lavc/mjpeg2jpeg: Accept more mjpeg streams as input

2016-01-12 Thread Michael Niedermayer
On Tue, Jan 12, 2016 at 04:18:35PM +0100, Carl Eugen Hoyos wrote:
> On Tuesday 12 January 2016 03:19:24 pm Michael Niedermayer wrote:
> > >  mjpeg2jpeg_bsf.c |5 +
> > >  1 file changed, 5 insertions(+)
> > > a261f4350cbfeefc9c011cfc93fc39e5c4f7fe7c  patchmjpeg2jpgffd8.diff
> > > diff --git a/libavcodec/mjpeg2jpeg_bsf.c b/libavcodec/mjpeg2jpeg_bsf.c
> >
> > LGTM
> 
> Patch applied.
> 
> New patch attached that fixes ticket #5151.

LGTM

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Never trust a computer, one day, it may think you are the virus. -- Compn


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


Re: [FFmpeg-devel] [PATCH]lavf/icodec: Improve probe function

2016-01-12 Thread Michael Niedermayer
On Tue, Jan 12, 2016 at 08:33:47AM -0800, Michael Bradshaw wrote:
> Overall it looks good. I thought it might overflow the buffer but with
> AVPROBE_PADDING_SIZE it doesn't.
> 
> On Tue, Jan 12, 2016 at 7:09 AM, Carl Eugen Hoyos  wrote:
> > diff --git a/libavformat/icodec.c b/libavformat/icodec.c
> > index 22e2099..9cf3dca 100644
> > --- a/libavformat/icodec.c
> > +++ b/libavformat/icodec.c
> > @@ -27,6 +27,7 @@
> >  #include "libavutil/intreadwrite.h"
> >  #include "libavcodec/bytestream.h"
> >  #include "libavcodec/bmp.h"
> > +#include "libavcodec/png.h"
> >  #include "avformat.h"
> >  #include "internal.h"
> >
> > @@ -44,9 +45,30 @@ typedef struct {
> >
> >  static int probe(AVProbeData *p)
> >  {
> > -if (AV_RL16(p->buf) == 0 && AV_RL16(p->buf + 2) == 1 && AV_RL16(p->buf 
> > + 4))
> > -return AVPROBE_SCORE_MAX / 4;
> > -return 0;
> > +unsigned i, frames = AV_RL16(p->buf + 4);
> > +
> > +if (AV_RL16(p->buf) || AV_RL16(p->buf + 2) != 1 || !frames)
> > +return 0;
> > +for (i = 0; i < frames; i++) {
> > +unsigned offset;
> > +if (AV_RL16(p->buf + 10 + i * 16) & ~1) // color planes
> > +return FFMIN(i, AVPROBE_SCORE_MAX / 4);
> > +if (p->buf[13 + i * 16])
> > +return FFMIN(i, AVPROBE_SCORE_MAX / 4);
> > +if (AV_RL32(p->buf + 14 + i * 16) < 40)  // size
> > +return FFMIN(i, AVPROBE_SCORE_MAX / 4);
> > +offset = AV_RL32(p->buf + 18 + i * 16);
> > +if (offset < 22)
> > +return FFMIN(i, AVPROBE_SCORE_MAX / 4);
> > +if (offset + 8 > p->buf_size)
> > +return AVPROBE_SCORE_MAX / 4 + FFMIN(i, 1);
> > +if (p->buf[offset] != 40 && AV_RB64(p->buf + offset) != PNGSIG)
> > +return FFMIN(i, AVPROBE_SCORE_MAX / 4);
> > +if (i * 16 + 6 > p->buf_size)
> > +return AVPROBE_SCORE_MAX / 4;
> > +}
> > +
> > +return AVPROBE_SCORE_MAX / 4 + 1;
> 
> A score of 26 seems low to me, but maybe that's just me.

same feeling
either way LGTM

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

Concerning the gods, I have no means of knowing whether they exist or not
or of what sort they may be, because of the obscurity of the subject, and
the brevity of human life -- Protagoras


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


[FFmpeg-devel] [PATCH 2/3] lavd: add teletext quantizer

2016-01-12 Thread Marton Balint
Getting teletext right from VANC/VBI data is tricky, because the teletext clock
is not synced to the video clock. Therefore we have to first measure the
frequency of the teletext clock in the reconstructed signal, and then resample
the original data appropriately.

What I do is that I measure the distance between the first and the last zero
crossing (leading edge) in the first 3 (constant) bytes of the input to
calculate the clock frequency and the starting point of the real teletext data.

Based on these I can calculate the offsets where the rest of the signal needs
to be quantized, and I do that by a simple linear interpolation between two
neighbouring values in the original data, so the resampling method is simple
first order hold.

Fixed point arithmethic is used for frequencies and offsets to improve
precision.

I guess the DSP minded people can come up with a better way, but it works for
me just fine as it is.

Signed-off-by: Marton Balint 
---
 libavdevice/Makefile  |   2 +-
 libavdevice/teletext_quantizer.c  | 174 ++
 libavdevice/teletext_quantizer.h  |  32 +++
 tests/fate/libavdevice.mak|   5 +-
 tests/ref/fate/teletext_quantizer |  22 +
 5 files changed, 233 insertions(+), 2 deletions(-)
 create mode 100644 libavdevice/teletext_quantizer.c
 create mode 100644 libavdevice/teletext_quantizer.h
 create mode 100644 tests/ref/fate/teletext_quantizer

diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index f57ec0b..f889b7c 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -69,4 +69,4 @@ SKIPHEADERS-$(CONFIG_V4L2_OUTDEV)+= v4l2-common.h
 SKIPHEADERS-$(HAVE_ALSA_ASOUNDLIB_H) += alsa.h
 SKIPHEADERS-$(HAVE_SNDIO_H)  += sndio.h
 
-TESTPROGS = timefilter
+TESTPROGS = timefilter teletext_quantizer
diff --git a/libavdevice/teletext_quantizer.c b/libavdevice/teletext_quantizer.c
new file mode 100644
index 000..af6dbbf
--- /dev/null
+++ b/libavdevice/teletext_quantizer.c
@@ -0,0 +1,174 @@
+/*
+ * 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/common.h"
+#include "libavutil/mem.h"
+#include "config.h"
+#include "teletext_quantizer.h"
+
+#define BLACK_LEVEL 16
+#define WHITE_LEVEL 235
+#define DATA_ZERO_LEVEL (BLACK_LEVEL)
+#define DATA_ONE_LEVEL (BLACK_LEVEL + ((WHITE_LEVEL - BLACK_LEVEL) * 2 / 3))
+#define DATA_ZERO_MAX ((DATA_ONE_LEVEL + DATA_ZERO_LEVEL) / 2)
+#define MAX_FRAMING_CODE_END_POSITION 64
+
+#define CLOCK_RUNIN  0xaa
+#define FRAMING_CODE 0xe4
+
+static inline int calc_zerocross(int i, uint8_t y1, uint8_t y2)
+{
+return 65536 * i + 65536 * (DATA_ZERO_MAX - y1) / (y2 - y1);
+}
+
+static int calc_frequency(const uint8_t *src, int *offset)
+{
+int first_cross = 0, last_cross = 0;
+int crosses = 0;
+uint8_t last = DATA_ZERO_LEVEL;
+int frequency;
+int i;
+
+/* Teletext data starts with 3 constant bytes: 10101010 10101010 11100100.
+ * Lets find the 10th leading edge zero crossing, (actually DATA_ZERO_MAX
+ * crossing) which should be at the 6th bit of the third byte. */
+for (i = 0; i < MAX_FRAMING_CODE_END_POSITION; src += 2, i++) {
+   uint8_t val = *src;
+   if (val > DATA_ZERO_MAX && last <= DATA_ZERO_MAX) {
+   crosses++;
+   if (crosses == 1 || crosses == 10) {
+   last_cross = calc_zerocross(i - 1, last, val);
+   if (crosses == 1)
+   first_cross = last_cross;
+   else
+   break;
+   }
+   }
+   last = val;
+}
+
+if (i >= MAX_FRAMING_CODE_END_POSITION)
+return -1;
+
+frequency = (last_cross - first_cross) / 21;
+*offset = FFMAX(0, first_cross + frequency / 2);
+
+return frequency;
+}
+
+static uint8_t calc_parity_and_line_offset(int line)
+{
+uint8_t ret = (line < 313) << 5;
+if (line >= 7 && line <= 22)
+ret += line;
+if (line >= 320 && line <= 335)
+ret += (line - 313);
+return ret;
+}
+
+int ff_teletext_line_from_vbi_data(int line, const uint8_t *src, uint8_t *tgt)
+{
+int i, offset, frequency;
+uint8_t *tgt0 = tgt;
+#ifdef TEST
+int mindiff = 255 << 16;
+#endif
+
+src++;
+
+if ((frequency = 

[FFmpeg-devel] [PATCH 3/3] lavd/decklink_dec: add support for teletext

2016-01-12 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 doc/indevs.texi |  9 +++
 libavdevice/Makefile|  2 +-
 libavdevice/decklink_common.h   |  2 ++
 libavdevice/decklink_common_c.h |  1 +
 libavdevice/decklink_dec.cpp| 56 +
 libavdevice/decklink_dec_c.c|  3 +++
 6 files changed, 72 insertions(+), 1 deletion(-)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index 6cf626d..54ab824 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -236,6 +236,15 @@ Defaults to @option{false}.
 If set to @samp{1}, video is captured in 10 bit v210 instead
 of uyvy422. Not all Blackmagic devices support this option.
 
+@item teletext_lines
+If set to nonzero, an additional teletext stream will be captured from the
+vertical ancillary data. This option is a bitmask of the VBI lines checked,
+specifically lines 6 to 22, and lines 318 to 335. Line 6 is the LSB in the 
mask.
+Selected lines which do not contain teletext information will be ignored. You
+can use the special @option{all} constant to select all possible lines, or
+@option{standard} to skip lines 6, 318 and 319, which are not compatible with 
all
+receivers. Capturing teletext only works for SD PAL sources in 8 bit mode.
+
 @end table
 
 @subsection Examples
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index f889b7c..4710d79 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -16,7 +16,7 @@ OBJS-$(CONFIG_AVFOUNDATION_INDEV)+= avfoundation.o
 OBJS-$(CONFIG_BKTR_INDEV)+= bktr.o
 OBJS-$(CONFIG_CACA_OUTDEV)   += caca.o
 OBJS-$(CONFIG_DECKLINK_OUTDEV)   += decklink_enc.o decklink_enc_c.o 
decklink_common.o
-OBJS-$(CONFIG_DECKLINK_INDEV)+= decklink_dec.o decklink_dec_c.o 
decklink_common.o
+OBJS-$(CONFIG_DECKLINK_INDEV)+= decklink_dec.o decklink_dec_c.o 
decklink_common.o teletext_quantizer.o
 OBJS-$(CONFIG_DSHOW_INDEV)   += dshow_crossbar.o dshow.o 
dshow_enummediatypes.o \
 dshow_enumpins.o dshow_filter.o \
 dshow_pin.o dshow_common.o
diff --git a/libavdevice/decklink_common.h b/libavdevice/decklink_common.h
index 3bc30f0..076c625 100644
--- a/libavdevice/decklink_common.h
+++ b/libavdevice/decklink_common.h
@@ -67,10 +67,12 @@ struct decklink_ctx {
 unsigned int dropped;
 AVStream *audio_st;
 AVStream *video_st;
+AVStream *teletext_st;
 
 /* Options */
 int list_devices;
 int list_formats;
+int64_t teletext_lines;
 double preroll;
 
 int frames_preroll;
diff --git a/libavdevice/decklink_common_c.h b/libavdevice/decklink_common_c.h
index fb2b788..2b1a579 100644
--- a/libavdevice/decklink_common_c.h
+++ b/libavdevice/decklink_common_c.h
@@ -27,6 +27,7 @@ struct decklink_cctx {
 /* Options */
 int list_devices;
 int list_formats;
+int64_t teletext_lines;
 double preroll;
 int v210;
 };
diff --git a/libavdevice/decklink_dec.cpp b/libavdevice/decklink_dec.cpp
index 89f93de..d123c4a 100644
--- a/libavdevice/decklink_dec.cpp
+++ b/libavdevice/decklink_dec.cpp
@@ -28,6 +28,7 @@ extern "C" {
 #include "libavformat/avformat.h"
 #include "libavformat/internal.h"
 #include "libavutil/imgutils.h"
+#include "libavdevice/teletext_quantizer.h"
 }
 
 #include "decklink_common.h"
@@ -277,6 +278,46 @@ HRESULT decklink_input_callback::VideoInputFrameArrived(
 pkt.size = videoFrame->GetRowBytes() *
videoFrame->GetHeight();
 //fprintf(stderr,"Video Frame size %d ts %d\n", pkt.size, pkt.pts);
+
+if (!no_video && ctx->teletext_lines && videoFrame->GetPixelFormat() 
== bmdFormat8BitYUV && videoFrame->GetWidth() == 720) {
+IDeckLinkVideoFrameAncillary *vanc;
+AVPacket txt_pkt;
+uint8_t txt_buf[1611]; // max 35 * 46 bytes decoded teletext lines 
+ 1 byte data_identifier
+uint8_t *txt_data = txt_buf;
+
+if (videoFrame->GetAncillaryData() == S_OK) {
+int stuffing_units, i;
+int64_t line_mask = 1;
+av_init_packet(_pkt);
+txt_pkt.pts = pkt.pts;
+txt_pkt.dts = pkt.dts;
+txt_pkt.stream_index = ctx->teletext_st->index;
+txt_pkt.data = txt_data;
+txt_data[0] = 0x10;// data_identifier - EBU_data
+txt_data++;
+for (i = 6; i < 336; i++, line_mask <<= 1) {
+uint8_t *buf;
+if ((ctx->teletext_lines & line_mask) && 
vanc->GetBufferForVerticalBlankingLine(i, (void**)) == S_OK) {
+if (ff_teletext_line_from_vbi_data(i, buf, txt_data) 
>= 0)
+txt_data += 46;
+}
+if (i == 22)
+i = 317;
+}
+vanc->Release();
+

Re: [FFmpeg-devel] [PATCH 3/3] avcodec/diracdec: Handle the 0 vlc case at the top of coeff_unpack_golomb()

2016-01-12 Thread Ronald S. Bultje
Hi,

On Tue, Jan 12, 2016 at 5:32 PM, Michael Niedermayer 
wrote:

> From: Michael Niedermayer 
>
> encoding changes from 17 to 20 fps


decoding, right?

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


[FFmpeg-devel] [PATCH 1/3] avcodec/diracdec: Inline svq3_get_ue_golomb() and merge the sign bit decoding into it

2016-01-12 Thread Michael Niedermayer
From: Michael Niedermayer 

This avoids closing and opening the bit reader

Signed-off-by: Michael Niedermayer 
---
 libavcodec/diracdec.c |   37 ++---
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index c67f845..fe879bb 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -485,13 +485,44 @@ static av_cold int dirac_decode_end(AVCodecContext *avctx)
 static inline int coeff_unpack_golomb(GetBitContext *gb, int qfactor, int 
qoffset)
 {
 int sign, coeff;
+uint32_t buf;
 
-coeff = svq3_get_ue_golomb(gb);
+OPEN_READER(re, gb);
+UPDATE_CACHE(re, gb);
+buf = GET_CACHE(re, gb);
+
+if (buf & 0xAA80) {
+buf >>= 32 - 8;
+SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
+
+coeff = ff_interleaved_ue_golomb_vlc_code[buf];
+} else {
+unsigned ret = 1;
+
+do {
+buf >>= 32 - 8;
+SKIP_BITS(re, gb,
+   FFMIN(ff_interleaved_golomb_vlc_len[buf], 8));
+
+if (ff_interleaved_golomb_vlc_len[buf] != 9) {
+ret <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1;
+ret  |= ff_interleaved_dirac_golomb_vlc_code[buf];
+break;
+}
+ret = (ret << 4) | ff_interleaved_dirac_golomb_vlc_code[buf];
+UPDATE_CACHE(re, gb);
+buf = GET_CACHE(re, gb);
+} while (ret<0x800U && BITS_AVAILABLE(re, gb));
+
+coeff = ret - 1;
+}
 if (coeff) {
 coeff = (coeff * qfactor + qoffset + 2) >> 2;
-sign  = get_bits1(gb);
-coeff = (coeff ^ -sign) + sign;
+sign  = SHOW_SBITS(re, gb, 1);
+LAST_SKIP_BITS(re, gb, 1);
+coeff = (coeff ^ sign) - sign;
 }
+CLOSE_READER(re, gb);
 return coeff;
 }
 
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH 3/3] avcodec/diracdec: Handle the 0 vlc case at the top of coeff_unpack_golomb()

2016-01-12 Thread Michael Niedermayer
From: Michael Niedermayer 

encoding changes from 17 to 20 fps

Signed-off-by: Michael Niedermayer 
---
 libavcodec/diracdec.c |   18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index bbe6d87..942376b 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -491,6 +491,12 @@ static inline int coeff_unpack_golomb(GetBitContext *gb, 
int qfactor, int qoffse
 UPDATE_CACHE(re, gb);
 buf = GET_CACHE(re, gb);
 
+if (buf & 0x8000) {
+LAST_SKIP_BITS(re,gb,1);
+CLOSE_READER(re, gb);
+return 0;
+}
+
 if (buf & 0xAA80) {
 buf >>= 32 - 8;
 SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
@@ -516,12 +522,12 @@ static inline int coeff_unpack_golomb(GetBitContext *gb, 
int qfactor, int qoffse
 
 coeff = ret - 1;
 }
-if (coeff) {
-coeff = (coeff * qfactor + qoffset) >> 2;
-sign  = SHOW_SBITS(re, gb, 1);
-LAST_SKIP_BITS(re, gb, 1);
-coeff = (coeff ^ sign) - sign;
-}
+
+coeff = (coeff * qfactor + qoffset) >> 2;
+sign  = SHOW_SBITS(re, gb, 1);
+LAST_SKIP_BITS(re, gb, 1);
+coeff = (coeff ^ sign) - sign;
+
 CLOSE_READER(re, gb);
 return coeff;
 }
-- 
1.7.9.5

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


[FFmpeg-devel] [PATCH 1/3] configure: use -ldl for decklink

2016-01-12 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 configure | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configure b/configure
index 19898be..a0f2276 100755
--- a/configure
+++ b/configure
@@ -5189,6 +5189,8 @@ elif check_func dlopen -ldl; then
 ldl=-ldl
 fi
 
+decklink_outdev_extralibs="$decklink_outdev_extralibs $ldl"
+decklink_indev_extralibs="$decklink_indev_extralibs $ldl"
 frei0r_filter_extralibs='$ldl'
 frei0r_src_filter_extralibs='$ldl'
 ladspa_filter_extralibs='$ldl'
-- 
2.6.2

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


Re: [FFmpeg-devel] [PATCH] libvpxdec: fix 'ISO C90 forbids mixed declarations and code' warning

2016-01-12 Thread James Zern
On Tue, Jan 12, 2016 at 5:40 AM, Ronald S. Bultje  wrote:
> Hi,
>
> On Tue, Jan 12, 2016 at 1:43 AM, James Zern  wrote:
>
>> since:
>> cbcc88c libvpx: Support setting color range for vp9.
>>
>> Signed-off-by: James Zern 
>> ---
>> [...]
>
>
> lgtm, thanks.
>

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


Re: [FFmpeg-devel] [PATCH 3/3] avcodec/diracdec: Handle the 0 vlc case at the top of coeff_unpack_golomb()

2016-01-12 Thread Michael Niedermayer
On Tue, Jan 12, 2016 at 05:48:21PM -0500, Ronald S. Bultje wrote:
> Hi,
> 
> On Tue, Jan 12, 2016 at 5:32 PM, Michael Niedermayer 
> wrote:
> 
> > From: Michael Niedermayer 
> >
> > encoding changes from 17 to 20 fps
> 
> 
> decoding, right?

yes i cant write :)

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

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell


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


[FFmpeg-devel] [PATCH 2/3] avcodec/diracdec: Factor +2 out of the inner loop

2016-01-12 Thread Michael Niedermayer
From: Michael Niedermayer 

Signed-off-by: Michael Niedermayer 
---
 libavcodec/diracdec.c |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavcodec/diracdec.c b/libavcodec/diracdec.c
index fe879bb..bbe6d87 100644
--- a/libavcodec/diracdec.c
+++ b/libavcodec/diracdec.c
@@ -517,7 +517,7 @@ static inline int coeff_unpack_golomb(GetBitContext *gb, 
int qfactor, int qoffse
 coeff = ret - 1;
 }
 if (coeff) {
-coeff = (coeff * qfactor + qoffset + 2) >> 2;
+coeff = (coeff * qfactor + qoffset) >> 2;
 sign  = SHOW_SBITS(re, gb, 1);
 LAST_SKIP_BITS(re, gb, 1);
 coeff = (coeff ^ sign) - sign;
@@ -548,7 +548,7 @@ static inline int coeff_unpack_golomb(GetBitContext *gb, 
int qfactor, int qoffse
 } \
 coeff = dirac_get_arith_uint(c, pred_ctx, CTX_COEFF_DATA); \
 if (coeff) { \
-coeff = (coeff * qfactor + qoffset + 2) >> 2; \
+coeff = (coeff * qfactor + qoffset) >> 2; \
 sign  = dirac_get_arith_bit(c, SIGN_CTX(sign_pred)); \
 coeff = (coeff ^ -sign) + sign; \
 } \
@@ -600,9 +600,9 @@ static inline void codeblock(DiracContext *s, SubBand *b,
 qfactor = qscale_tab[b->quant];
 /* TODO: context pointer? */
 if (!s->num_refs)
-qoffset = qoffset_intra_tab[b->quant];
+qoffset = qoffset_intra_tab[b->quant] + 2;
 else
-qoffset = qoffset_inter_tab[b->quant];
+qoffset = qoffset_inter_tab[b->quant] + 2;
 
 buf = b->ibuf + top * b->stride;
 if (is_arith) {
@@ -776,7 +776,7 @@ static void decode_subband(DiracContext *s, GetBitContext 
*gb, int quant,
 int bottom = b1->height *(slice_y+1) / s->num_y;
 
 int qfactor = qscale_tab[quant & 0x7f];
-int qoffset = qoffset_intra_tab[quant & 0x7f];
+int qoffset = qoffset_intra_tab[quant & 0x7f] + 2;
 
 uint8_t *buf1 =  b1->ibuf + top * b1->stride;
 uint8_t *buf2 = b2 ? b2->ibuf + top * b2->stride: NULL;
-- 
1.7.9.5

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


Re: [FFmpeg-devel] [PATCH 1/3] avcodec/diracdec: Inline svq3_get_ue_golomb() and merge the sign bit decoding into it

2016-01-12 Thread Michael Niedermayer
On Tue, Jan 12, 2016 at 11:32:56PM +0100, Michael Niedermayer wrote:
> From: Michael Niedermayer 
> 
> This avoids closing and opening the bit reader
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/diracdec.c |   37 ++---
>  1 file changed, 34 insertions(+), 3 deletions(-)

Note, theres alot more that can be done to speed this up, this patchset
is just a few steps ...

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

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


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


Re: [FFmpeg-devel] [RFC] avcodec: Add native DCA decoder based on libdcadec.

2016-01-12 Thread Andreas Cadhalpun
On 08.01.2016 15:34, foo86 wrote:
> On Thu, Jan 07, 2016 at 08:17:59PM +0100, Andreas Cadhalpun wrote:
>> On 03.01.2016 18:49, foo86 wrote:
>>> +for (i = 0; i < s->nmixoutconfigs; i++) {
>>> +for (j = 0; j < nchannels_dmix; j++) {
>>> +// Mix output mask
>>> +int mix_map_mask = get_bits(>gb, s->nmixoutchs[i]);
>>
>> Here s->nmixoutchs[i] can be zero. If that should not happen, there needs
>> to be an error check and otherwise it should use get_bitsz, because
>> get_bits doesn't support reading 0 bits.
> 
> It doesn't seem that zero channel mask should normally happen, added an
> error check earlier.

It's not completely fixed yet, because the check is only done if
static_fields_present is 1.
I think the correct fix would be to set mix_metadata_enabled to 0 if
static_fields_present is 0, e.g. in the else branch in ff_dca_exss_parse.

>> Anyway, I still think the code is pretty robust. :-)
> 
> Thanks for testing!

You're welcome.

>> I'd be glad to increase fuzz-testing coverage further, but I'm lacking
>> input examples. It would be great if you could share some (tiny) samples
>> triggering the HEADER_XCH/HEADER_XXCH cases and/or *_down_mix functions.
> 
> As Hendrik pointed out, there are lidcadec test suite samples you can
> use for this. To trigger all downmixing functions you may need to
> provide -request_channel_layout 3 option.

Thanks to your hints I could increase the coverage above 90%.
I found a few more issues along the way:

static void get_array(GetBitContext *s, int *array, int size, int n)
{
int i;

for (i = 0; i < size; i++)
array[i] = get_sbits(s, n);

This should be get_sbits_long, because n can be larger than 25.


static int chs_assemble_freq_bands(DCAXllDecoder *s, DCAXllChSet *c)
{
int i, ch, nsamples = s->nframesamples, *ptr;

av_assert1(c->nfreqbands > 1);

This assert can be triggered.

static void combine_residual_frame(DCAXllDecoder *s, DCACoreDecoder *core, 
DCAXllChSet *c)
{
int ch, nsamples = s->nframesamples;
DCAXllChSet *o;

av_assert0(c->freq == core->output_rate);
av_assert0(nsamples == core->npcmsamples);

These two, as well.
Maybe they should be regular error checks instead?


static void scale_down_mix(DCAXllDecoder *s, DCAXllChSet *o, int band)
{
int i, j, nchannels = 0, nsamples = s->nframesamples;
DCAXllChSet *c;

for (i = 0, c = s->chset; i < s->nactivechsets; i++, c++) {
if (!c->hier_chset)
continue;
for (j = 0; j < c->nchannels; j++) {
int scale = o->dmix_scale[nchannels++];
if (scale != (1 << 15)) {
s->dcadsp->dmix_scale(c->bands[band].msb_sample_buffer[j],
  scale, nsamples);

c->bands[band].msb_sample_buffer[j] can be NULL here, which causes a crash.


Additionally there are some rarely happening overflows in dcadsp.c.
(More precisely in filter0, filter1, dmix_sub_c and dmix_scale_c.)
It would be nice to avoid those, if that's possible without significant
speed loss.

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


Re: [FFmpeg-devel] [PATCH 00/13] check all fclose usage

2016-01-12 Thread Paul B Mahol
On 1/12/16, Ganesh Ajjanagadde  wrote:
> On Tue, Jan 12, 2016 at 10:29 AM, Ronald S. Bultje 
> wrote:
>> Hi,
>>
>> On Tue, Jan 12, 2016 at 10:07 AM, Ganesh Ajjanagadde 
>> wrote:
>>
>>> On Tue, Jan 12, 2016 at 9:43 AM, Ronald S. Bultje 
>>> wrote:
>>> > Hi,
>>> >
>>> > On Tue, Jan 12, 2016 at 7:52 AM, Ganesh Ajjanagadde 
>>> > wrote:
>>> >
>>> >> On Tue, Jan 12, 2016 at 4:38 AM, wm4  wrote:
>>> >> > This makes no sense. Even if fclose() should fail for
>>> >> > whatever obscure reasons there might be, reading already worked
>>> >> > without errors, and thus closing failure has no meaning to use.
>>> >>
>>> >> Well, reading may not have worked, and the fclose may have been called
>>> >> in a failure path.
>>> >
>>> >
>>> > Then the error should be in the code path of fread(), not fclose().
>>> > Displaying an error (in whatever way) related to close while the actual
>>> > problem was reading data is going to be confusing to the user.
>>>
>>> Read the rest of it; checking for every fread/fseek is not productive;
>>> there are at least 3 of fread/fseek in the example I gave. Printing at
>>> the time of closure is a natural means of doing things, again see:
>>> https://www.gnu.org/ghm/2011/paris/slides/jim-meyering-goodbye-world.pdf
>>> (particularly slide 7).
>>
>>
>> He's very smart, but you still have to see his advice in context, also see
>> [1].
>
> The question of his smartness is irrelevant, as is the appeal to
> authority definition here.
>
>>
>> Most production uses of ffmpeg involve long-running processes in a
>> multi-component pipeline, where fail-to-read will cause errors downstream.
>> Reading the file from disk is only one small component. Let's say that I
>> read a buffer of 10 bytes but I only got 5 because whatever went wrong. I
>> parse the input buffer of 5 bytes, it's obviously corrupt, decoding stream
>> goes wrong, and the decoder displays error ("ffvp9: corrupt input stream,
>> failed to decode"). Note how this is the topmost error in stderr,
>> therefore
>> the user (logically) thinks: "FFmpeg's decoder sucks. FFmpeg sucks."
>> That's
>> bad. [2]
>
> If the fread is unchecked, that is a separate issue. At least for the
> example I gave, the fread is checked. However, there is little (if
> anything) that gets logged, since only the return value is set. The
> question is where/what to log, if any.
>
> Instead of making such generic statements, please post comments to the
> actual patches; the discussion will be more productive.
>
>>
>> The first error should (ideally) be indicative of the actual problem. So,
>> if the read is the error, the error should be associated with that read
>> early on to help the user diagnose the actual source of the problem.
>
> Well, how about littering the code all over the place for every
> read/seek/puts, etc so that your "ideal" can be met.
>
>>
>> Ronald
>>
>> [1] https://en.wikipedia.org/wiki/Argument_from_authority
>> [2] 10s or 1000s of bytes or frames failing to decode later, there's some
>> little error saying the file descriptor failed to close. Did you ever look
>> at line 1000 in your error log?
>
> There is something called grep. And ironically your proposed idea of
> logging at the fread does not help with this either.

Why the stuff I post have no comments at all?
But this marginal functionality is commented so much.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavf/mpjpegdec: Do not av_log() while probing

2016-01-12 Thread Michael Niedermayer
On Tue, Jan 12, 2016 at 06:29:47PM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch silences the mpjpeg probing function.
> 
> Please comment, Carl Eugen

>  mpjpegdec.c |3 +++
>  1 file changed, 3 insertions(+)
> acd4f042b52c6400a6aaf613b89ecad9ca3405ac  patchmpjpeglog.diff

should be ok

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.


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


Re: [FFmpeg-devel] [PATCH] rtp: Fix play multiple multicast streams with the same port

2016-01-12 Thread Zhao Zhili
ping?

On Fri, Jan 8, 2016 at 9:15 AM, Zhao Zhili  wrote:

> Sorry, I work hard to cross the Great Fire Wall to send this patch and
> cannot send it as plaintext.
> Now send it as attachment.
>
> On Fri, Jan 8, 2016 at 1:52 AM, Michael Niedermayer <
> mich...@niedermayer.cc> wrote:
>
>> On Thu, Jan 07, 2016 at 06:58:49PM +0800, Zhao Zhili wrote:
>> > I made a mistake that rtp and rtcp cannot be the same port. A new patch
>> is
>> > appended.
>> >
>> > From: Zhao Zhili 
>> > Date: Thu, 7 Jan 2016 18:55:50 +0800
>> > Subject: [PATCH] rtp: Fix play multiple multicast streams with the same
>> port
>> >
>> > We cannot play multiple multicast streams with the same port at the
>> > same time. This is because both rtp and rtcp port are opened in
>> > read-write mode, so they will not bind to the multicast address. Try
>> > to make rtp port as read-only by default to solve this bug.
>> >
>> > Signed-off-by: Zhao Zhili 
>> > ---
>> >  libavformat/rtpproto.c | 6 --
>> >  libavformat/rtsp.c | 2 +-
>> >  2 files changed, 5 insertions(+), 3 deletions(-)
>> >
>> > diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
>> > index e0aa23e..04a40ea 100644
>> > --- a/libavformat/rtpproto.c
>> > +++ b/libavformat/rtpproto.c
>> > @@ -323,6 +323,7 @@ static int rtp_open(URLContext *h, const char *uri,
>> int
>> > flags)
>> >  char path[1024];
>> >  const char *p;
>> >  int i, max_retry_count = 3;
>> > +int rtcpflags;
>> >
>> >  av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname),
>> _port,
>> >   path, sizeof(path), uri);
>> > @@ -387,12 +388,13 @@ static int rtp_open(URLContext *h, const char
>> *uri,
>> > int flags)
>> >  s->local_rtpport = -1;
>> >  continue;
>> >  }
>> > +rtcpflags = flags | AVIO_FLAG_WRITE;
>> >  if (s->local_rtcpport < 0) {
>> >  s->local_rtcpport = s->local_rtpport + 1;
>> >  build_udp_url(s, buf, sizeof(buf),
>> >hostname, s->rtcp_port, s->local_rtcpport,
>> >sources, block);
>> > -if (ffurl_open(>rtcp_hd, buf, flags,
>> > >interrupt_callback, NULL) < 0) {
>> > +if (ffurl_open(>rtcp_hd, buf, rtcpflags,
>> > >interrupt_callback, NULL) < 0) {
>>
>> the patch is corrupted by linebreaks
>>
>> attaching it usually fixes that
>>
>> [...]
>> --
>> 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.
>>
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavu: check for overflow in av_clip_intp2_c

2016-01-12 Thread Andreas Cadhalpun
---
 libavutil/common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/common.h b/libavutil/common.h
index f3276a2..5ae2847 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -211,7 +211,7 @@ static av_always_inline av_const int32_t 
av_clipl_int32_c(int64_t a)
  */
 static av_always_inline av_const int av_clip_intp2_c(int a, int p)
 {
-if ((a + (1 << p)) & ~((2 << p) - 1))
+if (a >= INT_MAX - (1 << p) || ((a + (1 << p)) & ~((2 << p) - 1)))
 return (a >> 31) ^ ((1 << p) - 1);
 else
 return a;
-- 
2.6.4
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavf/matroskadec: Set A_QUICKTIME bit depth

2016-01-12 Thread Mats Peterson
Since mkvmerge doesn't set the bit depth for A_QUICKTIME audio (as far 
as I know), the track->audio.bitdepth variable will be zero, and its 
value needs to be retrieved from the sound sample description. Also, 
confine the 0x to 'raw '/'twos' fourcc mapping to old version 0 
sound sample descriptions, since they are the only valid sample 
descriptions for this type of mapping.


Mats
>From 5c0635522f888ec208588215dc3d4a13dabe1018 Mon Sep 17 00:00:00 2001
From: Mats Peterson 
Date: Wed, 13 Jan 2016 00:06:52 +0100
Subject: [PATCH] lavf/matroskadec: Set A_QUICKTIME bit depth

Since mkvmerge doesn't set the bit depth for A_QUICKTIME audio (as far
as I know), the track->audio.bitdepth variable will be zero, and its
value needs to be retrieved from the sound sample description. Also,
confine the 0x to 'raw '/'twos' fourcc mapping to old version 0
sound sample descriptions, since they are the only valid sample
descriptions for this type of mapping.

---
 libavformat/matroskadec.c |   21 ++---
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index cc5ec19..89bc68e 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -1891,16 +1891,23 @@ static int matroska_parse_tracks(AVFormatContext *s)
/* Normally 36, but allow noncompliant private data */
&& (track->codec_priv.size >= 32)
&& (track->codec_priv.data)) {
+uint16_t stsd_version;
 int ret = get_qt_codec(track, , _id);
 if (ret < 0)
 return ret;
-if (fourcc == 0) {
-if (track->audio.bitdepth == 8) {
-fourcc = MKTAG('r','a','w',' ');
-codec_id = ff_codec_get_id(ff_codec_movaudio_tags, fourcc);
-} else if (track->audio.bitdepth == 16) {
-fourcc = MKTAG('t','w','o','s');
-codec_id = ff_codec_get_id(ff_codec_movaudio_tags, fourcc);
+stsd_version = AV_RB16(track->codec_priv.data + 16);
+if (stsd_version == 0) {
+/* Currently not set by mkvmerge, so get the bit depth
+ * from the sample description. */
+track->audio.bitdepth = AV_RB16(track->codec_priv.data + 26);
+if (fourcc == 0) {
+if (track->audio.bitdepth == 8) {
+fourcc = MKTAG('r','a','w',' ');
+codec_id = ff_codec_get_id(ff_codec_movaudio_tags, fourcc);
+} else if (track->audio.bitdepth == 16) {
+fourcc = MKTAG('t','w','o','s');
+codec_id = ff_codec_get_id(ff_codec_movaudio_tags, fourcc);
+}
 }
 }
 } else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH] qtpalette: make the color_* variables unsigned again

2016-01-12 Thread Mats Peterson

On 01/12/2016 10:44 PM, Andreas Cadhalpun wrote:

Why are we using stdint types for non-vector data here? Our custom has
always been to used sized (stdint-style) data only for vector data (arrays
etc.), and use native-sized types (e.g. unsigned, int, whatever) for scalar
values. Why are we making exceptions here?


I can't find this convention in our coding rules[1].
The main reason why I used uint32_t instead of unsigned here was consistency
with the line below. But as Ganesh explained it makes prefect sense to use
uint32_t at least for color_start.



Yes it does.

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


[FFmpeg-devel] [PATCH] dca: fix misaligned access in avpriv_dca_convert_bitstream

2016-01-12 Thread Andreas Cadhalpun
src and dst are only 8-bit-aligned, so accessing them as uint16_t causes
SIGBUS crashes on architectures like sparc.

This fixes ubsan runtime error: load of misaligned address for type
'const uint16_t', which requires 2 byte alignment

Signed-off-by: Andreas Cadhalpun 
---
 libavcodec/dca.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libavcodec/dca.c b/libavcodec/dca.c
index 8dd0430..714509b 100644
--- a/libavcodec/dca.c
+++ b/libavcodec/dca.c
@@ -41,8 +41,6 @@ int avpriv_dca_convert_bitstream(const uint8_t *src, int 
src_size, uint8_t *dst,
 {
 uint32_t mrk;
 int i, tmp;
-const uint16_t *ssrc = (const uint16_t *) src;
-uint16_t *sdst = (uint16_t *) dst;
 PutBitContext pb;
 
 if ((unsigned) src_size > (unsigned) max_size)
@@ -54,8 +52,11 @@ int avpriv_dca_convert_bitstream(const uint8_t *src, int 
src_size, uint8_t *dst,
 memcpy(dst, src, src_size);
 return src_size;
 case DCA_SYNCWORD_CORE_LE:
-for (i = 0; i < (src_size + 1) >> 1; i++)
-*sdst++ = av_bswap16(*ssrc++);
+for (i = 0; i < (src_size + 1) >> 1; i++) {
+AV_WB16(dst, AV_RL16(src));
+src += 2;
+dst += 2;
+}
 return src_size;
 case DCA_SYNCWORD_CORE_14B_BE:
 case DCA_SYNCWORD_CORE_14B_LE:
-- 
2.6.4
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v2 8/9] lavc/ccaption_dec: implement positioning for closed captions

2016-01-12 Thread Aman Gupta
From: Aman Gupta 

Positioning math is based on the guidelines in
https://dvcs.w3.org/hg/text-tracks/raw-file/default/608toVTT/608toVTT.html#positioning-in-cea-608
---
 libavcodec/ccaption_dec.c | 29 +
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index 1c8a0d0..4ec063e 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -316,7 +316,7 @@ static void roll_up(CCaptionSubContext *ctx)
 
 static int capture_screen(CCaptionSubContext *ctx)
 {
-int i;
+int i, j, tab = 0;
 struct Screen *screen = ctx->screen + ctx->active_screen;
 enum cc_font prev_font = CCFONT_REGULAR;
 av_bprint_clear(>buffer);
@@ -325,13 +325,30 @@ static int capture_screen(CCaptionSubContext *ctx)
 {
 if (CHECK_FLAG(screen->row_used, i)) {
 const char *row = screen->characters[i];
+j = 0;
+while (row[j] == ' ')
+j++;
+if (!tab || j < tab)
+tab = j;
+}
+}
+
+for (i = 0; screen->row_used && i < SCREEN_ROWS; i++)
+{
+if (CHECK_FLAG(screen->row_used, i)) {
+const char *row = screen->characters[i];
 const char *font = screen->fonts[i];
-int j = 0;
+int x, y, seen_char = 0;
+j = 0;
 
 /* skip leading space */
-while (row[j] == ' ')
+while (row[j] == ' ' && j < tab)
 j++;
 
+x = ASS_DEFAULT_PLAYRESX * (0.1 + 0.0250 * j);
+y = ASS_DEFAULT_PLAYRESY * (0.1 + 0.0533 * i);
+av_bprintf(>buffer, "{\\an7}{\\pos(%d,%d)}", x, y);
+
 for (; j < SCREEN_COLUMNS; j++) {
 const char *e_tag = "", *s_tag = "";
 
@@ -365,8 +382,12 @@ static int capture_screen(CCaptionSubContext *ctx)
 prev_font = font[j];
 if (row[j] == 1)
 av_bprintf(>buffer, "%s%s\u266A", e_tag, s_tag);
-else
+else if (row[j] == ' ' && !seen_char)
+av_bprintf(>buffer, "%s%s\\h", e_tag, s_tag);
+else {
 av_bprintf(>buffer, "%s%s%c", e_tag, s_tag, row[j]);
+seen_char = 1;
+}
 
 }
 av_bprintf(>buffer, "\\N");
-- 
2.5.3

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


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

2016-01-12 Thread Aman Gupta
From: Aman Gupta 

---
 libavcodec/ccaption_dec.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index 8c913fe..50625df 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -558,6 +558,11 @@ static void process_cc608(CCaptionSubContext *ctx, int64_t 
pts, uint8_t hi, uint
 } else if (hi >= 0x20) {
 /* Standard characters (always in pairs) */
 handle_char(ctx, hi, lo, pts);
+} else if (hi == 0x17 && lo >= 0x21 && lo <= 0x23) {
+/* Tab offsets (spacing) */
+for (int i = 0; i < lo - 0x20; i++) {
+handle_char(ctx, ' ', 0, pts);
+}
 } else {
 /* Ignoring all other non data code */
 ff_dlog(ctx, "Unknown command 0x%hhx 0x%hhx\n", hi, lo);
-- 
2.5.3

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


[FFmpeg-devel] [PATCH v2 3/9] fate: add test for realtime ccaption decoder

2016-01-12 Thread Aman Gupta
From: Aman Gupta 

---
 tests/fate/subtitles.mak   |  3 +++
 tests/ref/fate/sub-cc-realtime | 42 ++
 2 files changed, 45 insertions(+)
 create mode 100644 tests/ref/fate/sub-cc-realtime

diff --git a/tests/fate/subtitles.mak b/tests/fate/subtitles.mak
index d273f2e..8aa0279 100644
--- a/tests/fate/subtitles.mak
+++ b/tests/fate/subtitles.mak
@@ -4,6 +4,9 @@ fate-sub-aqtitle: CMD = fmtstdout ass -sub_charenc windows-1250 
-i $(TARGET_SAMP
 FATE_SUBTITLES_ASS-$(call ALLYES, AVDEVICE LAVFI_INDEV CCAPTION_DECODER 
MOVIE_FILTER MPEGTS_DEMUXER) += fate-sub-cc
 fate-sub-cc: CMD = fmtstdout ass -f lavfi -i 
"movie=$(TARGET_SAMPLES)/sub/Closedcaption_rollup.m2v[out0+subcc]"
 
+FATE_SUBTITLES_ASS-$(call ALLYES, AVDEVICE LAVFI_INDEV CCAPTION_DECODER 
MOVIE_FILTER MPEGTS_DEMUXER) += fate-sub-cc-realtime
+fate-sub-cc-realtime: CMD = fmtstdout ass -real_time 1 -f lavfi -i 
"movie=$(TARGET_SAMPLES)/sub/Closedcaption_rollup.m2v[out0+subcc]"
+
 FATE_SUBTITLES_ASS-$(call DEMDEC, ASS, ASS) += fate-sub-ass-to-ass-transcode
 fate-sub-ass-to-ass-transcode: CMD = fmtstdout ass -i 
$(TARGET_SAMPLES)/sub/1ededcbd7b.ass
 
diff --git a/tests/ref/fate/sub-cc-realtime b/tests/ref/fate/sub-cc-realtime
new file mode 100644
index 000..0b4037c
--- /dev/null
+++ b/tests/ref/fate/sub-cc-realtime
@@ -0,0 +1,42 @@
+[Script Info]
+; Script generated by FFmpeg/Lavc
+ScriptType: v4.00+
+PlayResX: 384
+PlayResY: 288
+
+[V4+ Styles]
+Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, 
OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, 
Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, 
MarginV, Encoding
+Style: 
Default,Monospace,16,0,0,0,0,100,100,0,0,3,1,0,2,10,10,10,0
+
+[Events]
+Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
+Dialogue: 0,0:00:14.14,999:59:59.99,Default,,0,0,0,,(
+Dialogue: 0,0:00:15.47,999:59:59.99,Default,,0,0,0,,({\i1} in
+Dialogue: 0,0:00:15.92,999:59:59.99,Default,,0,0,0,,({\i1} inau
+Dialogue: 0,0:00:16.36,999:59:59.99,Default,,0,0,0,,({\i1} inaudi
+Dialogue: 0,0:00:16.81,999:59:59.99,Default,,0,0,0,,({\i1} inaudibl
+Dialogue: 0,0:00:17.25,999:59:59.99,Default,,0,0,0,,({\i1} inaudible 
+Dialogue: 0,0:00:17.70,999:59:59.99,Default,,0,0,0,,({\i1} inaudible ra
+Dialogue: 0,0:00:18.14,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radi
+Dialogue: 0,0:00:18.59,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
+Dialogue: 0,0:00:19.03,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio ch
+Dialogue: 0,0:00:19.48,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio chat
+Dialogue: 0,0:00:19.92,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatte
+Dialogue: 0,0:00:20.36,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter
+Dialogue: 0,0:00:21.70,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )
+Dialogue: 0,0:00:42.61,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>>
+Dialogue: 0,0:00:43.05,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> S
+Dialogue: 0,0:00:43.50,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Saf
+Dialogue: 0,0:00:43.94,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safet
+Dialogue: 0,0:00:44.39,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety 
+Dialogue: 0,0:00:44.83,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety re
+Dialogue: 0,0:00:45.28,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety rema
+Dialogue: 0,0:00:45.72,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remain
+Dialogue: 0,0:00:46.17,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains 
+Dialogue: 0,0:00:46.61,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains ou
+Dialogue: 0,0:00:47.06,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our 
+Dialogue: 0,0:00:47.50,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our nu
+Dialogue: 0,0:00:47.95,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our numb
+Dialogue: 0,0:00:48.39,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our number
+Dialogue: 0,0:00:48.84,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our number o
+Dialogue: 0,0:00:49.28,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our number one
-- 
2.5.3

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


[FFmpeg-devel] [PATCH v2 9/9] fate: update sub-cc tests for subtitle positioning

2016-01-12 Thread Aman Gupta
From: Aman Gupta 

---
 tests/ref/fate/sub-cc  |  4 +--
 tests/ref/fate/sub-cc-realtime | 60 +-
 2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/tests/ref/fate/sub-cc b/tests/ref/fate/sub-cc
index 0d5bc77..4cc02d1 100644
--- a/tests/ref/fate/sub-cc
+++ b/tests/ref/fate/sub-cc
@@ -10,5 +10,5 @@ Style: 
Default,Monospace,16,0,0,0,0,100,100,0,0,3,1,0,
 
 [Events]
 Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:00:12.36,0:00:40.83,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )
-Dialogue: 0,0:00:40.83,0:00:59.07,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our number one
+Dialogue: 0,0:00:12.36,0:00:40.83,Default,,0,0,0,,{\an7}{\pos(38,44)}({\i1} 
inaudible radio chatter{\i0} )
+Dialogue: 0,0:00:40.83,0:00:59.07,Default,,0,0,0,,{\an7}{\pos(38,28)}({\i1} 
inaudible radio chatter{\i0} )\N{\an7}{\pos(38,44)}>> Safety remains our number 
one
diff --git a/tests/ref/fate/sub-cc-realtime b/tests/ref/fate/sub-cc-realtime
index 0b4037c..be800a4 100644
--- a/tests/ref/fate/sub-cc-realtime
+++ b/tests/ref/fate/sub-cc-realtime
@@ -10,33 +10,33 @@ Style: 
Default,Monospace,16,0,0,0,0,100,100,0,0,3,1,0,
 
 [Events]
 Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
-Dialogue: 0,0:00:14.14,999:59:59.99,Default,,0,0,0,,(
-Dialogue: 0,0:00:15.47,999:59:59.99,Default,,0,0,0,,({\i1} in
-Dialogue: 0,0:00:15.92,999:59:59.99,Default,,0,0,0,,({\i1} inau
-Dialogue: 0,0:00:16.36,999:59:59.99,Default,,0,0,0,,({\i1} inaudi
-Dialogue: 0,0:00:16.81,999:59:59.99,Default,,0,0,0,,({\i1} inaudibl
-Dialogue: 0,0:00:17.25,999:59:59.99,Default,,0,0,0,,({\i1} inaudible 
-Dialogue: 0,0:00:17.70,999:59:59.99,Default,,0,0,0,,({\i1} inaudible ra
-Dialogue: 0,0:00:18.14,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radi
-Dialogue: 0,0:00:18.59,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
-Dialogue: 0,0:00:19.03,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio ch
-Dialogue: 0,0:00:19.48,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio chat
-Dialogue: 0,0:00:19.92,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatte
-Dialogue: 0,0:00:20.36,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter
-Dialogue: 0,0:00:21.70,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )
-Dialogue: 0,0:00:42.61,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>>
-Dialogue: 0,0:00:43.05,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> S
-Dialogue: 0,0:00:43.50,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Saf
-Dialogue: 0,0:00:43.94,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safet
-Dialogue: 0,0:00:44.39,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety 
-Dialogue: 0,0:00:44.83,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety re
-Dialogue: 0,0:00:45.28,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety rema
-Dialogue: 0,0:00:45.72,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remain
-Dialogue: 0,0:00:46.17,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains 
-Dialogue: 0,0:00:46.61,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains ou
-Dialogue: 0,0:00:47.06,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our 
-Dialogue: 0,0:00:47.50,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our nu
-Dialogue: 0,0:00:47.95,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our numb
-Dialogue: 0,0:00:48.39,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our number
-Dialogue: 0,0:00:48.84,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our number o
-Dialogue: 0,0:00:49.28,999:59:59.99,Default,,0,0,0,,({\i1} inaudible radio 
chatter{\i0} )\N>> Safety remains our number one
+Dialogue: 0,0:00:14.14,9:59:59.99,Default,,0,0,0,,{\an7}{\pos(38,44)}(
+Dialogue: 0,0:00:15.47,9:59:59.99,Default,,0,0,0,,{\an7}{\pos(38,44)}({\i1} in
+Dialogue: 0,0:00:15.92,9:59:59.99,Default,,0,0,0,,{\an7}{\pos(38,44)}({\i1} 
inau
+Dialogue: 0,0:00:16.36,9:59:59.99,Default,,0,0,0,,{\an7}{\pos(38,44)}({\i1} 
inaudi
+Dialogue: 0,0:00:16.81,9:59:59.99,Default,,0,0,0,,{\an7}{\pos(38,44)}({\i1} 
inaudibl
+Dialogue: 0,0:00:17.25,9:59:59.99,Default,,0,0,0,,{\an7}{\pos(38,44)}({\i1} 
inaudible 
+Dialogue: 0,0:00:17.70,9:59:59.99,Default,,0,0,0,,{\an7}{\pos(38,44)}({\i1} 
inaudible ra
+Dialogue: 0,0:00:18.14,9:59:59.99,Default,,0,0,0,,{\an7}{\pos(38,44)}({\i1} 
inaudible radi
+Dialogue: 0,0:00:18.59,9:59:59.99,Default,,0,0,0,,{\an7}{\pos(38,44)}({\i1} 
inaudible radio 
+Dialogue: 

[FFmpeg-devel] [PATCH v2 1/9] lavc/ccaption_dec: flush context on seek

2016-01-12 Thread Aman Gupta
From: Aman Gupta 

---
 libavcodec/ccaption_dec.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index ca497e5..a9dfc94 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -173,6 +173,26 @@ static av_cold int close_decoder(AVCodecContext *avctx)
 return 0;
 }
 
+static void flush_decoder(AVCodecContext *avctx)
+{
+CCaptionSubContext *ctx = avctx->priv_data;
+ctx->screen[0].row_used = 0;
+ctx->screen[1].row_used = 0;
+ctx->prev_cmd[0] = 0;
+ctx->prev_cmd[1] = 0;
+ctx->mode = CCMODE_ROLLUP;
+ctx->rollup = 2;
+ctx->cursor_row = 0;
+ctx->cursor_column = 0;
+ctx->cursor_font = 0;
+ctx->cursor_color = 0;
+ctx->active_screen = 0;
+ctx->last_real_time = 0;
+ctx->screen_touched = 0;
+ctx->buffer_changed = 0;
+av_bprint_clear(>buffer);
+}
+
 /**
  * @param ctx closed caption context just to print log
  */
@@ -578,6 +598,7 @@ AVCodec ff_ccaption_decoder = {
 .priv_data_size = sizeof(CCaptionSubContext),
 .init   = init_decoder,
 .close  = close_decoder,
+.flush  = flush_decoder,
 .decode = decode,
 .priv_class = _dec_class,
 };
-- 
2.5.3

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


[FFmpeg-devel] [PATCH v2 4/9] lavc/ccaption_dec: default rollup to row 10

2016-01-12 Thread Aman Gupta
From: Aman Gupta 

This ensures that captions are written towards the bottom of the screen
when tuning into mid-stream. The row will be reset on the receipt of the
next PAC command. Row 10 was chosen as it corresponds to the value of
"0" in a PAC (see row_map in handle_pac()).
---
 libavcodec/ccaption_dec.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index 6bdd754..8c913fe 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -148,6 +148,7 @@ static av_cold int init_decoder(AVCodecContext *avctx)
 /* taking by default roll up to 2 */
 ctx->mode = CCMODE_ROLLUP;
 ctx->rollup = 2;
+ctx->cursor_row = 10;
 ret = ff_ass_subtitle_header(avctx, "Monospace",
  ASS_DEFAULT_FONT_SIZE,
  ASS_DEFAULT_COLOR,
@@ -185,7 +186,7 @@ static void flush_decoder(AVCodecContext *avctx)
 ctx->prev_cmd[1] = 0;
 ctx->mode = CCMODE_ROLLUP;
 ctx->rollup = 2;
-ctx->cursor_row = 0;
+ctx->cursor_row = 10;
 ctx->cursor_column = 0;
 ctx->cursor_font = 0;
 ctx->cursor_color = 0;
-- 
2.5.3

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


[FFmpeg-devel] [PATCH v2 7/9] lavc/ccaption_dec: implement musical glyph

2016-01-12 Thread Aman Gupta
From: Aman Gupta 

This is the most commonly used character from the special north-american
character set. All the non-standard charsets are "optional" according to
the spec, and we currently implement none of them. This commit adds
support for "♪" which very popular (and has no ascii fallback), typically
used to indicate lyrics in captions.
---
 libavcodec/ccaption_dec.c | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index ff0735e..1c8a0d0 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -363,7 +363,11 @@ static int capture_screen(CCaptionSubContext *ctx)
 }
 }
 prev_font = font[j];
-av_bprintf(>buffer, "%s%s%c", e_tag, s_tag, row[j]);
+if (row[j] == 1)
+av_bprintf(>buffer, "%s%s\u266A", e_tag, s_tag);
+else
+av_bprintf(>buffer, "%s%s%c", e_tag, s_tag, row[j]);
+
 }
 av_bprintf(>buffer, "\\N");
 }
@@ -557,6 +561,9 @@ static void process_cc608(CCaptionSubContext *ctx, int64_t 
pts, uint8_t hi, uint
 ff_dlog(ctx, "Unknown command 0x%hhx 0x%hhx\n", hi, lo);
 break;
 }
+} else if (hi == 0x11 && lo == 0x37) {
+/* Musical note glyph */
+handle_char(ctx, 1, 0, pts);
 } else if (hi >= 0x20) {
 /* Standard characters (always in pairs) */
 handle_char(ctx, hi, lo, pts);
-- 
2.5.3

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


[FFmpeg-devel] [PATCH v2 2/9] lavc/ccaption_dec: implement real_time option

2016-01-12 Thread Aman Gupta
From: Aman Gupta 

This new mode is useful for realtime decoding of closed captions so they
can be display along with mpeg2 frames.

Closed caption streams contain two major types of captions:

- POPON captions, which are buffered off-screen and displayed
  only after EOC (end of caption, aka display buffer)

- PAINTON/ROLLUP captions, which are written to the display as soon as
  they arrive.

In a typical real-time eia608 decoder, commands like EOC (end of
caption; display buffer), EDM (erase display memory) and EBM (erase
buffered memory) perform their expected functions as soon as the
commands are processed. This is implemented in the real_time branches
added in this commit.

Before this commit, and in the !real_time branches after this commit,
the decoder cleverly implements its own version of the decoder which is
specifically geared towards buffered decoding. It does so by actively
ignoring commands like EBM (erase buffered memory), and then re-using
the non-display buffer to hold the previous caption while the new one is
received. This is the opposite of the real-time decoder, which uses the
non-display buffer to hold the new caption while the display buffer is
still showing the current caption.

In addition to ignoring EBM, the buffered decoder also has custom
implementations for EDM and EOC. An EDM (erase display memory) command
flushes the existing contents before clearing the screen, and EOC
similarly always flushes the active buffer (the previous subtitle)
before flipping buffers.
---
 libavcodec/ccaption_dec.c | 80 ++-
 1 file changed, 72 insertions(+), 8 deletions(-)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index a9dfc94..6bdd754 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -116,6 +116,7 @@ struct Screen {
 
 typedef struct CCaptionSubContext {
 AVClass *class;
+int real_time;
 struct Screen screen[2];
 int active_screen;
 uint8_t cursor_row;
@@ -130,6 +131,8 @@ typedef struct CCaptionSubContext {
 /* visible screen time */
 int64_t startv_time;
 int64_t end_time;
+int screen_touched;
+int64_t last_real_time;
 char prev_cmd[2];
 /* buffer to store pkt data */
 AVBufferRef *pktbuf;
@@ -428,15 +431,33 @@ static void handle_edm(CCaptionSubContext *ctx, int64_t 
pts)
 {
 struct Screen *screen = ctx->screen + ctx->active_screen;
 
-reap_screen(ctx, pts);
+// In buffered mode, keep writing to screen until it is wiped.
+// Before wiping the display, capture contents to emit subtitle.
+if (!ctx->real_time)
+reap_screen(ctx, pts);
+
 screen->row_used = 0;
+
+// In realtime mode, emit an empty caption so the last one doesn't
+// stay on the screen.
+if (ctx->real_time)
+reap_screen(ctx, pts);
 }
 
 static void handle_eoc(CCaptionSubContext *ctx, int64_t pts)
 {
-handle_edm(ctx,pts);
+// In buffered mode, we wait til the *next* EOC and
+// reap what was already on the screen since the last EOC.
+if (!ctx->real_time)
+handle_edm(ctx,pts);
+
 ctx->active_screen = !ctx->active_screen;
 ctx->cursor_column = 0;
+
+// In realtime mode, we display the buffered contents (after
+// flipping the buffer to active above) as soon as EOC arrives.
+if (ctx->real_time)
+reap_screen(ctx, pts);
 }
 
 static void handle_delete_end_of_row(CCaptionSubContext *ctx, char hi, char lo)
@@ -458,6 +479,9 @@ static void handle_char(CCaptionSubContext *ctx, char hi, 
char lo, int64_t pts)
 }
 write_char(ctx, screen, 0);
 
+if (ctx->mode != CCMODE_POPON)
+ctx->screen_touched = 1;
+
 /* reset prev command since character can repeat */
 ctx->prev_cmd[0] = 0;
 ctx->prev_cmd[1] = 0;
@@ -507,10 +531,20 @@ static void process_cc608(CCaptionSubContext *ctx, 
int64_t pts, uint8_t hi, uint
 case 0x2d:
 /* carriage return */
 ff_dlog(ctx, "carriage return\n");
-reap_screen(ctx, pts);
+if (!ctx->real_time)
+reap_screen(ctx, pts);
 roll_up(ctx);
 ctx->cursor_column = 0;
 break;
+case 0x2e:
+/* erase buffered (non displayed) memory */
+// Only in realtime mode. In buffered mode, we re-use the inactive 
screen
+// for our own buffering.
+if (ctx->real_time) {
+struct Screen *screen = ctx->screen + !ctx->active_screen;
+screen->row_used = 0;
+}
+break;
 case 0x2f:
 /* end of caption */
 ff_dlog(ctx, "handle_eoc\n");
@@ -562,24 +596,54 @@ static int decode(AVCodecContext *avctx, void *data, int 
*got_sub, AVPacket *avp
 continue;
 else
 process_cc608(ctx, avpkt->pts, *(bptr + i + 1) & 0x7f, *(bptr + i 
+ 2) & 0x7f);
-if (ctx->buffer_changed && *ctx->buffer.str)
+

[FFmpeg-devel] [PATCH v2 6/9] lavc/ccaption_dec: clear all unused rows during rollup

2016-01-12 Thread Aman Gupta
From: Aman Gupta 

Sometimes rollup captions can move around the screen. This fixes "ghost"
captions from below the current rollup area from continuing to be
captured when a rollup moves higher up on the screen.
---
 libavcodec/ccaption_dec.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
index 50625df..ff0735e 100644
--- a/libavcodec/ccaption_dec.c
+++ b/libavcodec/ccaption_dec.c
@@ -295,9 +295,11 @@ static void roll_up(CCaptionSubContext *ctx)
  */
 keep_lines = FFMIN(ctx->cursor_row + 1, ctx->rollup);
 
-for (i = 0; i < ctx->cursor_row - keep_lines; i++)
+for (i = 0; i < SCREEN_ROWS; i++) {
+if (i > (ctx->cursor_row - keep_lines) && i <= ctx->cursor_row)
+continue;
 UNSET_FLAG(screen->row_used, i);
-
+}
 
 for (i = 0; i < keep_lines && screen->row_used; i++) {
 const int i_row = ctx->cursor_row - keep_lines + i + 1;
@@ -307,8 +309,8 @@ static void roll_up(CCaptionSubContext *ctx)
 memcpy(screen->fonts[i_row], screen->fonts[i_row+1], SCREEN_COLUMNS);
 if (CHECK_FLAG(screen->row_used, i_row + 1))
 SET_FLAG(screen->row_used, i_row);
-
 }
+
 UNSET_FLAG(screen->row_used, ctx->cursor_row);
 }
 
-- 
2.5.3

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


Re: [FFmpeg-devel] [PATCH v2 1/9] lavc/ccaption_dec: flush context on seek

2016-01-12 Thread Aman Gupta
On Tue, Jan 12, 2016 at 5:42 PM, Aman Gupta  wrote:

> From: Aman Gupta 
>
> ---
>  libavcodec/ccaption_dec.c | 21 +
>  1 file changed, 21 insertions(+)
>
> diff --git a/libavcodec/ccaption_dec.c b/libavcodec/ccaption_dec.c
> index ca497e5..a9dfc94 100644
> --- a/libavcodec/ccaption_dec.c
> +++ b/libavcodec/ccaption_dec.c
> @@ -173,6 +173,26 @@ static av_cold int close_decoder(AVCodecContext
> *avctx)
>  return 0;
>  }
>
> +static void flush_decoder(AVCodecContext *avctx)
> +{
> +CCaptionSubContext *ctx = avctx->priv_data;
> +ctx->screen[0].row_used = 0;
> +ctx->screen[1].row_used = 0;
> +ctx->prev_cmd[0] = 0;
> +ctx->prev_cmd[1] = 0;
> +ctx->mode = CCMODE_ROLLUP;
> +ctx->rollup = 2;
> +ctx->cursor_row = 0;
> +ctx->cursor_column = 0;
> +ctx->cursor_font = 0;
> +ctx->cursor_color = 0;
> +ctx->active_screen = 0;
> +ctx->last_real_time = 0;
> +ctx->screen_touched = 0;
>

I messed up a rebase here... these two fields weren't introduced until the
next commit.

I've re-rolled the patchset here with a fix:
https://github.com/tmm1/ffmpeg/compare/master...upstream-cc.patch


> +ctx->buffer_changed = 0;
> +av_bprint_clear(>buffer);
> +}
> +
>  /**
>   * @param ctx closed caption context just to print log
>   */
> @@ -578,6 +598,7 @@ AVCodec ff_ccaption_decoder = {
>  .priv_data_size = sizeof(CCaptionSubContext),
>  .init   = init_decoder,
>  .close  = close_decoder,
> +.flush  = flush_decoder,
>  .decode = decode,
>  .priv_class = _dec_class,
>  };
> --
> 2.5.3
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/3] lavd: add teletext quantizer

2016-01-12 Thread Andrey Turkin
Why not use libzvbi's slicer? It should be pretty robust with
less-than-ideal signal.

Regarding your code - is there a need to calculate a frequency? I did
something similar a while back with VBI from TV signal and in my experience:

a) this kind of frequency/phase estimation doesn't work that well on a
noisy signal.
 b) there's really no need to estimate frequency - it's a known constant
(well it depends on a standard but in each standard it is a constant) and
generators usually don't deviate from it; you just need to get a good phase
estimation based on, say, local maxima/minima of run-in bits.

Ideal frequency (or rather period) for WST in your code should be 127530; I
presume 4 last samples are WST so their estimated frequency is pretty far
outside specified 25ppm tolerance. Value of 127590 means  that for the last
bit you get a (127590-127530)/65536*360 phase error which is about 1/3 of
period (still within the sample if initial phase was estimated accurately -
but getting close to the edge). However any additional error in estimated
frequency would cause lost or duplicate bits in the last bits of decoded
data. If SDI data is noisy there's a good chance of that happening (and
noisy SDI is not some theoretical possibility - one of local TV studios has
a rather strange setup where they do several SDI->analog and analog->SDI
conversions; frames coming from their last SDI output are already noisy).

2016-01-13 1:40 GMT+03:00 Marton Balint :

> Getting teletext right from VANC/VBI data is tricky, because the teletext
> clock
> is not synced to the video clock. Therefore we have to first measure the
> frequency of the teletext clock in the reconstructed signal, and then
> resample
> the original data appropriately.
>
> What I do is that I measure the distance between the first and the last
> zero
> crossing (leading edge) in the first 3 (constant) bytes of the input to
> calculate the clock frequency and the starting point of the real teletext
> data.
>
> Based on these I can calculate the offsets where the rest of the signal
> needs
> to be quantized, and I do that by a simple linear interpolation between two
> neighbouring values in the original data, so the resampling method is
> simple
> first order hold.
>
> Fixed point arithmethic is used for frequencies and offsets to improve
> precision.
>
> I guess the DSP minded people can come up with a better way, but it works
> for
> me just fine as it is.
>
> Signed-off-by: Marton Balint 
> ---
>  libavdevice/Makefile  |   2 +-
>  libavdevice/teletext_quantizer.c  | 174
> ++
>  libavdevice/teletext_quantizer.h  |  32 +++
>  tests/fate/libavdevice.mak|   5 +-
>  tests/ref/fate/teletext_quantizer |  22 +
>  5 files changed, 233 insertions(+), 2 deletions(-)
>  create mode 100644 libavdevice/teletext_quantizer.c
>  create mode 100644 libavdevice/teletext_quantizer.h
>  create mode 100644 tests/ref/fate/teletext_quantizer
>
> diff --git a/libavdevice/Makefile b/libavdevice/Makefile
> index f57ec0b..f889b7c 100644
> --- a/libavdevice/Makefile
> +++ b/libavdevice/Makefile
> @@ -69,4 +69,4 @@ SKIPHEADERS-$(CONFIG_V4L2_OUTDEV)+= v4l2-common.h
>  SKIPHEADERS-$(HAVE_ALSA_ASOUNDLIB_H) += alsa.h
>  SKIPHEADERS-$(HAVE_SNDIO_H)  += sndio.h
>
> -TESTPROGS = timefilter
> +TESTPROGS = timefilter teletext_quantizer
> diff --git a/libavdevice/teletext_quantizer.c
> b/libavdevice/teletext_quantizer.c
> new file mode 100644
> index 000..af6dbbf
> --- /dev/null
> +++ b/libavdevice/teletext_quantizer.c
> @@ -0,0 +1,174 @@
> +/*
> + * 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/common.h"
> +#include "libavutil/mem.h"
> +#include "config.h"
> +#include "teletext_quantizer.h"
> +
> +#define BLACK_LEVEL 16
> +#define WHITE_LEVEL 235
> +#define DATA_ZERO_LEVEL (BLACK_LEVEL)
> +#define DATA_ONE_LEVEL (BLACK_LEVEL + ((WHITE_LEVEL - BLACK_LEVEL) * 2 /
> 3))
> +#define DATA_ZERO_MAX ((DATA_ONE_LEVEL + DATA_ZERO_LEVEL) / 2)
> +#define MAX_FRAMING_CODE_END_POSITION 64
> +
> +#define CLOCK_RUNIN  0xaa
> +#define FRAMING_CODE 0xe4
> +
> +static inline int calc_zerocross(int i, uint8_t y1, uint8_t y2)

Re: [FFmpeg-devel] [PATCH]lavf/icodec: Improve probe function

2016-01-12 Thread Michael Bradshaw
Overall it looks good. I thought it might overflow the buffer but with
AVPROBE_PADDING_SIZE it doesn't.

On Tue, Jan 12, 2016 at 7:09 AM, Carl Eugen Hoyos  wrote:
> diff --git a/libavformat/icodec.c b/libavformat/icodec.c
> index 22e2099..9cf3dca 100644
> --- a/libavformat/icodec.c
> +++ b/libavformat/icodec.c
> @@ -27,6 +27,7 @@
>  #include "libavutil/intreadwrite.h"
>  #include "libavcodec/bytestream.h"
>  #include "libavcodec/bmp.h"
> +#include "libavcodec/png.h"
>  #include "avformat.h"
>  #include "internal.h"
>
> @@ -44,9 +45,30 @@ typedef struct {
>
>  static int probe(AVProbeData *p)
>  {
> -if (AV_RL16(p->buf) == 0 && AV_RL16(p->buf + 2) == 1 && AV_RL16(p->buf + 
> 4))
> -return AVPROBE_SCORE_MAX / 4;
> -return 0;
> +unsigned i, frames = AV_RL16(p->buf + 4);
> +
> +if (AV_RL16(p->buf) || AV_RL16(p->buf + 2) != 1 || !frames)
> +return 0;
> +for (i = 0; i < frames; i++) {
> +unsigned offset;
> +if (AV_RL16(p->buf + 10 + i * 16) & ~1) // color planes
> +return FFMIN(i, AVPROBE_SCORE_MAX / 4);
> +if (p->buf[13 + i * 16])
> +return FFMIN(i, AVPROBE_SCORE_MAX / 4);
> +if (AV_RL32(p->buf + 14 + i * 16) < 40)  // size
> +return FFMIN(i, AVPROBE_SCORE_MAX / 4);
> +offset = AV_RL32(p->buf + 18 + i * 16);
> +if (offset < 22)
> +return FFMIN(i, AVPROBE_SCORE_MAX / 4);
> +if (offset + 8 > p->buf_size)
> +return AVPROBE_SCORE_MAX / 4 + FFMIN(i, 1);
> +if (p->buf[offset] != 40 && AV_RB64(p->buf + offset) != PNGSIG)
> +return FFMIN(i, AVPROBE_SCORE_MAX / 4);
> +if (i * 16 + 6 > p->buf_size)
> +return AVPROBE_SCORE_MAX / 4;
> +}
> +
> +return AVPROBE_SCORE_MAX / 4 + 1;

A score of 26 seems low to me, but maybe that's just me.

>  }
>
>  static int read_header(AVFormatContext *s)

I checked all the various header bytes this would be checking and it
all looks good.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH]lavf/mpjpegdec: Do not av_log() while probing

2016-01-12 Thread Carl Eugen Hoyos
Hi!

Attached patch silences the mpjpeg probing function.

Please comment, Carl Eugen
diff --git a/libavformat/mpjpegdec.c b/libavformat/mpjpegdec.c
index dd31f87..c9fcf47 100644
--- a/libavformat/mpjpegdec.c
+++ b/libavformat/mpjpegdec.c
@@ -198,6 +198,7 @@ static int parse_multipart_header(AVIOContext *pb,
 }
 
 if (!av_strstart(line, expected_boundary, NULL)) {
+if (log_ctx)
 av_log(log_ctx,
 AV_LOG_ERROR,
 "Expected boundary '%s' not found, instead found a line of %zu 
bytes\n",
@@ -228,6 +229,7 @@ static int parse_multipart_header(AVIOContext *pb,
 
 if (!av_strcasecmp(tag, "Content-type")) {
 if (av_strcasecmp(value, "image/jpeg")) {
+if (log_ctx)
 av_log(log_ctx, AV_LOG_ERROR,
"Unexpected %s : %s\n",
tag, value);
@@ -237,6 +239,7 @@ static int parse_multipart_header(AVIOContext *pb,
 } else if (!av_strcasecmp(tag, "Content-Length")) {
 *size = parse_content_length(value);
 if ( *size < 0 )
+if (log_ctx)
 av_log(log_ctx, AV_LOG_WARNING,
"Invalid Content-Length value : %s\n",
value);
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel