Re: [FFmpeg-devel] [PATCH] Fixed remuxing of HDMV PGS subtitles

2015-04-12 Thread Carl Eugen Hoyos
Philip Langdale  overt.org> writes:

> On Sun, 12 Apr 2015 00:16:45 + (UTC)
> Carl Eugen Hoyos  ag.or.at> wrote:
> 
> > Timothy Gu  gmail.com> writes:
> > 
> > > From: Niklesh Lalwani  gmail.com>
> > > 
> > > Fixes #2622.
> > 
> > Which sample did you use for testing?
> 
> I don't think we have a sample in FATE that has 
> subtitles. I used one of my own bluray discs to verify 
> this fix.

I tested with samples from the following directories:
http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket598/
http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket1722/
http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket3820/

None of them work for me with the patch. It seems I am 
doing something wrong, could you explain how I should 
test?

Thank you, Carl Eugen

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


[FFmpeg-devel] [PATCH 2/3] [GSoC] [AAC] aaccoder: Implement Perceptual Noise Substitution

2015-04-12 Thread Rostislav Pehlivanov
This commit enables the use of the pseudo-codebook NOISE_BT for encoding noise 
values for the twoloop coder. It uses the energy values from the psychoacoustic 
model to determine whether it's acceptible to use noise for encoding and if so, 
determine the energy of the noise. The cost system was modified to accept the 
13th codebook (skipping the nonexistant 12). The system was extended such that 
in the future it should be easy to add support for intensity stereo coding, 
hence the use of arrays for the maps.

The parameters used (such as the factor by which uplims is multiplied when 
comparing and the cost returned by the BT_NOISE case) and the way energy values 
are converted to scalefactor indices have not been extensively tested, so safe 
values which should not break anything were used. They are to be tweaked in the 
future to optimize audio quality if needed.
---
 libavcodec/aaccoder.c | 128 +-
 1 file changed, 86 insertions(+), 42 deletions(-)

diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index 64eee32..f7662fd 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -40,6 +40,9 @@
 #include "aacenc.h"
 #include "aactab.h"
 
+/** Total number of usable codebooks **/
+#define CB_TOT 13
+
 /** bits needed to code codebook run value for long windows */
 static const uint8_t run_value_bits_long[64] = {
  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,
@@ -57,6 +60,10 @@ static const uint8_t * const run_value_bits[2] = {
 run_value_bits_long, run_value_bits_short
 };
 
+/** Map to convert values from BandCodingPath index to a codebook index **/
+static const uint8_t aac_cb_out_map[CB_TOT]  = {0,1,2,3,4,5,6,7,8,9,10,11,13};
+/** Inverse map to convert from codebooks to BandCodingPath indices **/
+static const uint8_t aac_cb_in_map[CB_TOT+1] = 
{0,1,2,3,4,5,6,7,8,9,10,11,0,12};
 
 /**
  * Quantize one coefficient.
@@ -108,7 +115,7 @@ static av_always_inline float 
quantize_and_encode_band_cost_template(
 const float *scaled, int size, int scale_idx,
 int cb, const float lambda, const float uplim,
 int *bits, int BT_ZERO, int BT_UNSIGNED,
-int BT_PAIR, int BT_ESC)
+int BT_PAIR, int BT_ESC, int BT_NOISE)
 {
 const int q_idx = POW_SF2_ZERO - scale_idx + SCALE_ONE_POS - SCALE_DIV_512;
 const float Q   = ff_aac_pow2sf_tab [q_idx];
@@ -119,8 +126,6 @@ static av_always_inline float 
quantize_and_encode_band_cost_template(
 float cost = 0;
 const int dim = BT_PAIR ? 2 : 4;
 int resbits = 0;
-const int range  = aac_cb_range[cb];
-const int maxval = aac_cb_maxval[cb];
 int off;
 
 if (BT_ZERO) {
@@ -130,15 +135,22 @@ static av_always_inline float 
quantize_and_encode_band_cost_template(
 *bits = 0;
 return cost * lambda;
 }
+if (BT_NOISE) {
+for (i = 0; i < size; i++)
+cost += in[i]*in[i];
+if (bits)
+*bits = 0;
+return cost * lambda;
+}
 if (!scaled) {
 abs_pow34_v(s->scoefs, in, size);
 scaled = s->scoefs;
 }
-quantize_bands(s->qcoefs, in, scaled, size, Q34, !BT_UNSIGNED, maxval);
+quantize_bands(s->qcoefs, in, scaled, size, Q34, !BT_UNSIGNED, 
aac_cb_maxval[cb]);
 if (BT_UNSIGNED) {
 off = 0;
 } else {
-off = maxval;
+off = aac_cb_maxval[cb];
 }
 for (i = 0; i < size; i += dim) {
 const float *vec;
@@ -147,7 +159,7 @@ static av_always_inline float 
quantize_and_encode_band_cost_template(
 int curbits;
 float rd = 0.0f;
 for (j = 0; j < dim; j++) {
-curidx *= range;
+curidx *= aac_cb_range[cb];
 curidx += quants[j] + off;
 }
 curbits =  ff_aac_spectral_bits[cb-1][curidx];
@@ -207,8 +219,8 @@ static av_always_inline float 
quantize_and_encode_band_cost_template(
 return cost;
 }
 
-#define QUANTIZE_AND_ENCODE_BAND_COST_FUNC(NAME, BT_ZERO, BT_UNSIGNED, 
BT_PAIR, BT_ESC) \
-static float quantize_and_encode_band_cost_ ## NAME(   
 \
+#define QUANTIZE_AND_ENCODE_BAND_COST_FUNC(NAME, BT_ZERO, BT_UNSIGNED, 
BT_PAIR, BT_ESC, BT_NOISE) \
+static float quantize_and_encode_band_cost_ ## NAME(   
 \
 struct AACEncContext *s,   
 \
 PutBitContext *pb, const float *in,
 \
 const float *scaled, int size, int scale_idx,  
 \
@@ -217,15 +229,16 @@ static float quantize_and_encode_band_cost_ ## NAME(
 return quantize_and_encode_band_cost_template( 
 \
 s, pb, in, scaled, size, scale_idx,
 \
  

[FFmpeg-devel] [PATCH 1/3] [GSoC] [AAC] aacenc: Add support for Perceptual Noise Substitution energy values

2015-04-12 Thread Rostislav Pehlivanov
This commit implements support for writing the noise energy values used in PNS. 
The difference between regular scalefactors and noise energy values is that the 
latter require a small preamble (NOISE_PRE + energy_value_diff) to be written 
as the first noise-containing band. Any following noise energy values use the 
previous one to base their "diff" on. Ordinary scalefactors remain unchanged 
other than that they ignore the noise values.

This commit should not change anything by itself, the following commits will 
bring it in use.
---
 libavcodec/aac.h|  3 +++
 libavcodec/aacenc.c | 17 ++---
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/libavcodec/aac.h b/libavcodec/aac.h
index b25b40c..2701386 100644
--- a/libavcodec/aac.h
+++ b/libavcodec/aac.h
@@ -141,6 +141,9 @@ typedef struct PredictorState {
 #define SCALE_MAX_DIFF   60///< maximum scalefactor difference allowed by 
standard
 #define SCALE_DIFF_ZERO  60///< codebook index corresponding to zero 
scalefactor indices difference
 
+#define NOISE_PRE   256///< preamble for NOISE_BT, put in bitstream 
with the first noise band
+#define NOISE_PRE_BITS9///< length of preamble
+
 /**
  * Long Term Prediction
  */
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 7015a27..5288afb 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -388,15 +388,26 @@ static void encode_band_info(AACEncContext *s, 
SingleChannelElement *sce)
 static void encode_scale_factors(AVCodecContext *avctx, AACEncContext *s,
  SingleChannelElement *sce)
 {
-int off = sce->sf_idx[0], diff;
+int diff, off_sf = sce->sf_idx[0], off_pns = sce->sf_idx[0];
+int noise_flag = 1;
 int i, w;
 
 for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
 for (i = 0; i < sce->ics.max_sfb; i++) {
 if (!sce->zeroes[w*16 + i]) {
-diff = sce->sf_idx[w*16 + i] - off + SCALE_DIFF_ZERO;
+if (sce->band_type[w*16 + i] == NOISE_BT) {
+diff = sce->sf_idx[w*16 + i] - off_pns;
+off_pns = sce->sf_idx[w*16 + i];
+if (noise_flag-- > 0) {
+put_bits(&s->pb, NOISE_PRE_BITS, diff + NOISE_PRE);
+continue;
+}
+} else {
+diff = sce->sf_idx[w*16 + i] - off_sf;
+off_sf = sce->sf_idx[w*16 + i];
+}
+diff += SCALE_DIFF_ZERO;
 av_assert0(diff >= 0 && diff <= 120);
-off = sce->sf_idx[w*16 + i];
 put_bits(&s->pb, ff_aac_scalefactor_bits[diff], 
ff_aac_scalefactor_code[diff]);
 }
 }
-- 
2.1.4

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


[FFmpeg-devel] [PATCH 3/3] [GSoC] [AAC] aacdec: Use defined macros for constants

2015-04-12 Thread Rostislav Pehlivanov
This commit changes the decoder to use the macro definitions for scalefactors 
and noise energy values reading. This was done to reduce confusion when looking 
at the encoder and decoder and possibly as a first step in unifying some of the 
code in the two files.
---
 libavcodec/aacdec.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
index 5a0c05a..3ed66c3 100644
--- a/libavcodec/aacdec.c
+++ b/libavcodec/aacdec.c
@@ -1406,7 +1406,7 @@ static int decode_scalefactors(AACContext *ac, float 
sf[120], GetBitContext *gb,
 } else if ((band_type[idx] == INTENSITY_BT) ||
(band_type[idx] == INTENSITY_BT2)) {
 for (; i < run_end; i++, idx++) {
-offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 
60;
+offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 
SCALE_DIFF_ZERO;
 clipped_offset = av_clip(offset[2], -155, 100);
 if (offset[2] != clipped_offset) {
 avpriv_request_sample(ac->avctx,
@@ -1419,9 +1419,9 @@ static int decode_scalefactors(AACContext *ac, float 
sf[120], GetBitContext *gb,
 } else if (band_type[idx] == NOISE_BT) {
 for (; i < run_end; i++, idx++) {
 if (noise_flag-- > 0)
-offset[1] += get_bits(gb, 9) - 256;
+offset[1] += get_bits(gb, NOISE_PRE_BITS) - NOISE_PRE;
 else
-offset[1] += get_vlc2(gb, vlc_scalefactors.table, 7, 
3) - 60;
+offset[1] += get_vlc2(gb, vlc_scalefactors.table, 7, 
3) - SCALE_DIFF_ZERO;
 clipped_offset = av_clip(offset[1], -100, 155);
 if (offset[1] != clipped_offset) {
 avpriv_request_sample(ac->avctx,
@@ -1433,7 +1433,7 @@ static int decode_scalefactors(AACContext *ac, float 
sf[120], GetBitContext *gb,
 }
 } else {
 for (; i < run_end; i++, idx++) {
-offset[0] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 
60;
+offset[0] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) - 
SCALE_DIFF_ZERO;
 if (offset[0] > 255U) {
 av_log(ac->avctx, AV_LOG_ERROR,
"Scalefactor (%d) out of range.\n", offset[0]);
-- 
2.1.4

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


[FFmpeg-devel] [PATCH] tests/tiny_psnr: Make the search range extend both sides from the specified shift value

2015-04-12 Thread Michael Niedermayer
This is what one would expect from the help text

Signed-off-by: Michael Niedermayer 
---
 tests/tiny_psnr.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/tests/tiny_psnr.c b/tests/tiny_psnr.c
index b35ed81..e09f394 100644
--- a/tests/tiny_psnr.c
+++ b/tests/tiny_psnr.c
@@ -273,6 +273,9 @@ int main(int argc, char *argv[])
 int max_psnr   = -1;
 int max_psnr_shift = 0;
 
+if (shift_last > shift_first)
+shift_first -= shift_last - shift_first;
+
 if (argc > 3) {
 if (!strcmp(argv[3], "u8")) {
 len = 1;
-- 
1.7.9.5

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


Re: [FFmpeg-devel] [RFC][PATCH] avformat/flvdec: avoid reseting eof_reached to 0 silently

2015-04-12 Thread Michael Niedermayer
On Sun, Apr 12, 2015 at 12:00:18PM +0800, Zhang Rui wrote:
> 2015-04-10 22:04 GMT+08:00 wm4 :
> > On Fri, 10 Apr 2015 21:17:42 +0800
> > Zhang Rui  wrote:
> >>
> >> This kind of error handling need some more work in aviobuf.c,
> >> and more advises from ffmpeg developers.
> >> And i prefer this way than the patch I posted.
> >
> > stdio.h does it this way: FILE has an error flag that is set when
> > something goes wrong.
> 
> AVIOContext has an error field, too. But I don't think it's enough
> for EAGAIN situation without some convention.
> At least, ffplay doesn't show that.
> 
> >> > Also, why doesn't avio_skip() return an error if the skip count is not
> >> > 0 and the stream has reached EOF?
> >>
> >> The eof handling is quite confusing in ffplay for me. AVERROR_EOF is
> >> clear enough.
> >
> > Well, I have no idea what avio_skip() even returns... it just calls
> > avio_seek(), which is a goddamn fucked up mess thanks to years of
> > people adding hacks.
> 
> Is there any correct direction to fix it?
> 
> > ffplay probably does it wrong. Wouldn't be surprising. It checks
> > avio_feof() after a av_read_frame() call, which doesn't look correct.
> > File EOF has absolutely nothing to do with whether a demuxer still has
> > data.
> >
> > On a side note, I'm not sure whether av_read_frame() returning
> > AVERROR_EOF is an error at all, or just signals that the end of the
> > file was reached. The doxygen on this function isn't helpful either.
> 
> Is there any ideas, or any helpful keywords or threads in mail list archive?

a simple error_count field could be added that way one could easily
check if the count increased over any series of function call(s)

it also could be presented at verbose level by the user application,
showing how many io errors where encountered which where not fatal

[...]

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


[FFmpeg-devel] [PATCH] fate: Include branch information in the payload header

2015-04-12 Thread Timothy Gu
The server is properly equiped not to choke on that now.
---
 tests/fate.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tests/fate.sh b/tests/fate.sh
index 81224b6..6ce8c48 100755
--- a/tests/fate.sh
+++ b/tests/fate.sh
@@ -84,8 +84,7 @@ clean(){
 
 report(){
 date=$(date -u +%Y%m%d%H%M%S)
-echo "fate:0:${date}:${slot}:${version}:$1:$2:${comment}" >report
-#echo "fate:1:${date}:${slot}:${version}:$1:$2:${branch}:${comment}" 
>report
+echo "fate:1:${date}:${slot}:${version}:$1:$2:${branch}:${comment}" >report
 cat ${build}/config.fate >>report
 cat ${build}/tests/data/fate/*.rep >>report || for i in 
${build}/tests/data/fate/*.rep ; do cat "$i" >>report ; done
 test -n "$fate_recv" && $tar report *.log | gzip | $fate_recv
-- 
1.9.1

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


[FFmpeg-devel] [PATCH] avformat/rtsp: Fix dereference after null check

2015-04-12 Thread Himangi Saraogi
---
This fixes CID 732219.

 libavformat/rtsp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 42dbe96..c186b99 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -802,7 +802,7 @@ int ff_rtsp_open_transport_ctx(AVFormatContext *s, 
RTSPStream *rtsp_st)
 if (!st)
 s->ctx_flags |= AVFMTCTX_NOHEADER;
 
-if (CONFIG_RTSP_MUXER && s->oformat) {
+if (CONFIG_RTSP_MUXER && s->oformat && st) {
 int ret = ff_rtp_chain_mux_open((AVFormatContext 
**)&rtsp_st->transport_priv,
 s, st, rtsp_st->rtp_handle,
 RTSP_TCP_MAX_PACKET_SIZE,
@@ -814,7 +814,7 @@ int ff_rtsp_open_transport_ctx(AVFormatContext *s, 
RTSPStream *rtsp_st)
 st->time_base = 
((AVFormatContext*)rtsp_st->transport_priv)->streams[0]->time_base;
 } else if (rt->transport == RTSP_TRANSPORT_RAW) {
 return 0; // Don't need to open any parser here
-} else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RDT)
+} else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RDT && st)
 rtsp_st->transport_priv = ff_rdt_parse_open(s, st->index,
 rtsp_st->dynamic_protocol_context,
 rtsp_st->dynamic_handler);
-- 
1.9.1

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


Re: [FFmpeg-devel] [PATCH] avformat/rtsp: Fix dereference after null check

2015-04-12 Thread Thomas Volkert


Am 12.04.2015 um 21:35 schrieb Himangi Saraogi:

---
This fixes CID 732219.

  libavformat/rtsp.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 42dbe96..c186b99 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -802,7 +802,7 @@ int ff_rtsp_open_transport_ctx(AVFormatContext *s, 
RTSPStream *rtsp_st)
  if (!st)
  s->ctx_flags |= AVFMTCTX_NOHEADER;
  
-if (CONFIG_RTSP_MUXER && s->oformat) {

+if (CONFIG_RTSP_MUXER && s->oformat && st) {
  int ret = ff_rtp_chain_mux_open((AVFormatContext 
**)&rtsp_st->transport_priv,
  s, st, rtsp_st->rtp_handle,
  RTSP_TCP_MAX_PACKET_SIZE,
@@ -814,7 +814,7 @@ int ff_rtsp_open_transport_ctx(AVFormatContext *s, 
RTSPStream *rtsp_st)
  st->time_base = 
((AVFormatContext*)rtsp_st->transport_priv)->streams[0]->time_base;
  } else if (rt->transport == RTSP_TRANSPORT_RAW) {
  return 0; // Don't need to open any parser here
-} else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RDT)
+} else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RDT && st)
  rtsp_st->transport_priv = ff_rdt_parse_open(s, st->index,
  rtsp_st->dynamic_protocol_context,
  rtsp_st->dynamic_handler);

LGTM, this addresses the problem which was resported by coverity scan.

But I think this is only a part of the complete solution. If "st" is 
NULL, it would also crash inside "ff_rtp_parse_open()" (espec., if H.264 
or G.722 are used).
Could you also fix this in a separate patch? Maybe you can also 
rearrange the "if" checks/branches and remove some duplicated conditions 
in the code.


Best regards,
Thomas.



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


Re: [FFmpeg-devel] [PATCH] fate: Include branch information in the payload header

2015-04-12 Thread Timothy Gu
On Sun, Apr 12, 2015 at 8:28 AM Timothy Gu  wrote:

> The server is properly equiped not to choke on that now.
> ---
>  tests/fate.sh | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
This was applied by Michael earlier today.

[...]

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


[FFmpeg-devel] [PATCH] Check for not synchronized packets (very small feed file, very slow client connection)

2015-04-12 Thread Milan Matejec
Hi,

attached is patch for encoding/decoding .ffm format. When you set a maximum
size of feed file to too small number (I tried 20k) and try to connect to
ffserver from very slow connection (simulated by reading 8k chunks and then
wait 3 seconds) .ffm decoder will after a few seconds (10 maybe more ...)
stuck in endless "READ_HEADER" state because it got unreal size of .ffm
data packet (it's 24bits so take some random number - usually something
about 10MB) leading to immediately return after *ffm_is_avail_data()*. This
patch adds a packet header with signature so after loading header it tries
to check if signature is there. If not then it logs an error and tries to
reset a packet and read header again. It's not a best solution but better
than end up in an endless loop ...

Thanks.

Regards.

Milan Matejec


0001-Check-for-not-synchronized-packets-very-small-feed-f.b64
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/rtsp: Fix dereference after null check

2015-04-12 Thread Michael Niedermayer
On Sun, Apr 12, 2015 at 09:57:19PM +0200, Thomas Volkert wrote:
> 
> Am 12.04.2015 um 21:35 schrieb Himangi Saraogi:
> >---
> >This fixes CID 732219.
> >
> >  libavformat/rtsp.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> >diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
> >index 42dbe96..c186b99 100644
> >--- a/libavformat/rtsp.c
> >+++ b/libavformat/rtsp.c
> >@@ -802,7 +802,7 @@ int ff_rtsp_open_transport_ctx(AVFormatContext *s, 
> >RTSPStream *rtsp_st)
> >  if (!st)
> >  s->ctx_flags |= AVFMTCTX_NOHEADER;
> >-if (CONFIG_RTSP_MUXER && s->oformat) {
> >+if (CONFIG_RTSP_MUXER && s->oformat && st) {
> >  int ret = ff_rtp_chain_mux_open((AVFormatContext 
> > **)&rtsp_st->transport_priv,
> >  s, st, rtsp_st->rtp_handle,
> >  RTSP_TCP_MAX_PACKET_SIZE,
> >@@ -814,7 +814,7 @@ int ff_rtsp_open_transport_ctx(AVFormatContext *s, 
> >RTSPStream *rtsp_st)
> >  st->time_base = 
> > ((AVFormatContext*)rtsp_st->transport_priv)->streams[0]->time_base;
> >  } else if (rt->transport == RTSP_TRANSPORT_RAW) {
> >  return 0; // Don't need to open any parser here
> >-} else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RDT)
> >+} else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RDT && st)
> >  rtsp_st->transport_priv = ff_rdt_parse_open(s, st->index,
> >  
> > rtsp_st->dynamic_protocol_context,
> >  rtsp_st->dynamic_handler);
> LGTM, this addresses the problem which was resported by coverity scan.

applied

thanks

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

You can kill me, but you cannot change the truth.


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/3] [GSoC] [AAC] aacenc: Add support for Perceptual Noise Substitution energy values

2015-04-12 Thread Michael Niedermayer
On Sun, Apr 12, 2015 at 05:50:34AM +0100, Rostislav Pehlivanov wrote:
> This commit implements support for writing the noise energy values used in 
> PNS. The difference between regular scalefactors and noise energy values is 
> that the latter require a small preamble (NOISE_PRE + energy_value_diff) to 
> be written as the first noise-containing band. Any following noise energy 
> values use the previous one to base their "diff" on. Ordinary scalefactors 
> remain unchanged other than that they ignore the noise values.
> 
> This commit should not change anything by itself, the following commits will 
> bring it in use.
> ---
>  libavcodec/aac.h|  3 +++
>  libavcodec/aacenc.c | 17 ++---
>  2 files changed, 17 insertions(+), 3 deletions(-)

have you checked that the values which are stored are equal to
what the decoder reads out again ?

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

Awnsering whenever a program halts or runs forever is
On a turing machine, in general impossible (turings halting problem).
On any real computer, always possible as a real computer has a finite number
of states N, and will either halt in less than N cycles or never halt.


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


[FFmpeg-devel] [PATCH] tests/fate: added mxf opatom audio regression tests

2015-04-12 Thread Mark Reid
---
 tests/fate/avformat.mak  |  1 +
 tests/fate/seek.mak  |  2 ++
 tests/lavf-regression.sh |  4 +++
 tests/ref/lavf/mxf_opatom_audio  |  3 ++
 tests/ref/seek/lavf-mxf_opatom_audio | 53 
 5 files changed, 63 insertions(+)
 create mode 100644 tests/ref/lavf/mxf_opatom_audio
 create mode 100644 tests/ref/seek/lavf-mxf_opatom_audio

diff --git a/tests/fate/avformat.mak b/tests/fate/avformat.mak
index 4e7a440..1d13434 100644
--- a/tests/fate/avformat.mak
+++ b/tests/fate/avformat.mak
@@ -23,6 +23,7 @@ FATE_LAVF-$(call ENCDEC,  PCM_MULAW, PCM_MULAW)   
   += mulaw
 FATE_LAVF-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, MXF)+= mxf
 FATE_LAVF-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, MXF_D10 MXF)+= mxf_d10
 FATE_LAVF-$(call ENCDEC2, DNXHD,  PCM_S16LE, MXF_OPATOM MXF) += 
mxf_opatom
+FATE_LAVF-$(call ENCDEC2, DNXHD,  PCM_S16LE, MXF_OPATOM MXF) += 
mxf_opatom_audio
 FATE_LAVF-$(call ENCDEC2, MPEG4,  MP2,   NUT)+= nut
 FATE_LAVF-$(call ENCDEC,  FLAC,  OGG)+= ogg
 FATE_LAVF-$(call ENCDEC,  PAM,   IMAGE2) += pam
diff --git a/tests/fate/seek.mak b/tests/fate/seek.mak
index 4f4ccff..3be04ca 100644
--- a/tests/fate/seek.mak
+++ b/tests/fate/seek.mak
@@ -179,6 +179,7 @@ FATE_SEEK_LAVF-$(call ENCDEC,  PCM_MULAW, 
PCM_MULAW)   += mulaw
 FATE_SEEK_LAVF-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, MXF) += mxf
 FATE_SEEK_LAVF-$(call ENCDEC2, MPEG2VIDEO, PCM_S16LE, MXF_D10 MXF) += mxf_d10
 FATE_SEEK_LAVF-$(call ENCDEC2, DNXHD,  PCM_S16LE, MXF_OPATOM MXF) += 
mxf_opatom
+FATE_SEEK_LAVF-$(call ENCDEC2, DNXHD,  PCM_S16LE, MXF_OPATOM MXF) += 
mxf_opatom_audio
 FATE_SEEK_LAVF-$(call ENCDEC2, MPEG4,  MP2,   NUT) += nut
 FATE_SEEK_LAVF-$(call ENCDEC,  FLAC,  OGG) += ogg
 FATE_SEEK_LAVF-$(call ENCDEC,  PBM,   IMAGE2PIPE)  += pbmpipe
@@ -218,6 +219,7 @@ fate-seek-lavf-mulaw:SRC = lavf/lavf.ul
 fate-seek-lavf-mxf:  SRC = lavf/lavf.mxf
 fate-seek-lavf-mxf_d10:  SRC = lavf/lavf.mxf_d10
 fate-seek-lavf-mxf_opatom: SRC = lavf/lavf.mxf_opatom
+fate-seek-lavf-mxf_opatom_audio: SRC = lavf/lavf.mxf_opatom_audio
 fate-seek-lavf-nut:  SRC = lavf/lavf.nut
 fate-seek-lavf-ogg:  SRC = lavf/lavf.ogg
 fate-seek-lavf-pbmpipe:  SRC = lavf/pbmpipe.pbm
diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh
index c5cb597..a37f714 100755
--- a/tests/lavf-regression.sh
+++ b/tests/lavf-regression.sh
@@ -94,6 +94,10 @@ if [ -n "$do_mxf_opatom" ]; then
 do_lavf mxf_opatom "" "-s 1920x1080 -vcodec dnxhd -pix_fmt yuv422p -vb 36M -f 
mxf_opatom -map 0"
 fi
 
+if [ -n "$do_mxf_opatom_audio" ]; then
+do_lavf mxf_opatom_audio "-ar 48000 -ac 1" "-f mxf_opatom -mxf_audio_edit_rate 
25 -map 1"
+fi
+
 if [ -n "$do_ts" ] ; then
 do_lavf ts "" "-ab 64k -mpegts_transport_stream_id 42 -ar 44100 -threads 1"
 fi
diff --git a/tests/ref/lavf/mxf_opatom_audio b/tests/ref/lavf/mxf_opatom_audio
new file mode 100644
index 000..45010d0
--- /dev/null
+++ b/tests/ref/lavf/mxf_opatom_audio
@@ -0,0 +1,3 @@
+77bd25ba3213ffbdc4d4c9052914510f *./tests/data/lavf/lavf.mxf_opatom_audio
+102457 ./tests/data/lavf/lavf.mxf_opatom_audio
+./tests/data/lavf/lavf.mxf_opatom_audio CRC=0xd155c6ff
diff --git a/tests/ref/seek/lavf-mxf_opatom_audio 
b/tests/ref/seek/lavf-mxf_opatom_audio
new file mode 100644
index 000..12d4644
--- /dev/null
+++ b/tests/ref/seek/lavf-mxf_opatom_audio
@@ -0,0 +1,53 @@
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:   5145 size:  
3840
+ret: 0 st:-1 flags:0  ts:-1.00
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:   5145 size:  
3840
+ret: 0 st:-1 flags:1  ts: 1.894167
+ret: 0 st: 0 flags:1 dts: 0.79 pts: 0.79 pos: 101143 size: 
2
+ret: 0 st: 0 flags:0  ts: 0.788333
+ret: 0 st: 0 flags:1 dts: 0.788333 pts: 0.788333 pos:  80825 size:  
3840
+ret: 0 st: 0 flags:1  ts:-0.317500
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:   5145 size:  
3840
+ret: 0 st:-1 flags:0  ts: 2.576668
+ret: 0 st: 0 flags:1 dts: 0.79 pts: 0.79 pos: 101143 size: 
2
+ret: 0 st:-1 flags:1  ts: 1.470835
+ret: 0 st: 0 flags:1 dts: 0.79 pts: 0.79 pos: 101143 size: 
2
+ret: 0 st: 0 flags:0  ts: 0.365000
+ret: 0 st: 0 flags:1 dts: 0.365000 pts: 0.365000 pos:  40185 size:  
3840
+ret: 0 st: 0 flags:1  ts:-0.740833
+ret: 0 st: 0 flags:1 dts: 0.00 pts: 0.00 pos:   5145 size:  
3840
+ret: 0 st:-1 flags:0  ts: 2.153336
+ret: 0 st: 0 flags:1 dts: 0.79 pts: 0.79 pos: 101143 size: 
2
+ret: 0 st:-1 flags:1  ts: 1.047503
+ret: 0 st: 0 flags:1 dts: 0.79 pts: 0.79 pos: 101143 size: 
2
+ret: 0 st: 0 flags:0  ts:-0.058333
+ret: 0 st

Re: [FFmpeg-devel] [PATCH] Fixed remuxing of HDMV PGS subtitles

2015-04-12 Thread Philip Langdale
On Sun, 12 Apr 2015 08:13:39 + (UTC)
Carl Eugen Hoyos  wrote:
> 
> I tested with samples from the following directories:
> http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket598/
> http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket1722/
> http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket3820/
> 
> None of them work for me with the patch. It seems I am 
> doing something wrong, could you explain how I should 
> test?

OK.

I used:

http://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket598/2_nosubs_detected.m2ts

Then I did:

ffmpeg -i 2_nosubs_detected.m2ts -map 0 -c:v copy -c:a copy -c:s \
copy remux.m2ts

and I played remux.m2ts successfully in mplayer with working subtitles.

Now, the ffmpeg probe output will not look the same as the original
file. You'll see:

Stream #0:7[0x107], 0, 1/9: Unknown: none ([144][0][0][0] / 0x0090)
Stream #0:8[0x108], 0, 1/9: Unknown: none ([144][0][0][0] / 0x0090)
Stream #0:9[0x109], 0, 1/9: Unknown: none ([144][0][0][0] / 0x0090)
Stream #0:10[0x10a], 0, 1/9: Unknown: none ([144][0][0][0] / 0x0090)
Stream #0:11[0x10b], 0, 1/9: Unknown: none ([144][0][0][0] / 0x0090)

This change makes sure the 0x0090 type ID at the end is carried over
during the copy operation. There is a bunch of separate metadata which
needs to be copied for the 'Unknown' to be replaced by the right info
for the pgs subtitles, but that's a separate lower level problem in the
muxer - it doesn't appear to copy that info correctly in a whole class
of types, where pgs is just one example.

It does have implications. You can remux from a proper bluray m2ts and
get a working file, but if you try and remux that output into a new
file, everything fails because ffmpeg can't identify the subtitle
tracks any more.

So, this change is not a complete fix, but it's one of the necessary
steps.

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


Re: [FFmpeg-devel] [PATCH] Fixed remuxing of HDMV PGS subtitles

2015-04-12 Thread Timothy Gu
On Sun, Apr 12, 2015 at 4:41 PM Philip Langdale  wrote:
>
> So, this change is not a complete fix, but it's one of the necessary
> steps.
>

That was what I suspected. I simply forwarded the patch from GitHub.

Also I didn't notice the patch had some trailing spaces…

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


Re: [FFmpeg-devel] [PATCH] Fixed remuxing of HDMV PGS subtitles

2015-04-12 Thread Philip Langdale
On Sun, 12 Apr 2015 23:53:21 +
Timothy Gu  wrote:

> On Sun, Apr 12, 2015 at 4:41 PM Philip Langdale 
> wrote:
> >
> > So, this change is not a complete fix, but it's one of the necessary
> > steps.
> >
> 
> That was what I suspected. I simply forwarded the patch from GitHub.
> 
> Also I didn't notice the patch had some trailing spaces…

I had original asked Niklesh to fix 2262 as his GSoC qualification task
and this was the first thing he did. Then I switched him to the movtext
task after Wesley dropped out.

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


Re: [FFmpeg-devel] [PATCH 2/3] [GSoC] [AAC] aaccoder: Implement Perceptual Noise Substitution

2015-04-12 Thread Rostislav Pehlivanov
Here's an objective comparison of the difference the patch makes:

Original spectrum:
https://0x0.st/T7.png

Encoded without the patchset:
https://0x0.st/Th.png

Encoded with the patchset:
https://0x0.st/TF.png

Difference:
https://0x0.st/TR.png 
Made by: "$ composite Encoded_clean.png Encoded_noise.png -compose
difference Difference.png"

On 12 April 2015 at 05:50, Rostislav Pehlivanov  wrote:

> This commit enables the use of the pseudo-codebook NOISE_BT for encoding
> noise values for the twoloop coder. It uses the energy values from the
> psychoacoustic model to determine whether it's acceptible to use noise for
> encoding and if so, determine the energy of the noise. The cost system was
> modified to accept the 13th codebook (skipping the nonexistant 12). The
> system was extended such that in the future it should be easy to add
> support for intensity stereo coding, hence the use of arrays for the maps.
>
> The parameters used (such as the factor by which uplims is multiplied when
> comparing and the cost returned by the BT_NOISE case) and the way energy
> values are converted to scalefactor indices have not been extensively
> tested, so safe values which should not break anything were used. They are
> to be tweaked in the future to optimize audio quality if needed.
> ---
>  libavcodec/aaccoder.c | 128
> +-
>  1 file changed, 86 insertions(+), 42 deletions(-)
>
> diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
> index 64eee32..f7662fd 100644
> --- a/libavcodec/aaccoder.c
> +++ b/libavcodec/aaccoder.c
> @@ -40,6 +40,9 @@
>  #include "aacenc.h"
>  #include "aactab.h"
>
> +/** Total number of usable codebooks **/
> +#define CB_TOT 13
> +
>  /** bits needed to code codebook run value for long windows */
>  static const uint8_t run_value_bits_long[64] = {
>   5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,
> @@ -57,6 +60,10 @@ static const uint8_t * const run_value_bits[2] = {
>  run_value_bits_long, run_value_bits_short
>  };
>
> +/** Map to convert values from BandCodingPath index to a codebook index
> **/
> +static const uint8_t aac_cb_out_map[CB_TOT]  =
> {0,1,2,3,4,5,6,7,8,9,10,11,13};
> +/** Inverse map to convert from codebooks to BandCodingPath indices **/
> +static const uint8_t aac_cb_in_map[CB_TOT+1] =
> {0,1,2,3,4,5,6,7,8,9,10,11,0,12};
>
>  /**
>   * Quantize one coefficient.
> @@ -108,7 +115,7 @@ static av_always_inline float
> quantize_and_encode_band_cost_template(
>  const float *scaled, int size, int
> scale_idx,
>  int cb, const float lambda, const float
> uplim,
>  int *bits, int BT_ZERO, int BT_UNSIGNED,
> -int BT_PAIR, int BT_ESC)
> +int BT_PAIR, int BT_ESC, int BT_NOISE)
>  {
>  const int q_idx = POW_SF2_ZERO - scale_idx + SCALE_ONE_POS -
> SCALE_DIV_512;
>  const float Q   = ff_aac_pow2sf_tab [q_idx];
> @@ -119,8 +126,6 @@ static av_always_inline float
> quantize_and_encode_band_cost_template(
>  float cost = 0;
>  const int dim = BT_PAIR ? 2 : 4;
>  int resbits = 0;
> -const int range  = aac_cb_range[cb];
> -const int maxval = aac_cb_maxval[cb];
>  int off;
>
>  if (BT_ZERO) {
> @@ -130,15 +135,22 @@ static av_always_inline float
> quantize_and_encode_band_cost_template(
>  *bits = 0;
>  return cost * lambda;
>  }
> +if (BT_NOISE) {
> +for (i = 0; i < size; i++)
> +cost += in[i]*in[i];
> +if (bits)
> +*bits = 0;
> +return cost * lambda;
> +}
>  if (!scaled) {
>  abs_pow34_v(s->scoefs, in, size);
>  scaled = s->scoefs;
>  }
> -quantize_bands(s->qcoefs, in, scaled, size, Q34, !BT_UNSIGNED,
> maxval);
> +quantize_bands(s->qcoefs, in, scaled, size, Q34, !BT_UNSIGNED,
> aac_cb_maxval[cb]);
>  if (BT_UNSIGNED) {
>  off = 0;
>  } else {
> -off = maxval;
> +off = aac_cb_maxval[cb];
>  }
>  for (i = 0; i < size; i += dim) {
>  const float *vec;
> @@ -147,7 +159,7 @@ static av_always_inline float
> quantize_and_encode_band_cost_template(
>  int curbits;
>  float rd = 0.0f;
>  for (j = 0; j < dim; j++) {
> -curidx *= range;
> +curidx *= aac_cb_range[cb];
>  curidx += quants[j] + off;
>  }
>  curbits =  ff_aac_spectral_bits[cb-1][curidx];
> @@ -207,8 +219,8 @@ static av_always_inline float
> quantize_and_encode_band_cost_template(
>  return cost;
>  }
>
> -#define QUANTIZE_AND_ENCODE_BAND_COST_FUNC(NAME, BT_ZERO, BT_UNSIGNED,
> BT_PAIR, BT_ESC) \
> -static float quantize_and_encode_band_cost_ ## NAME(
>   \
> +#define QUANTIZE_AND_ENCODE_BAND_COST_FUNC(NAME, BT_ZERO, BT_UNSIGNED,
> BT_PAIR, BT_ESC, BT_NOISE) \
> +static float quantize_and_encode_

Re: [FFmpeg-devel] [PATCH] tests/fate: added mxf opatom audio regression tests

2015-04-12 Thread Michael Niedermayer
On Sun, Apr 12, 2015 at 04:39:01PM -0700, Mark Reid wrote:
> ---
>  tests/fate/avformat.mak  |  1 +
>  tests/fate/seek.mak  |  2 ++
>  tests/lavf-regression.sh |  4 +++
>  tests/ref/lavf/mxf_opatom_audio  |  3 ++
>  tests/ref/seek/lavf-mxf_opatom_audio | 53 
> 
>  5 files changed, 63 insertions(+)
>  create mode 100644 tests/ref/lavf/mxf_opatom_audio
>  create mode 100644 tests/ref/seek/lavf-mxf_opatom_audio

applied

thanks

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

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


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


Re: [FFmpeg-devel] [PATCH 1/3] [GSoC] [AAC] aacenc: Add support for Perceptual Noise Substitution energy values

2015-04-12 Thread Michael Niedermayer
On Sun, Apr 12, 2015 at 05:50:34AM +0100, Rostislav Pehlivanov wrote:
> This commit implements support for writing the noise energy values used in 
> PNS. The difference between regular scalefactors and noise energy values is 
> that the latter require a small preamble (NOISE_PRE + energy_value_diff) to 
> be written as the first noise-containing band. Any following noise energy 
> values use the previous one to base their "diff" on. Ordinary scalefactors 
> remain unchanged other than that they ignore the noise values.
> 
> This commit should not change anything by itself, the following commits will 
> bring it in use.
> ---
>  libavcodec/aac.h|  3 +++
>  libavcodec/aacenc.c | 17 ++---
>  2 files changed, 17 insertions(+), 3 deletions(-)

applied

thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- 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 1/3] [GSoC] [AAC] aacenc: Add support for Perceptual Noise Substitution energy values

2015-04-12 Thread Claudio Freire
On Sun, Apr 12, 2015 at 1:50 AM, Rostislav Pehlivanov
 wrote:
> +int diff, off_sf = sce->sf_idx[0], off_pns = sce->sf_idx[0];


If you take a look at the decoder, off_pns has to be initialized as off_pns - 90
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/3] [GSoC] [AAC] aacenc: Add support for Perceptual Noise Substitution energy values

2015-04-12 Thread Claudio Freire
On Sun, Apr 12, 2015 at 11:49 PM, Claudio Freire  wrote:
> On Sun, Apr 12, 2015 at 1:50 AM, Rostislav Pehlivanov
>  wrote:
>> +int diff, off_sf = sce->sf_idx[0], off_pns = sce->sf_idx[0];
>
>
> If you take a look at the decoder, off_pns has to be initialized as off_pns - 
> 90


Sorry, hit send prematurely by mistake.

Adding -90 there will probably invalidate parts of the following
patches that deal with that offset (like that -70 at the second
patch), but it's worth fixing.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 2/3] [GSoC] [AAC] aaccoder: Implement Perceptual Noise Substitution

2015-04-12 Thread Claudio Freire
On Sun, Apr 12, 2015 at 1:50 AM, Rostislav Pehlivanov
 wrote:
> @@ -245,6 +258,8 @@ static float (*const quantize_and_encode_band_cost_arr[])(
>  quantize_and_encode_band_cost_UPAIR,
>  quantize_and_encode_band_cost_UPAIR,
>  quantize_and_encode_band_cost_ESC,
> +NULL,
> +quantize_and_encode_band_cost_NOISE,
>  };


Make a function that has the same signature as the
quantize_and_encode_band_cost_X functions here, but whose only
contents are an assert(false), and add it instead of the NULL.

> +energies[w*16+g] = log2f(2*(energy*energy));
> +energy_avg = (energies[w*16+g] + energy_avg)/2;

Not sure I follow the math there. Why the average?

It seems to me that you're trying to compensate for the encoding error
on the first patch (failing to initialize off_pns with -90).

> -if (sce->sf_idx[i] < 218 - qstep)
> +if (sce->sf_idx[i] < 218 - qstep && sce->band_type[i] < 
> NOISE_BT)
>  sce->sf_idx[i] += qstep;
>  } else {
>  for (i = 0; i < 128; i++)
> -if (sce->sf_idx[i] > 60 - qstep)
> +if (sce->sf_idx[i] > 60 - qstep && sce->band_type[i] < 
> NOISE_BT)
>  sce->sf_idx[i] -= qstep;

Careful here. You're using band_type[i], but not all of them will have
been initialize to NOISE_BT (ie: consider window groups, only w*16+g
is intialized, with w the first window in the group, the rest are not
initialized.

Probably the easiest solution is to initialize them all to NOISE_BT.

> +if (freq > 4000.0f && energy <= uplim * 1.52f) {

4000.0f should probably be a constant somewhere.

> +float freq = 
> (w*16+g)*(avctx->sample_rate/(1024/sce->ics.num_windows)/2);

This is wrong. Should be

start*avctx->sample_rate/(1024/sce->ics.num_windows)/2

More precisely, the window doesn't count for this calculation, you
don't care which window it is, only which coefficient.

And that will be an int, not a float.

Other than that, it looks fine.

You should try to fix the off_pns issue, retest, and resubmit.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/3] [GSoC] [AAC] aacdec: Use defined macros for constants

2015-04-12 Thread Claudio Freire
Looks good.

Though it does depend on the first patch of the series.

On Sun, Apr 12, 2015 at 1:50 AM, Rostislav Pehlivanov
 wrote:
> This commit changes the decoder to use the macro definitions for scalefactors 
> and noise energy values reading. This was done to reduce confusion when 
> looking at the encoder and decoder and possibly as a first step in unifying 
> some of the code in the two files.
> ---
>  libavcodec/aacdec.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c
> index 5a0c05a..3ed66c3 100644
> --- a/libavcodec/aacdec.c
> +++ b/libavcodec/aacdec.c
> @@ -1406,7 +1406,7 @@ static int decode_scalefactors(AACContext *ac, float 
> sf[120], GetBitContext *gb,
>  } else if ((band_type[idx] == INTENSITY_BT) ||
> (band_type[idx] == INTENSITY_BT2)) {
>  for (; i < run_end; i++, idx++) {
> -offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) 
> - 60;
> +offset[2] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) 
> - SCALE_DIFF_ZERO;
>  clipped_offset = av_clip(offset[2], -155, 100);
>  if (offset[2] != clipped_offset) {
>  avpriv_request_sample(ac->avctx,
> @@ -1419,9 +1419,9 @@ static int decode_scalefactors(AACContext *ac, float 
> sf[120], GetBitContext *gb,
>  } else if (band_type[idx] == NOISE_BT) {
>  for (; i < run_end; i++, idx++) {
>  if (noise_flag-- > 0)
> -offset[1] += get_bits(gb, 9) - 256;
> +offset[1] += get_bits(gb, NOISE_PRE_BITS) - 
> NOISE_PRE;
>  else
> -offset[1] += get_vlc2(gb, vlc_scalefactors.table, 7, 
> 3) - 60;
> +offset[1] += get_vlc2(gb, vlc_scalefactors.table, 7, 
> 3) - SCALE_DIFF_ZERO;
>  clipped_offset = av_clip(offset[1], -100, 155);
>  if (offset[1] != clipped_offset) {
>  avpriv_request_sample(ac->avctx,
> @@ -1433,7 +1433,7 @@ static int decode_scalefactors(AACContext *ac, float 
> sf[120], GetBitContext *gb,
>  }
>  } else {
>  for (; i < run_end; i++, idx++) {
> -offset[0] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) 
> - 60;
> +offset[0] += get_vlc2(gb, vlc_scalefactors.table, 7, 3) 
> - SCALE_DIFF_ZERO;
>  if (offset[0] > 255U) {
>  av_log(ac->avctx, AV_LOG_ERROR,
> "Scalefactor (%d) out of range.\n", 
> offset[0]);
> --
> 2.1.4
>
> ___
> 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 1/3] [GSoC] [AAC] aacenc: Add support for Perceptual Noise Substitution energy values

2015-04-12 Thread Claudio Freire
On Sun, Apr 12, 2015 at 11:52 PM, Claudio Freire  wrote:
> On Sun, Apr 12, 2015 at 11:49 PM, Claudio Freire  
> wrote:
>> On Sun, Apr 12, 2015 at 1:50 AM, Rostislav Pehlivanov
>>  wrote:
>>> +int diff, off_sf = sce->sf_idx[0], off_pns = sce->sf_idx[0];
>>
>>
>> If you take a look at the decoder, off_pns has to be initialized as off_pns 
>> - 90
>
>
> Sorry, hit send prematurely by mistake.
>
> Adding -90 there will probably invalidate parts of the following
> patches that deal with that offset (like that -70 at the second
> patch), but it's worth fixing.


Again with the typos. I'm clumsy tonight.

off_pns has to be initialized to off_sf - 90
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 3/3] [GSoC] [AAC] aacdec: Use defined macros for constants

2015-04-12 Thread Claudio Freire
On Mon, Apr 13, 2015 at 12:02 AM, Claudio Freire  wrote:
> Looks good.
>
> Though it does depend on the first patch of the series.
>
>
> On Sun, Apr 12, 2015 at 1:50 AM, Rostislav Pehlivanov
>  wrote:
>> This commit changes the decoder to use the macro definitions for 
>> scalefactors and noise energy values reading. This was done to reduce 
>> confusion when looking at the encoder and decoder and possibly as a first 
>> step in unifying some of the code in the two files.

Another thing I'd like to see in this patch set is a switch to enable
setting NOISE_BT, default off.

This is still a POC and should not be enabled unless specifically asked for.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [RFC][PATCH] avformat/flvdec: avoid reseting eof_reached to 0 silently

2015-04-12 Thread Zhang Rui
2015-04-12 22:45 GMT+08:00 Michael Niedermayer :
> On Sun, Apr 12, 2015 at 12:00:18PM +0800, Zhang Rui wrote:
>> 2015-04-10 22:04 GMT+08:00 wm4 :
>> > On Fri, 10 Apr 2015 21:17:42 +0800
>> > Zhang Rui  wrote:
>> >>
>> >> This kind of error handling need some more work in aviobuf.c,
>> >> and more advises from ffmpeg developers.
>> >> And i prefer this way than the patch I posted.
>> >
>> > stdio.h does it this way: FILE has an error flag that is set when
>> > something goes wrong.
>>
>> AVIOContext has an error field, too. But I don't think it's enough
>> for EAGAIN situation without some convention.
>> At least, ffplay doesn't show that.
>>
>> >> > Also, why doesn't avio_skip() return an error if the skip count is not
>> >> > 0 and the stream has reached EOF?
>> >>
>> >> The eof handling is quite confusing in ffplay for me. AVERROR_EOF is
>> >> clear enough.
>> >
>> > Well, I have no idea what avio_skip() even returns... it just calls
>> > avio_seek(), which is a goddamn fucked up mess thanks to years of
>> > people adding hacks.
>>
>> Is there any correct direction to fix it?
>>
>> > ffplay probably does it wrong. Wouldn't be surprising. It checks
>> > avio_feof() after a av_read_frame() call, which doesn't look correct.
>> > File EOF has absolutely nothing to do with whether a demuxer still has
>> > data.
>> >
>> > On a side note, I'm not sure whether av_read_frame() returning
>> > AVERROR_EOF is an error at all, or just signals that the end of the
>> > file was reached. The doxygen on this function isn't helpful either.
>>
>> Is there any ideas, or any helpful keywords or threads in mail list archive?
>
> a simple error_count field could be added that way one could easily
> check if the count increased over any series of function call(s)

Good enough for internal use of avio_r8().

> it also could be presented at verbose level by the user application,
> showing how many io errors where encountered which where not fatal

Two problems for application:

1. Which error should be defined as fatal?
For avio_r8(), even an EAGAIN can be a fatal.
The error_count has no more information than error field for application.

2. Nested format, e.g. hls, concatdec.
The error_count field is supposed to be added to AVIOContext.
But if the internal input failed, it's weired to set error to the
outer AVIOContext,
since it has nothing todo with the outer http/file/... protocol.


In my opinion, we could stop returning avio error code directly from
av_read_frame(),
and limit the error code which could return from av_read_frame(), explicitly.
e.g.

// Map various error codes to limited error codes.
int av_read_frame2(AVFormatContext *s, AVPacket *pkt) {
int ret = av_read_frame(s, pkt);
switch (ret) {
case AVERROR_EOS: // end of stream.
case AVERROR_AGAIN: // error can be recovered.
case AVERROR_EXIT: // interrupted by user.
case AVERROR_FAIL: // generic error
return ret;
case AVERROR(EAGAIN):
return AVERROR_AGAIN;
case AVERROR(EOF):
return AVERROR_EOS;
default:
return AVERROR_FAIL;
}
}

Detailed error code could be obtained from new API av_get_error(),
as errno/WSAGetLastError() does.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/rtsp: Fix dereference after null check

2015-04-12 Thread Himangi Saraogi
On 13 April 2015 at 01:27, Thomas Volkert  wrote:

>
> Am 12.04.2015 um 21:35 schrieb Himangi Saraogi:
>
>> ---
>> This fixes CID 732219.
>>
>>   libavformat/rtsp.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
>> index 42dbe96..c186b99 100644
>> --- a/libavformat/rtsp.c
>> +++ b/libavformat/rtsp.c
>> @@ -802,7 +802,7 @@ int ff_rtsp_open_transport_ctx(AVFormatContext *s,
>> RTSPStream *rtsp_st)
>>   if (!st)
>>   s->ctx_flags |= AVFMTCTX_NOHEADER;
>>   -if (CONFIG_RTSP_MUXER && s->oformat) {
>> +if (CONFIG_RTSP_MUXER && s->oformat && st) {
>>   int ret = ff_rtp_chain_mux_open((AVFormatContext
>> **)&rtsp_st->transport_priv,
>>   s, st, rtsp_st->rtp_handle,
>>   RTSP_TCP_MAX_PACKET_SIZE,
>> @@ -814,7 +814,7 @@ int ff_rtsp_open_transport_ctx(AVFormatContext *s,
>> RTSPStream *rtsp_st)
>>   st->time_base = ((AVFormatContext*)rtsp_st->
>> transport_priv)->streams[0]->time_base;
>>   } else if (rt->transport == RTSP_TRANSPORT_RAW) {
>>   return 0; // Don't need to open any parser here
>> -} else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RDT)
>> +} else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RDT &&
>> st)
>>   rtsp_st->transport_priv = ff_rdt_parse_open(s, st->index,
>>   rtsp_st->dynamic_protocol_
>> context,
>>   rtsp_st->dynamic_handler);
>>
> LGTM, this addresses the problem which was resported by coverity scan.
>
> But I think this is only a part of the complete solution. If "st" is NULL,
> it would also crash inside "ff_rtp_parse_open()"


I had checked for that, but ff_rtp_parse_open does a null test before using
"st" and hence probably avoids a crash.


> (espec., if H.264 or G.722 are used).
> Could you also fix this in a separate patch? Maybe you can also rearrange
> the "if" checks/branches and remove some duplicated conditions in the code.
>
>
I was planning on that when I saw these if branches!


> Best regards,
> Thomas.
>
>
> Thanks,
Himangi

>
> ___
> 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] lavf/http: handle case where the server returns a redirect during a seek

2015-04-12 Thread Rodger Combs
txoffer (e.g. http://tori.aoi-chan.com/ ) redirects to the same URI on your
first request, and serves the actual file on the second. It's stupid, but AFAIK
technically compliant. We'd previously see the server not handing back a Range
header and return an error; now, instead, we see that there's a redirect and
keep track of the offset we want while trying again at the new URL.
---
 libavformat/http.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/http.c b/libavformat/http.c
index b2293da..bbe5de5 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -917,6 +917,9 @@ static int http_connect(URLContext *h, const char *path, 
const char *local_path,
 if (err < 0)
 goto done;
 
+if (*new_location)
+s->off = off;
+
 err = (off == s->off) ? 0 : -1;
 done:
 av_freep(&authstr);
-- 
2.3.5

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


[FFmpeg-devel] [PATCH] lavf/mpeg: vobsub add an option to specify the .sub's URI

2015-04-12 Thread Rodger Combs
---
 libavformat/mpeg.c | 52 +---
 1 file changed, 37 insertions(+), 15 deletions(-)

diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index c29291d..1c5bbed 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -26,6 +26,7 @@
 #if CONFIG_VOBSUB_DEMUXER
 # include "subtitles.h"
 # include "libavutil/bprint.h"
+# include "libavutil/opt.h"
 #endif
 
 #include "libavutil/avassert.h"
@@ -121,6 +122,7 @@ static int mpegps_probe(AVProbeData *p)
 }
 
 typedef struct MpegDemuxContext {
+AVClass *class;
 int32_t header_state;
 unsigned char psm_es_type[256];
 int sofdec;
@@ -129,6 +131,7 @@ typedef struct MpegDemuxContext {
 #if CONFIG_VOBSUB_DEMUXER
 AVFormatContext *sub_ctx;
 FFDemuxSubtitlesQueue q[32];
+char *sub_name;
 #endif
 } MpegDemuxContext;
 
@@ -684,9 +687,8 @@ static int vobsub_read_header(AVFormatContext *s)
 {
 int i, ret = 0, header_parsed = 0, langidx = 0;
 MpegDemuxContext *vobsub = s->priv_data;
-char *sub_name = NULL;
 size_t fname_len;
-char *ext, *header_str;
+char *header_str;
 AVBPrint header;
 int64_t delay = 0;
 AVStream *st = NULL;
@@ -695,17 +697,25 @@ static int vobsub_read_header(AVFormatContext *s)
 char alt[MAX_LINE_SIZE] = {0};
 AVInputFormat *iformat;
 
-sub_name = av_strdup(s->filename);
-fname_len = strlen(sub_name);
-ext = sub_name - 3 + fname_len;
-if (fname_len < 4 || *(ext - 1) != '.') {
-av_log(s, AV_LOG_ERROR, "The input index filename is too short "
-   "to guess the associated .SUB file\n");
-ret = AVERROR_INVALIDDATA;
-goto end;
+if (!vobsub->sub_name) {
+char *ext;
+vobsub->sub_name = av_strdup(s->filename);
+if (!vobsub->sub_name) {
+ret = AVERROR(ENOMEM);
+goto end;
+}
+
+fname_len = strlen(vobsub->sub_name);
+ext = vobsub->sub_name - 3 + fname_len;
+if (fname_len < 4 || *(ext - 1) != '.') {
+av_log(s, AV_LOG_ERROR, "The input index filename is too short "
+   "to guess the associated .SUB file\n");
+ret = AVERROR_INVALIDDATA;
+goto end;
+}
+memcpy(ext, !strncmp(ext, "IDX", 3) ? "SUB" : "sub", 3);
+av_log(s, AV_LOG_VERBOSE, "IDX/SUB: %s -> %s\n", s->filename, 
vobsub->sub_name);
 }
-memcpy(ext, !strncmp(ext, "IDX", 3) ? "SUB" : "sub", 3);
-av_log(s, AV_LOG_VERBOSE, "IDX/SUB: %s -> %s\n", s->filename, sub_name);
 
 if (!(iformat = av_find_input_format("mpeg"))) {
 ret = AVERROR_DEMUXER_NOT_FOUND;
@@ -721,9 +731,9 @@ static int vobsub_read_header(AVFormatContext *s)
 if ((ret = ff_copy_whitelists(vobsub->sub_ctx, s)) < 0)
 goto end;
 
-ret = avformat_open_input(&vobsub->sub_ctx, sub_name, iformat, NULL);
+ret = avformat_open_input(&vobsub->sub_ctx, vobsub->sub_name, iformat, 
NULL);
 if (ret < 0) {
-av_log(s, AV_LOG_ERROR, "Unable to open %s as MPEG subtitles\n", 
sub_name);
+av_log(s, AV_LOG_ERROR, "Unable to open %s as MPEG subtitles\n", 
vobsub->sub_name);
 goto end;
 }
 
@@ -860,7 +870,6 @@ static int vobsub_read_header(AVFormatContext *s)
 av_free(header_str);
 
 end:
-av_free(sub_name);
 return ret;
 }
 
@@ -996,6 +1005,18 @@ static int vobsub_read_close(AVFormatContext *s)
 return 0;
 }
 
+static const AVOption options[] = {
+{ "sub_name", "URI for .sub file", offsetof(MpegDemuxContext, sub_name), 
AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, AV_OPT_FLAG_DECODING_PARAM },
+{ NULL }
+};
+
+static const AVClass vobsub_demuxer_class = {
+.class_name = "vobsub",
+.item_name  = av_default_item_name,
+.option = options,
+.version= LIBAVUTIL_VERSION_INT,
+};
+
 AVInputFormat ff_vobsub_demuxer = {
 .name   = "vobsub",
 .long_name  = NULL_IF_CONFIG_SMALL("VobSub subtitle format"),
@@ -1007,5 +1028,6 @@ AVInputFormat ff_vobsub_demuxer = {
 .read_close = vobsub_read_close,
 .flags  = AVFMT_SHOW_IDS,
 .extensions = "idx",
+.priv_class = &vobsub_demuxer_class,
 };
 #endif
-- 
2.3.5

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