Re: [FFmpeg-devel] [PATCH 1/6] lavf/brstm: add support for BFSTM files

2015-06-17 Thread Paul B Mahol
Dana 17. 6. 2015. 00:28 osoba "Rodger Combs" 
napisala je:
>
> ---
>  libavcodec/utils.c   |   4 ++
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/brstm.c  | 129
+++
>  4 files changed, 115 insertions(+), 20 deletions(-)
>
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 558afeb..a444a5e 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -3430,6 +3430,10 @@ int av_get_audio_frame_duration(AVCodecContext
*avctx, int frame_bytes)
>  return (frame_bytes - 4) * 2 / ch;
>  case AV_CODEC_ID_ADPCM_IMA_AMV:
>  return (frame_bytes - 8) * 2 / ch;
> +case AV_CODEC_ID_ADPCM_THP:
> +if (avctx->extradata)
> +return frame_bytes * 14 / (8 * ch);
> +break;
>  case AV_CODEC_ID_ADPCM_XA:
>  return (frame_bytes / 128) * 224 / ch;
>  case AV_CODEC_ID_INTERPLAY_DPCM:
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index b9169d9..3c2cf9f 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -106,6 +106,7 @@ OBJS-$(CONFIG_BIT_MUXER) += bit.o
>  OBJS-$(CONFIG_BMV_DEMUXER)   += bmv.o
>  OBJS-$(CONFIG_BOA_DEMUXER)   += boadec.o
>  OBJS-$(CONFIG_BRSTM_DEMUXER) += brstm.o
> +OBJS-$(CONFIG_BFSTM_DEMUXER) += brstm.o

Not in alphabetical order.

>  OBJS-$(CONFIG_C93_DEMUXER)   += c93.o vocdec.o voc.o
>  OBJS-$(CONFIG_CAF_DEMUXER)   += cafdec.o caf.o mov.o
mov_chan.o \
>  isom.o replaygain.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 3a49650..cc77d1c 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -93,6 +93,7 @@ void av_register_all(void)
>  REGISTER_MUXDEMUX(BIT,  bit);
>  REGISTER_DEMUXER (BMV,  bmv);
>  REGISTER_DEMUXER (BRSTM,brstm);
> +REGISTER_DEMUXER (BFSTM,   bfstm);

not in alphabetical order

>  REGISTER_DEMUXER (BOA,  boa);
>  REGISTER_DEMUXER (C93,  c93);
>  REGISTER_MUXDEMUX(CAF,  caf);
> diff --git a/libavformat/brstm.c b/libavformat/brstm.c
> index 19a4a2a..1eba943 100644
> --- a/libavformat/brstm.c
> +++ b/libavformat/brstm.c
> @@ -32,6 +32,7 @@ typedef struct BRSTMDemuxContext {
>  uint32_tlast_block_used_bytes;
>  uint8_t *table;
>  uint8_t *adpc;
> +int bfstm;
>  } BRSTMDemuxContext;
>
>  static int probe(AVProbeData *p)
> @@ -43,6 +44,15 @@ static int probe(AVProbeData *p)
>  return 0;
>  }
>
> +static int probe_bfstm(AVProbeData *p)
> +{
> +if (AV_RL32(p->buf) == MKTAG('F','S','T','M') &&
> +(AV_RL16(p->buf + 4) == 0xFFFE ||
> + AV_RL16(p->buf + 4) == 0xFEFF))
> +return AVPROBE_SCORE_MAX / 3 * 2;
> +return 0;
> +}
> +
>  static int read_close(AVFormatContext *s)
>  {
>  BRSTMDemuxContext *b = s->priv_data;
> @@ -57,11 +67,13 @@ static int read_header(AVFormatContext *s)
>  {
>  BRSTMDemuxContext *b = s->priv_data;
>  int bom, major, minor, codec, chunk;
> -int64_t pos, h1offset, toffset;
> +int64_t h1offset, pos, toffset, data_offset = 0;
>  uint32_t size, start, asize;
>  AVStream *st;
>  int ret = AVERROR_EOF;
>
> +b->bfstm = !strcmp("bfstm", s->iformat->name);
> +
>  st = avformat_new_stream(s, NULL);
>  if (!st)
>  return AVERROR(ENOMEM);
> @@ -79,19 +91,65 @@ static int read_header(AVFormatContext *s)
>  return AVERROR_PATCHWELCOME;
>  }
>
> -major = avio_r8(s->pb);
> -minor = avio_r8(s->pb);
> -avio_skip(s->pb, 4); // size of file
> -size = avio_rb16(s->pb);
> -if (size < 14)
> -return AVERROR_INVALIDDATA;
> +if (!b->bfstm) {
> +major = avio_r8(s->pb);
> +minor = avio_r8(s->pb);
> +avio_skip(s->pb, 4); // size of file
> +size = avio_rb16(s->pb);
> +if (size < 14)
> +return AVERROR_INVALIDDATA;
> +
> +avio_skip(s->pb, size - 14);
> +pos = avio_tell(s->pb);
> +if (avio_rl32(s->pb) != MKTAG('H','E','A','D'))
> +return AVERROR_INVALIDDATA;
> +} else {
> +uint32_t info_offset = 0, info_size;
> +uint16_t section_count, header_size, i;
> +
> +header_size = avio_rb16(s->pb); // 6
> +
> +avio_skip(s->pb, 4); // Unknown constant 0x0003
> +avio_skip(s->pb, 4); // size of file
> +section_count = avio_rb16(s->pb);
> +avio_skip(s->pb, 2); // padding
> +for (i = 0; avio_tell(s->pb) < header_size
> +&& !(data_offset && info_offset)
> +&& i < section_count; i++) {
> +uint32_t flag = avio_rb32(s->pb);
> +switch (flag) {
> +case 0x4000:
> +  

[FFmpeg-devel] [PATCH] lavf/brstm: add support for BFSTM files

2015-06-17 Thread Rodger Combs
Adds a FATE test with sample file:
fate-suite/bfstm/spl-forest-day.bfstm
Available at:
http://puu.sh/is0XS/ac869386e6.bfstm
---
 Changelog|   1 +
 doc/general.texi |   2 +
 libavcodec/utils.c   |   4 ++
 libavformat/Makefile |   1 +
 libavformat/allformats.c |   1 +
 libavformat/brstm.c  | 129 +++
 libavformat/version.h|   2 +-
 tests/fate/demux.mak |   3 ++
 tests/ref/fate/bfstm |   1 +
 9 files changed, 123 insertions(+), 21 deletions(-)
 create mode 100644 tests/ref/fate/bfstm

diff --git a/Changelog b/Changelog
index 3853978..c93889a 100644
--- a/Changelog
+++ b/Changelog
@@ -3,6 +3,7 @@ releases are sorted from youngest to oldest.
 
 version :
 - colorkey video filter
+- BFSTM demuxer
 
 
 version 2.7:
diff --git a/doc/general.texi b/doc/general.texi
index ba79503..471a11b 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -243,6 +243,8 @@ library:
 @tab Used in Z and Z95 games.
 @item Brute Force & Ignorance   @tab   @tab X
 @tab Used in the game Flash Traffic: City of Angels.
+@item BFSTM @tab   @tab X
+@tab Audio format used on the Nintendo WiiU (based on BRSTM).
 @item BRSTM @tab   @tab X
 @tab Audio format used on the Nintendo Wii.
 @item BWF   @tab X @tab X
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 558afeb..a444a5e 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -3430,6 +3430,10 @@ int av_get_audio_frame_duration(AVCodecContext *avctx, 
int frame_bytes)
 return (frame_bytes - 4) * 2 / ch;
 case AV_CODEC_ID_ADPCM_IMA_AMV:
 return (frame_bytes - 8) * 2 / ch;
+case AV_CODEC_ID_ADPCM_THP:
+if (avctx->extradata)
+return frame_bytes * 14 / (8 * ch);
+break;
 case AV_CODEC_ID_ADPCM_XA:
 return (frame_bytes / 128) * 224 / ch;
 case AV_CODEC_ID_INTERPLAY_DPCM:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index b9169d9..993ec09 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -105,6 +105,7 @@ OBJS-$(CONFIG_BIT_DEMUXER)   += bit.o
 OBJS-$(CONFIG_BIT_MUXER) += bit.o
 OBJS-$(CONFIG_BMV_DEMUXER)   += bmv.o
 OBJS-$(CONFIG_BOA_DEMUXER)   += boadec.o
+OBJS-$(CONFIG_BFSTM_DEMUXER) += brstm.o
 OBJS-$(CONFIG_BRSTM_DEMUXER) += brstm.o
 OBJS-$(CONFIG_C93_DEMUXER)   += c93.o vocdec.o voc.o
 OBJS-$(CONFIG_CAF_DEMUXER)   += cafdec.o caf.o mov.o mov_chan.o \
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 3a49650..306e0c9 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -92,6 +92,7 @@ void av_register_all(void)
 REGISTER_DEMUXER (BINK, bink);
 REGISTER_MUXDEMUX(BIT,  bit);
 REGISTER_DEMUXER (BMV,  bmv);
+REGISTER_DEMUXER (BFSTM,bfstm);
 REGISTER_DEMUXER (BRSTM,brstm);
 REGISTER_DEMUXER (BOA,  boa);
 REGISTER_DEMUXER (C93,  c93);
diff --git a/libavformat/brstm.c b/libavformat/brstm.c
index 19a4a2a..1eba943 100644
--- a/libavformat/brstm.c
+++ b/libavformat/brstm.c
@@ -32,6 +32,7 @@ typedef struct BRSTMDemuxContext {
 uint32_tlast_block_used_bytes;
 uint8_t *table;
 uint8_t *adpc;
+int bfstm;
 } BRSTMDemuxContext;
 
 static int probe(AVProbeData *p)
@@ -43,6 +44,15 @@ static int probe(AVProbeData *p)
 return 0;
 }
 
+static int probe_bfstm(AVProbeData *p)
+{
+if (AV_RL32(p->buf) == MKTAG('F','S','T','M') &&
+(AV_RL16(p->buf + 4) == 0xFFFE ||
+ AV_RL16(p->buf + 4) == 0xFEFF))
+return AVPROBE_SCORE_MAX / 3 * 2;
+return 0;
+}
+
 static int read_close(AVFormatContext *s)
 {
 BRSTMDemuxContext *b = s->priv_data;
@@ -57,11 +67,13 @@ static int read_header(AVFormatContext *s)
 {
 BRSTMDemuxContext *b = s->priv_data;
 int bom, major, minor, codec, chunk;
-int64_t pos, h1offset, toffset;
+int64_t h1offset, pos, toffset, data_offset = 0;
 uint32_t size, start, asize;
 AVStream *st;
 int ret = AVERROR_EOF;
 
+b->bfstm = !strcmp("bfstm", s->iformat->name);
+
 st = avformat_new_stream(s, NULL);
 if (!st)
 return AVERROR(ENOMEM);
@@ -79,19 +91,65 @@ static int read_header(AVFormatContext *s)
 return AVERROR_PATCHWELCOME;
 }
 
-major = avio_r8(s->pb);
-minor = avio_r8(s->pb);
-avio_skip(s->pb, 4); // size of file
-size = avio_rb16(s->pb);
-if (size < 14)
-return AVERROR_INVALIDDATA;
+if (!b->bfstm) {
+major = avio_r8(s->pb);
+minor = avio_r8(s->pb);
+avio_skip(s->pb, 4); // size of file
+size = avio_rb16(s->pb);
+if (size < 14)
+return AVERROR_INVALIDDATA;
+
+avio_skip(s->pb, size - 14);
+  

Re: [FFmpeg-devel] [PATCH] lavf/brstm: add support for BFSTM files

2015-06-17 Thread Michael Niedermayer
On Wed, Jun 17, 2015 at 03:09:52AM -0500, Rodger Combs wrote:
> Adds a FATE test with sample file:

> fate-suite/bfstm/spl-forest-day.bfstm
> Available at:
> http://puu.sh/is0XS/ac869386e6.bfstm

file uploaded


> ---
>  Changelog|   1 +
>  doc/general.texi |   2 +
>  libavcodec/utils.c   |   4 ++
>  libavformat/Makefile |   1 +
>  libavformat/allformats.c |   1 +
>  libavformat/brstm.c  | 129 
> +++
>  libavformat/version.h|   2 +-
>  tests/fate/demux.mak |   3 ++
>  tests/ref/fate/bfstm |   1 +
>  9 files changed, 123 insertions(+), 21 deletions(-)
>  create mode 100644 tests/ref/fate/bfstm

applied without the fate test, please resubmit the fate test in >24h
so the clients all synced the samples and have it available when the
test is added

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 2/6] lavc/adpcm: THP: handle trailing padding

2015-06-17 Thread Michael Niedermayer
On Tue, Jun 16, 2015 at 05:28:14PM -0500, Rodger Combs wrote:
> ---
>  libavcodec/adpcm.c | 5 -
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
> index 22b5468..07ebce8 100644
> --- a/libavcodec/adpcm.c
> +++ b/libavcodec/adpcm.c
> @@ -637,7 +637,7 @@ static int get_nb_samples(AVCodecContext *avctx, 
> GetByteContext *gb,
>  }
>  case AV_CODEC_ID_ADPCM_THP:
>  if (avctx->extradata) {
> -nb_samples = buf_size / (8 * ch) * 14;
> +nb_samples = buf_size * 14 / (8 * ch);

doesnt this leave uninitialized samples at the end ?

also theres a 2nd "buf_size / (8 * ch) * 14" a few lines later
is that intended ?

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

DNS cache poisoning attacks, popular search engine, Google internet authority
dont be evil, please


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


Re: [FFmpeg-devel] [PATCH 3/6] lavf/brstm: add support for seeking

2015-06-17 Thread Michael Niedermayer
On Tue, Jun 16, 2015 at 05:28:15PM -0500, Rodger Combs wrote:
> ---
>  libavformat/brstm.c | 17 +
>  1 file changed, 17 insertions(+)
> 
> diff --git a/libavformat/brstm.c b/libavformat/brstm.c
> index 1eba943..8adffb8 100644
> --- a/libavformat/brstm.c
> +++ b/libavformat/brstm.c
> @@ -30,6 +30,7 @@ typedef struct BRSTMDemuxContext {
>  uint32_tcurrent_block;
>  uint32_tsamples_per_block;
>  uint32_tlast_block_used_bytes;
> +uint32_tdata_start;
>  uint8_t *table;
>  uint8_t *adpc;
>  int bfstm;
> @@ -298,6 +299,8 @@ static int read_header(AVFormatContext *s)
>  }
>  avio_skip(s->pb, start - avio_tell(s->pb));
>  
> +b->data_start = avio_tell(s->pb);
> +
>  if ((major != 1 || minor) && !b->bfstm)
>  avpriv_request_sample(s, "Version %d.%d", major, minor);
>  
> @@ -363,6 +366,18 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
>  return ret;
>  }
>  
> +static int read_seek(AVFormatContext *s, int stream_index,
> + int64_t timestamp, int flags)
> +{
> +AVStream *st = s->streams[stream_index];
> +BRSTMDemuxContext *b = s->priv_data;
> +timestamp /= b->samples_per_block;

> +avio_seek(s->pb, b->data_start + timestamp * b->block_size, SEEK_SET);

the return code should be checked, the file could be smaller than the
target the user wants to seek to

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

Observe your enemies, for they first find out your faults. -- Antisthenes


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


Re: [FFmpeg-devel] [PATCH 1/5] avcodec/mips: MSA (MIPS-SIMD-Arch) optimizations for H263 lpf functions

2015-06-17 Thread Michael Niedermayer
On Sun, Jun 14, 2015 at 11:26:22PM +0530, shivraj.pa...@imgtec.com wrote:
> From: Shivraj Patil 
> 
> This patch adds MSA (MIPS-SIMD-Arch) optimizations for H263 lpf functions in 
> new file h263dsp_msa.c
> 
> Signed-off-by: Shivraj Patil 
> ---
>  libavcodec/h263dsp.c|   2 +
>  libavcodec/h263dsp.h|   1 +
>  libavcodec/mips/Makefile|   2 +
>  libavcodec/mips/h263dsp_init_mips.c |  36 
>  libavcodec/mips/h263dsp_mips.h  |  36 
>  libavcodec/mips/h263dsp_msa.c   | 164 
> 
>  6 files changed, 241 insertions(+)
>  create mode 100644 libavcodec/mips/h263dsp_init_mips.c
>  create mode 100644 libavcodec/mips/h263dsp_mips.h
>  create mode 100644 libavcodec/mips/h263dsp_msa.c

applied

thanks

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

I do not agree with what you have to say, but I'll defend to the death your
right to say it. -- Voltaire


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


[FFmpeg-devel] [PATCH] avcodec/flacenc: Regression test for ticket #4628

2015-06-17 Thread George Boyle
Corresponding commit: 2469ed32c81ebf2347e6883091c566724b286167
---
 tests/fate/flac.mak | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/fate/flac.mak b/tests/fate/flac.mak
index 4a13404..115cc96 100644
--- a/tests/fate/flac.mak
+++ b/tests/fate/flac.mak
@@ -6,6 +6,7 @@ FATE_FLAC += fate-flac-16-chmode-indep  
\
  fate-flac-16-lpc-cholesky  \
  fate-flac-16-lpc-levinson  \
  fate-flac-24-comp-8\
+ fate-flac-rice-params  \
 
 fate-flac-16-chmode-%: OPTS = -ch_mode $(@:fate-flac-16-chmode-%=%)
 fate-flac-16-fixed:OPTS = -lpc_type fixed
@@ -19,6 +20,9 @@ fate-flac-24-comp-%: OPTS = -compression_level 
$(@:fate-flac-24-comp-%=%)
 fate-flac-24-%: REF = $(SAMPLES)/audio-reference/divertimenti_2ch_96kHz_s24.wav
 fate-flac-24-%: CMD = enc_dec_pcm flac wav s24le $(subst 
$(SAMPLES),$(TARGET_SAMPLES),$(REF)) -c flac $(OPTS)
 
+fate-flac-rice-params: REF = 
$(SAMPLES)/audio-reference/chorusnoise_2ch_44kHz_s16.wav
+fate-flac-rice-params: CMD = enc_dec_pcm flac wav s16le $(subst 
$(SAMPLES),$(TARGET_SAMPLES),$(REF)) -c flac
+
 fate-flac-%: CMP = oneoff
 fate-flac-%: FUZZ = 0
 
-- 
2.4.3

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


[FFmpeg-devel] [PATCH 1/2] movtextdec.c: Improve upon dynarrays and text_to_ass

2015-06-17 Thread Niklesh Lalwani
From: Niklesh 

This Patch uses a single dynarray instead of 3 dynarrays used before. Changes 
are also done in text_to_ass() which previously failed to produce correct 
results for a few specific cases.
Signed-off-by: Niklesh 
---
 libavcodec/movtextdec.c | 83 -
 1 file changed, 41 insertions(+), 42 deletions(-)

diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index 8dda5ce..d1e2d61 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -31,19 +31,36 @@
 #define STYLE_FLAG_ITALIC   2
 #define STYLE_FLAG_UNDERLINE4
 
+typedef struct {
+uint16_t style_start;
+uint16_t style_end;
+uint8_t style_flag;
+} StyleBox;
+
 static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end,
-char **style_start, char **style_end,
-uint8_t **style_flags, int style_entries)
+StyleBox **s, int style_entries)
 {
 int i = 0;
+int text_pos = 0;
 while (text < text_end) {
 for (i = 0; i < style_entries; i++) {
-if (*style_flags[i] && text == style_start[i]) {
-if (*style_flags[i] & STYLE_FLAG_BOLD)
+if (s[i]->style_flag && text_pos == s[i]->style_end) {
+if (s[i]->style_flag & STYLE_FLAG_BOLD)
+av_bprintf(buf, "{\\b0}");
+if (s[i]->style_flag & STYLE_FLAG_ITALIC)
+av_bprintf(buf, "{\\i0}");
+if (s[i]->style_flag & STYLE_FLAG_UNDERLINE)
+av_bprintf(buf, "{\\u0}");
+}
+}
+
+for (i = 0; i < style_entries; i++) {
+if (s[i]->style_flag && text_pos == s[i]->style_start) {
+if (s[i]->style_flag & STYLE_FLAG_BOLD)
 av_bprintf(buf, "{\\b1}");
-if (*style_flags[i] & STYLE_FLAG_ITALIC)
+if (s[i]->style_flag & STYLE_FLAG_ITALIC)
 av_bprintf(buf, "{\\i1}");
-if (*style_flags[i] & STYLE_FLAG_UNDERLINE)
+if (s[i]->style_flag & STYLE_FLAG_UNDERLINE)
 av_bprintf(buf, "{\\u1}");
 }
 }
@@ -58,18 +75,8 @@ static int text_to_ass(AVBPrint *buf, const char *text, 
const char *text_end,
 av_bprint_chars(buf, *text, 1);
 break;
 }
-
-for (i = 0; i < style_entries; i++) {
-if (*style_flags[i] && text == style_end[i]) {
-if (*style_flags[i] & STYLE_FLAG_BOLD)
-av_bprintf(buf, "{\\b0}");
-if (*style_flags[i] & STYLE_FLAG_ITALIC)
-av_bprintf(buf, "{\\i0}");
-if (*style_flags[i] & STYLE_FLAG_UNDERLINE)
-av_bprintf(buf, "{\\u0}");
-}
-}
 text++;
+text_pos++;
 }
 
 return 0;
@@ -96,13 +103,10 @@ static int mov_text_decode_frame(AVCodecContext *avctx,
 //char *ptr_temp;
 int text_length, tsmb_type, style_entries;
 uint64_t tsmb_size, tracksize;
-char **style_start = { 0, };
-char **style_end = { 0, };
-uint8_t **style_flags = { 0, };
+StyleBox **s = {0, };
+StyleBox *s_temp;
 const uint8_t *tsmb;
-int index, i, size_var;
-uint8_t *flag;
-char *style_pos;
+int count, i, size_var;
 
 if (!ptr || avpkt->size < 2)
 return AVERROR_INVALIDDATA;
@@ -170,40 +174,35 @@ static int mov_text_decode_frame(AVCodecContext *avctx,
 break;
 
 for(i = 0; i < style_entries; i++) {
-style_pos = ptr + AV_RB16(tsmb);
-index = i;
-av_dynarray_add(&style_start, &index, style_pos);
+s_temp = av_malloc(sizeof(StyleBox));
+if (!s_temp)
+return AVERROR(ENOMEM);
+
+s_temp->style_start = AV_RB16(tsmb);
 tsmb += 2;
-style_pos = ptr + AV_RB16(tsmb);
-index = i;
-av_dynarray_add(&style_end, &index, style_pos);
+s_temp->style_end = AV_RB16(tsmb);
 tsmb += 2;
 // fontID = AV_RB16(tsmb);
 tsmb += 2;
-flag = av_malloc(1);
-if (!flag)
-return AVERROR(ENOMEM);
-*flag = AV_RB8(tsmb);
-index = i;
-av_dynarray_add(&style_flags, &index, flag);
+s_temp->style_flag = AV_RB8(tsmb);
+count = i;
+av_dynarray_add(&s, &count, s_temp);
 //fontsize=AV_RB8(tsmb);
 tsmb += 2;
 // text-color-rgba
 tsmb += 4;
 }
-text_to_ass(&buf, ptr, end, style_start, style_end, 
style_flags, style_ent

[FFmpeg-devel] [PATCH 2/2] movtextenc.c: Support for Bold, Italic and Underlined styles

2015-06-17 Thread Niklesh Lalwani
From: Niklesh 

Support for Bold, Italic and Underlined styles. The style information is 
appended into the buffer after the text. Dynarray is used to account for 
multiple style records. Tested on QuickTime OSX and iPhone.
Signed-off-by: Niklesh 
---
 libavcodec/movtextenc.c | 165 ++--
 1 file changed, 145 insertions(+), 20 deletions(-)

diff --git a/libavcodec/movtextenc.c b/libavcodec/movtextenc.c
index 1b8f454..56c599d 100644
--- a/libavcodec/movtextenc.c
+++ b/libavcodec/movtextenc.c
@@ -24,14 +24,38 @@
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
 #include "libavutil/intreadwrite.h"
+#include "libavutil/mem.h"
+#include "libavutil/common.h"
 #include "ass_split.h"
 #include "ass.h"
 
+#define STYLE_FLAG_BOLD 1
+#define STYLE_FLAG_ITALIC   2
+#define STYLE_FLAG_UNDERLINE4
+#define STYLE_RECORD_SIZE   12
+#define SIZE_ADD10
+
+
+typedef struct {
+uint16_t style_start;
+uint16_t style_end;
+uint8_t style_flag;
+} StyleBox;
+
 typedef struct {
 ASSSplitContext *ass_ctx;
-char buffer[2048];
-char *ptr;
-char *end;
+AVBPrint buffer;
+StyleBox **style_attributes;
+StyleBox *style_attributes_temp;
+int count;
+uint8_t style_box_flag;
+uint32_t tsmb_size;
+uint32_t tsmb_type;
+uint16_t style_entries;
+uint16_t style_fontID;
+uint8_t style_fontsize;
+uint32_t style_color;
+uint16_t text_pos;
 } MovTextContext;
 
 
@@ -79,32 +103,98 @@ static av_cold int mov_text_encode_init(AVCodecContext 
*avctx)
 if (!avctx->extradata)
 return AVERROR(ENOMEM);
 
+av_bprint_init(&s->buffer, 0, AV_BPRINT_SIZE_UNLIMITED);
+
 memcpy(avctx->extradata, text_sample_entry, avctx->extradata_size);
 
 s->ass_ctx = ff_ass_split(avctx->subtitle_header);
 return s->ass_ctx ? 0 : AVERROR_INVALIDDATA;
 }
 
+static void mov_text_style_cb(void *priv, const char style, int close)
+{
+MovTextContext *s = priv;
+if (!close) {
+if (s->style_box_flag == 0) {   //first style entry
+
+s->style_attributes_temp = av_malloc(sizeof(StyleBox));
+if (!s->style_attributes_temp)
+return AVERROR(ENOMEM);
+
+s->style_attributes_temp->style_flag = 0;
+s->style_attributes_temp->style_start = AV_RB16(&s->text_pos);
+} else {
+if (s->style_attributes_temp->style_flag) { //break the style 
record here and start a new one
+s->style_attributes_temp->style_end = AV_RB16(&s->text_pos);
+av_dynarray_add(&s->style_attributes, &s->count, 
s->style_attributes_temp);
+
+s->style_attributes_temp = av_malloc(sizeof(StyleBox));
+if (!s->style_attributes_temp)
+return AVERROR(ENOMEM);
+
+s->style_attributes_temp->style_flag = 
s->style_attributes[s->count - 1]->style_flag;
+s->style_attributes_temp->style_start = AV_RB16(&s->text_pos);
+} else {
+s->style_attributes_temp->style_flag = 0;
+s->style_attributes_temp->style_start = AV_RB16(&s->text_pos);
+}
+}
+switch (style){
+case 'b':
+s->style_attributes_temp->style_flag |= STYLE_FLAG_BOLD;
+break;
+case 'i':
+s->style_attributes_temp->style_flag |= STYLE_FLAG_ITALIC;
+break;
+case 'u':
+s->style_attributes_temp->style_flag |= STYLE_FLAG_UNDERLINE;
+break;
+}
+} else {
+s->style_attributes_temp->style_end = AV_RB16(&s->text_pos);
+av_dynarray_add(&s->style_attributes, &s->count, 
s->style_attributes_temp);
+
+s->style_attributes_temp = av_malloc(sizeof(StyleBox));
+if (!s->style_attributes_temp)
+return AVERROR(ENOMEM);
+
+s->style_attributes_temp->style_flag = s->style_attributes[s->count - 
1]->style_flag;
+switch (style){
+case 'b':
+s->style_attributes_temp->style_flag &= ~STYLE_FLAG_BOLD;
+break;
+case 'i':
+s->style_attributes_temp->style_flag &= ~STYLE_FLAG_ITALIC;
+break;
+case 'u':
+s->style_attributes_temp->style_flag &= ~STYLE_FLAG_UNDERLINE;
+break;
+}
+if (s->style_attributes_temp->style_flag) { //start of new style record
+s->style_attributes_temp->style_start = AV_RB16(&s->text_pos);
+}
+}
+s->style_box_flag = 1;
+}
+
 static void mov_text_text_cb(void *priv, const char *text, int len)
 {
 MovTextContext *s = priv;
-av_assert0(s->end >= s->ptr);
-av_strlcpy(s->ptr, text, FFMIN(s->end - s->ptr, len + 1));
-s->ptr += FFMIN(s->end - s->ptr, len);
+av_bprint_append_data(&s->buffer, text, len);
+s->text_pos += len;
 }
 
 static void mov_text_new_line_cb(void *priv, int forced)
 {
 MovTextContext *s = pr

[FFmpeg-devel] [PATCH] vp9: don't retain NULL as segmentation_map

2015-06-17 Thread Andreas Cadhalpun
This fixes segmentation faults, which were introduced in commit
4ba8f327.

Signed-off-by: Andreas Cadhalpun 
---
 libavcodec/vp9.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
index 4e2ed53..9d9326c 100644
--- a/libavcodec/vp9.c
+++ b/libavcodec/vp9.c
@@ -3988,7 +3988,8 @@ static int vp9_decode_frame(AVCodecContext *ctx, void 
*frame,
 int size = pkt->size;
 VP9Context *s = ctx->priv_data;
 int res, tile_row, tile_col, i, ref, row, col;
-int retain_segmap_ref = s->segmentation.enabled && 
!s->segmentation.update_map;
+int retain_segmap_ref = s->segmentation.enabled && 
!s->segmentation.update_map
+&& s->frames[REF_FRAME_SEGMAP].segmentation_map;
 ptrdiff_t yoff, uvoff, ls_y, ls_uv;
 AVFrame *f;
 int bytesperpixel;
-- 
2.1.4
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] vp9: don't retain NULL as segmentation_map

2015-06-17 Thread Ronald S. Bultje
Hi,

On Jun 17, 2015 10:07 AM, "Andreas Cadhalpun" <
andreas.cadhal...@googlemail.com> wrote:
>
> This fixes segmentation faults, which were introduced in commit
> 4ba8f327.
>
> Signed-off-by: Andreas Cadhalpun 
> ---
>  libavcodec/vp9.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
> index 4e2ed53..9d9326c 100644
> --- a/libavcodec/vp9.c
> +++ b/libavcodec/vp9.c
> @@ -3988,7 +3988,8 @@ static int vp9_decode_frame(AVCodecContext *ctx,
void *frame,
>  int size = pkt->size;
>  VP9Context *s = ctx->priv_data;
>  int res, tile_row, tile_col, i, ref, row, col;
> -int retain_segmap_ref = s->segmentation.enabled &&
!s->segmentation.update_map;
> +int retain_segmap_ref = s->segmentation.enabled &&
!s->segmentation.update_map
> +&&
s->frames[REF_FRAME_SEGMAP].segmentation_map;
>  ptrdiff_t yoff, uvoff, ls_y, ls_uv;
>  AVFrame *f;
>  int bytesperpixel;
> --
> 2.1.4

I might take a few days to respond, I'd like to look at this with some more
detailed focus, but feel free to apply before that since it seems to fix a
crash.

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


Re: [FFmpeg-devel] [PATCH] vp9: don't retain NULL as segmentation_map

2015-06-17 Thread Andreas Cadhalpun
Hi Ronald,

On 17.06.2015 20:26, Ronald S. Bultje wrote:
> On Jun 17, 2015 10:07 AM, "Andreas Cadhalpun" <
> andreas.cadhal...@googlemail.com> wrote:
>>
>> This fixes segmentation faults, which were introduced in commit
>> 4ba8f327.
>>
>> Signed-off-by: Andreas Cadhalpun 
>> ---
>>  libavcodec/vp9.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c
>> index 4e2ed53..9d9326c 100644
>> --- a/libavcodec/vp9.c
>> +++ b/libavcodec/vp9.c
>> @@ -3988,7 +3988,8 @@ static int vp9_decode_frame(AVCodecContext *ctx,
> void *frame,
>>  int size = pkt->size;
>>  VP9Context *s = ctx->priv_data;
>>  int res, tile_row, tile_col, i, ref, row, col;
>> -int retain_segmap_ref = s->segmentation.enabled &&
> !s->segmentation.update_map;
>> +int retain_segmap_ref = s->segmentation.enabled &&
> !s->segmentation.update_map
>> +&&
> s->frames[REF_FRAME_SEGMAP].segmentation_map;
>>  ptrdiff_t yoff, uvoff, ls_y, ls_uv;
>>  AVFrame *f;
>>  int bytesperpixel;
>> --
>> 2.1.4
> 
> I might take a few days to respond, I'd like to look at this with some more
> detailed focus, but feel free to apply before that since it seems to fix a
> crash.

OK, I'd wait till tomorrow before applying to give others some time to comment
on it.
I could send you a sample if that'd help you analyzing this in detail.

Best regards,
Andreas

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


[FFmpeg-devel] [PATCH] libvpxenc: support setting colorspace for vp9

2015-06-17 Thread James Zern
the vp9 bitstream supports 8 values:
unknown (default), bt601, bt709, smpte170, smpte240, bt2020, reserved
and sRGB.
---
 doc/encoders.texi  | 12 
 libavcodec/libvpxenc.c | 29 +
 2 files changed, 41 insertions(+)

diff --git a/doc/encoders.texi b/doc/encoders.texi
index 8b0ecb7..8fed2fc 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1550,6 +1550,18 @@ Enable frame parallel decodability features.
 @item aq-mode
 Set adaptive quantization mode (0: off (default), 1: variance 2: complexity, 3:
 cyclic refresh).
+@item colorspace @emph{color-space}
+Set input color space. The VP9 bitstream supports signaling the following
+colorspaces:
+@table @option
+@item @samp{rgb} @emph{sRGB}
+@item @samp{bt709} @emph{bt709}
+@item @samp{unspecified} @emph{unknown}
+@item @samp{bt470bg} @emph{bt601}
+@item @samp{smpte170m} @emph{smpte170}
+@item @samp{smpte240m} @emph{smpte240}
+@item @samp{bt2020_ncl} @emph{bt2020}
+@end table
 @end table
 
 @end table
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 28a0e14..b2deb5d 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -128,6 +128,9 @@ static const char *const ctlidstr[] = {
 [VP9E_SET_TILE_ROWS]   = "VP9E_SET_TILE_ROWS",
 [VP9E_SET_FRAME_PARALLEL_DECODING] = "VP9E_SET_FRAME_PARALLEL_DECODING",
 [VP9E_SET_AQ_MODE] = "VP9E_SET_AQ_MODE",
+#if VPX_ENCODER_ABI_VERSION > 8
+[VP9E_SET_COLOR_SPACE] = "VP9E_SET_COLOR_SPACE",
+#endif
 #endif
 };
 
@@ -349,6 +352,29 @@ static int set_pix_fmt(AVCodecContext *avctx, 
vpx_codec_caps_t codec_caps,
 av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format.\n");
 return AVERROR_INVALIDDATA;
 }
+
+#if VPX_ENCODER_ABI_VERSION > 8
+static void set_colorspace(AVCodecContext *avctx)
+{
+enum vpx_color_space vpx_cs;
+
+switch (avctx->colorspace) {
+case AVCOL_SPC_RGB: vpx_cs = VPX_CS_SRGB;  break;
+case AVCOL_SPC_BT709:   vpx_cs = VPX_CS_BT_709;break;
+case AVCOL_SPC_UNSPECIFIED: vpx_cs = VPX_CS_UNKNOWN;   break;
+case AVCOL_SPC_RESERVED:vpx_cs = VPX_CS_RESERVED;  break;
+case AVCOL_SPC_BT470BG: vpx_cs = VPX_CS_BT_601;break;
+case AVCOL_SPC_SMPTE170M:   vpx_cs = VPX_CS_SMPTE_170; break;
+case AVCOL_SPC_SMPTE240M:   vpx_cs = VPX_CS_SMPTE_240; break;
+case AVCOL_SPC_BT2020_NCL:  vpx_cs = VPX_CS_BT_2020;   break;
+default:
+av_log(avctx, AV_LOG_WARNING, "Unsupported colorspace (%d)\n",
+   avctx->colorspace);
+return;
+}
+codecctl_int(avctx, VP9E_SET_COLOR_SPACE, vpx_cs);
+}
+#endif
 #endif
 
 static av_cold int vpx_init(AVCodecContext *avctx,
@@ -593,6 +619,9 @@ static av_cold int vpx_init(AVCodecContext *avctx,
 codecctl_int(avctx, VP9E_SET_FRAME_PARALLEL_DECODING, 
ctx->frame_parallel);
 if (ctx->aq_mode >= 0)
 codecctl_int(avctx, VP9E_SET_AQ_MODE, ctx->aq_mode);
+#if VPX_ENCODER_ABI_VERSION > 8
+set_colorspace(avctx);
+#endif
 }
 #endif
 
-- 
2.2.0.rc0.207.ga3a616c

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


Re: [FFmpeg-devel] [PATCH] libvpxenc: add color-space option for vp9

2015-06-17 Thread James Zern
On Tue, Jun 16, 2015 at 10:58 PM, James Almer  wrote:
> On 16/06/15 2:43 AM, James Zern wrote:
>> the vp9 bitstream supports 8 values:
>> unknown (default), bt601, bt709, smpte170, smpte240, bt2020, reserved
>> and sRGB.
>> ---
>>  doc/encoders.texi  | 12 
>>  libavcodec/libvpxenc.c | 22 ++
>>  2 files changed, 34 insertions(+)
>>
>> diff --git a/doc/encoders.texi b/doc/encoders.texi
>> index 8b0ecb7..09c90c2 100644
>> --- a/doc/encoders.texi
>> +++ b/doc/encoders.texi
>> @@ -1550,6 +1550,18 @@ Enable frame parallel decodability features.
>>  @item aq-mode
>>  Set adaptive quantization mode (0: off (default), 1: variance 2: 
>> complexity, 3:
>>  cyclic refresh).
>> +@item color-space
>> +Set input color space.
>> +@table @samp
>> +@item unknown
>> +@item bt601
>> +@item bt709
>> +@item smpte170
>> +@item smpte240
>> +@item bt2020
>> +@item reserved
>> +@item sRGB
>> +@end table
>>  @end table
>>
>>  @end table
>> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
>> index 28a0e14..10f16e7 100644
>> --- a/libavcodec/libvpxenc.c
>> +++ b/libavcodec/libvpxenc.c
>> @@ -100,8 +100,12 @@ typedef struct VP8EncoderContext {
>>  int tile_rows;
>>  int frame_parallel;
>>  int aq_mode;
>> +int colorspace;
>>  } VP8Context;
>>
>> +// VP9E_SET_COLOR_SPACE was added just prior to v1.4.0.
>> +#define HAVE_VP9_COLORSPACE_CONTROL (VPX_ENCODER_ABI_VERSION > 8)
>
> Why this custom define? the end result is not shorter and there are other 
> uses of VPX version
> defines on this same file, like VPX_IMAGE_ABI_VERSION.
>

Given the current setup it doesn't do much for clarity; dropped.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] libvpxenc: support setting colorspace for vp9

2015-06-17 Thread Ronald S. Bultje
Hi,

On Jun 17, 2015 12:21 PM, "James Zern"  wrote:
>
> the vp9 bitstream supports 8 values:
> unknown (default), bt601, bt709, smpte170, smpte240, bt2020, reserved
> and sRGB.
> ---
>  doc/encoders.texi  | 12 
>  libavcodec/libvpxenc.c | 29 +
>  2 files changed, 41 insertions(+)
>
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index 8b0ecb7..8fed2fc 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -1550,6 +1550,18 @@ Enable frame parallel decodability features.
>  @item aq-mode
>  Set adaptive quantization mode (0: off (default), 1: variance 2:
complexity, 3:
>  cyclic refresh).
> +@item colorspace @emph{color-space}
> +Set input color space. The VP9 bitstream supports signaling the following
> +colorspaces:
> +@table @option
> +@item @samp{rgb} @emph{sRGB}
> +@item @samp{bt709} @emph{bt709}
> +@item @samp{unspecified} @emph{unknown}
> +@item @samp{bt470bg} @emph{bt601}
> +@item @samp{smpte170m} @emph{smpte170}
> +@item @samp{smpte240m} @emph{smpte240}
> +@item @samp{bt2020_ncl} @emph{bt2020}
> +@end table
>  @end table
>
>  @end table

Do you still need this?

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


[FFmpeg-devel] Ability to skip cursor draw in FIC decoding

2015-06-17 Thread Cal Leeming
It would appear that the FIC codec will skip any errors relating to
cursor draw, but results in a lot of warnings being printed. In some
situations, the user may not even want the cursor to be drawn, and as
such it would be good to offer the ability to disable this via CLI.

It seems the source already has a "skip_cursor" variable, but no
ability to set this from the outside. Sadly my C is not good enough to
contribute a patch, but I can help out with testing if that's of any
use.

Thank you

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


Re: [FFmpeg-devel] [PATCH] avcodec/flacenc: Regression test for ticket #4628

2015-06-17 Thread Michael Niedermayer
On Wed, Jun 17, 2015 at 02:51:16PM +0100, George Boyle wrote:
> Corresponding commit: 2469ed32c81ebf2347e6883091c566724b286167
> ---
>  tests/fate/flac.mak | 4 
>  1 file changed, 4 insertions(+)

applied

thanks

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

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato


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


[FFmpeg-devel] chromium-review spam - my mistake

2015-06-17 Thread Chris Cunningham
Hey Group,

Please ignore a wave of emails that were just sent out asking for code
review at https://chromium-review.googlesource.com/
.

Sorry for the spam!

I'm rolling upstream ffmpeg into chromium and our review tools have changed
recently. Our documented upstream-roll steps apparently need to be updated
to avoid sending out emails for every change in the merge :(

You may see a follow up mail as the reviews are deleted. Sorry for those
too.

Much shame,
Chris
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel