[FFmpeg-cvslog] avcodec/(e)ac3: Fix target_level for EAC3.

2016-09-15 Thread Nikolas Bowe
ffmpeg | branch: master | Nikolas Bowe  | Fri 
Sep  9 12:48:52 2016 -0700| [96cd6f672e5d8c5d49b06de4f24376f36880fea8] | 
committer: Michael Niedermayer

avcodec/(e)ac3: Fix target_level for EAC3.

Currently when using target_level with EAC3 it produces silence. This small 
patch fixes target_level for decoding EAC3.

Example:
ffmpeg -y -i /tmp/test.wav -acodec eac3 -dialnorm -14 -ac 6 -b:a 384000 
/tmp/test.m2ts
ffmpeg -y -target_level -24 -i /tmp/test.m2ts -acodec pcm_s16le -f matroska 
/tmp/out.mkv
ffplay /tmp/out.mkv

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=96cd6f672e5d8c5d49b06de4f24376f36880fea8
---

 libavcodec/ac3.h |  2 +-
 libavcodec/ac3dec.c  |  9 ++---
 libavcodec/ac3dec.h  |  4 
 libavcodec/eac3dec.c | 14 +++---
 4 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h
index 747f2f5..5c9c377 100644
--- a/libavcodec/ac3.h
+++ b/libavcodec/ac3.h
@@ -87,7 +87,7 @@ typedef int16_t SHORTFLOAT;
 #define AC3_NORM(norm)  (1.0f/(norm))
 #define AC3_MUL(a,b)((a) * (b))
 #define AC3_RANGE(x)(dynamic_range_tab[(x)])
-#define AC3_HEAVY_RANGE(x)  (heavy_dynamic_range_tab[(x)])
+#define AC3_HEAVY_RANGE(x)  (ff_ac3_heavy_dynamic_range_tab[(x)])
 #define AC3_DYNAMIC_RANGE(x)(powf(x,  s->drc_scale))
 #define AC3_SPX_BLEND(x)(x)* (1.0f/32)
 #define AC3_DYNAMIC_RANGE1  1.0f
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index fac189b..a95c204 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -63,9 +63,11 @@ static const uint8_t quantization_tab[16] = {
 5, 6, 7, 8, 9, 10, 11, 12, 14, 16
 };
 
+#if (!USE_FIXED)
 /** dynamic range table. converts codes to scale factors. */
 static float dynamic_range_tab[256];
-static float heavy_dynamic_range_tab[256];
+float ff_ac3_heavy_dynamic_range_tab[256];
+#endif
 
 /** Adjustments in dB gain */
 static const float gain_levels[9] = {
@@ -159,6 +161,7 @@ static av_cold void ac3_tables_init(void)
 b5_mantissas[i] = symmetric_dequant(i, 15);
 }
 
+#if (!USE_FIXED)
 /* generate dynamic range table
reference: Section 7.7.1 Dynamic Range Control */
 for (i = 0; i < 256; i++) {
@@ -170,9 +173,9 @@ static av_cold void ac3_tables_init(void)
reference: Section 7.7.2 Heavy Compression */
 for (i = 0; i < 256; i++) {
 int v = (i >> 4) - ((i >> 7) << 4) - 4;
-heavy_dynamic_range_tab[i] = powf(2.0f, v) * ((i & 0xF) | 0x10);
+ff_ac3_heavy_dynamic_range_tab[i] = powf(2.0f, v) * ((i & 0xF) | 0x10);
 }
-
+#endif
 }
 
 /**
diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h
index c2b867e..6cd67c0 100644
--- a/libavcodec/ac3dec.h
+++ b/libavcodec/ac3dec.h
@@ -260,4 +260,8 @@ static void 
ff_eac3_decode_transform_coeffs_aht_ch(AC3DecodeContext *s, int ch);
  */
 static void ff_eac3_apply_spectral_extension(AC3DecodeContext *s);
 
+#if (!USE_FIXED)
+extern float ff_ac3_heavy_dynamic_range_tab[256];
+#endif
+
 #endif /* AVCODEC_AC3DEC_H */
diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c
index 47e5aa6..83a54bc 100644
--- a/libavcodec/eac3dec.c
+++ b/libavcodec/eac3dec.c
@@ -339,9 +339,17 @@ static int ff_eac3_parse_header(AC3DecodeContext *s)
 
 /* volume control params */
 for (i = 0; i < (s->channel_mode ? 1 : 2); i++) {
-skip_bits(gbc, 5); // skip dialog normalization
-if (get_bits1(gbc)) {
-skip_bits(gbc, 8); // skip compression gain word
+s->dialog_normalization[i] = -get_bits(gbc, 5);
+if (s->dialog_normalization[i] == 0) {
+s->dialog_normalization[i] = -31;
+}
+if (s->target_level != 0) {
+s->level_gain[i] = powf(2.0f,
+(float)(s->target_level - s->dialog_normalization[i])/6.0f);
+}
+s->compression_exists[i] = get_bits1(gbc);
+if (s->compression_exists[i]) {
+s->heavy_dynamic_range[i] = AC3_HEAVY_RANGE(get_bits(gbc, 8));
 }
 }
 

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


[FFmpeg-cvslog] lavf/rtsp: Fix a crash with the RTSP muxer.

2016-09-15 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Thu Sep 15 
13:50:57 2016 +0200| [f8a13c72132a65e34e05b878dc780ad330dd7371] | committer: 
Carl Eugen Hoyos

lavf/rtsp: Fix a crash with the RTSP muxer.

Introduced in 00e122bc / bc2a3296
The whole block that the statement was added to is only
relevant when used as a demuxer, but the other statements
there have had other if statements guarding them. Make
sure to only run this whole block if being used as a
demuxer.

Fixes ticket #5844.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f8a13c72132a65e34e05b878dc780ad330dd7371
---

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

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 15e1ab8..c6292c5 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -834,7 +834,8 @@ int ff_rtsp_open_transport_ctx(AVFormatContext *s, 
RTSPStream *rtsp_st)
 
 if (!rtsp_st->transport_priv) {
  return AVERROR(ENOMEM);
-} else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RTP) {
+} else if (CONFIG_RTPDEC && rt->transport == RTSP_TRANSPORT_RTP &&
+   s->iformat) {
 RTPDemuxContext *rtpctx = rtsp_st->transport_priv;
 rtpctx->ssrc = rtsp_st->ssrc;
 if (rtsp_st->dynamic_handler) {

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


[FFmpeg-cvslog] libavcodec/qsvdec_h2645.c: drop executable permission

2016-09-15 Thread Moritz Barsnick
ffmpeg | branch: master | Moritz Barsnick  | Thu Sep 15 
15:49:38 2016 +0200| [022260271b1786796ec035d86d28b9bf9b177060] | committer: 
Carl Eugen Hoyos

libavcodec/qsvdec_h2645.c: drop executable permission

Accidentally set in b93e2233155e6c1f0a074cad4135a70d9d2934d3.

Signed-off-by: Moritz Barsnick 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=022260271b1786796ec035d86d28b9bf9b177060
---

 libavcodec/qsvdec_h2645.c | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/libavcodec/qsvdec_h2645.c b/libavcodec/qsvdec_h2645.c
old mode 100755
new mode 100644

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


[FFmpeg-cvslog] avformat/msf: add support for ATRAC3 codec

2016-09-15 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Thu Sep 15 16:57:48 
2016 +0200| [4d677c7ae37d1df57cc79ea7577c2e4cd1de8e3a] | committer: Paul B Mahol

avformat/msf: add support for ATRAC3 codec

Signed-off-by: Paul B Mahol 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4d677c7ae37d1df57cc79ea7577c2e4cd1de8e3a
---

 libavformat/msf.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavformat/msf.c b/libavformat/msf.c
index 0551e9b..24654e6 100644
--- a/libavformat/msf.c
+++ b/libavformat/msf.c
@@ -44,6 +44,7 @@ static int msf_read_header(AVFormatContext *s)
 {
 unsigned codec, align, size;
 AVStream *st;
+int ret;
 
 avio_skip(s->pb, 4);
 
@@ -68,6 +69,17 @@ static int msf_read_header(AVFormatContext *s)
 case 0: st->codecpar->codec_id = AV_CODEC_ID_PCM_S16BE; break;
 case 3: st->codecpar->block_align = 16 * st->codecpar->channels;
 st->codecpar->codec_id = AV_CODEC_ID_ADPCM_PSX; break;
+case 4:
+case 5:
+case 6: st->codecpar->block_align = (codec == 4 ? 96 : codec == 5 ? 152 : 
192) * st->codecpar->channels;
+ret = ff_alloc_extradata(st->codecpar, 14);
+if (ret < 0)
+return ret;
+memset(st->codecpar->extradata, 0, st->codecpar->extradata_size);
+AV_WL16(st->codecpar->extradata, 1);
+AV_WL16(st->codecpar->extradata+4, 4096);
+AV_WL16(st->codecpar->extradata+10, 1);
+st->codecpar->codec_id = AV_CODEC_ID_ATRAC3;break;
 case 7: st->need_parsing = AVSTREAM_PARSE_FULL_RAW;
 st->codecpar->codec_id = AV_CODEC_ID_MP3;   break;
 default:

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


[FFmpeg-cvslog] avcodec/adpcm: clip step for ADPCM MTAF decoder

2016-09-15 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Thu Sep 15 17:24:40 
2016 +0200| [b82c1a377a2b11663561189208f57c6c639f8ec6] | committer: Paul B Mahol

avcodec/adpcm: clip step for ADPCM MTAF decoder

Signed-off-by: Paul B Mahol 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b82c1a377a2b11663561189208f57c6c639f8ec6
---

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

diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c
index 06ba83e..cb7f644 100644
--- a/libavcodec/adpcm.c
+++ b/libavcodec/adpcm.c
@@ -909,8 +909,8 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void 
*data,
 case AV_CODEC_ID_ADPCM_MTAF:
 for (channel = 0; channel < avctx->channels; channel+=2) {
 bytestream2_skipu(&gb, 4);
-c->status[channel].step  = bytestream2_get_le16u(&gb);
-c->status[channel + 1].step  = bytestream2_get_le16u(&gb);
+c->status[channel].step  = bytestream2_get_le16u(&gb) & 
0x1f;
+c->status[channel + 1].step  = bytestream2_get_le16u(&gb) & 
0x1f;
 c->status[channel].predictor = 
sign_extend(bytestream2_get_le16u(&gb), 16);
 bytestream2_skipu(&gb, 2);
 c->status[channel + 1].predictor = 
sign_extend(bytestream2_get_le16u(&gb), 16);

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


[FFmpeg-cvslog] lavc: add hevc mediacodec decoder

2016-09-15 Thread Matthieu Bouron
ffmpeg | branch: master | Matthieu Bouron  | Mon 
Sep  5 17:08:41 2016 +0200| [140da8e810b2221922b800b4b0be8a5a8e08e0b6] | 
committer: Matthieu Bouron

lavc: add hevc mediacodec decoder

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=140da8e810b2221922b800b4b0be8a5a8e08e0b6
---

 Changelog  |   1 +
 configure  |   3 +
 libavcodec/Makefile|   3 +-
 libavcodec/allcodecs.c |   2 +
 libavcodec/hevc_parse.c| 134 ++
 libavcodec/hevc_parse.h|  33 
 libavcodec/mediacodec_wrapper.c|  23 ++-
 libavcodec/mediacodecdec.c |   7 +
 ...{mediacodecdec_h264.c => mediacodecdec_h2645.c} | 197 ++---
 libavcodec/version.h   |   4 +-
 10 files changed, 373 insertions(+), 34 deletions(-)

diff --git a/Changelog b/Changelog
index c5cdada..9f00342 100644
--- a/Changelog
+++ b/Changelog
@@ -28,6 +28,7 @@ version :
 - gblur filter
 - avgblur filter
 - sobel and prewitt filter
+- MediaCodec HEVC decoding
 
 
 version 3.1:
diff --git a/configure b/configure
index b11ca7f..af3fbf4 100755
--- a/configure
+++ b/configure
@@ -2585,6 +2585,9 @@ h264_videotoolbox_hwaccel_select="h264_decoder"
 hevc_cuvid_hwaccel_deps="cuda cuvid CUVIDHEVCPICPARAMS"
 hevc_d3d11va_hwaccel_deps="d3d11va DXVA_PicParams_HEVC"
 hevc_d3d11va_hwaccel_select="hevc_decoder"
+hevc_mediacodec_decoder_deps="mediacodec"
+hevc_mediacodec_hwaccel_deps="mediacodec"
+hevc_mediacodec_decoder_select="hevc_mp4toannexb_bsf hevc_parser"
 hevc_dxva2_hwaccel_deps="dxva2 DXVA_PicParams_HEVC"
 hevc_dxva2_hwaccel_select="hevc_decoder"
 hevc_qsv_hwaccel_deps="libmfx"
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 9c7302a..41fb216 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -316,7 +316,7 @@ OBJS-$(CONFIG_H264_DECODER)+= h264dec.o 
h264_cabac.o h264_cavlc.o \
   h264_slice.o h264data.o h264_parse.o 
\
   h2645_parse.o
 OBJS-$(CONFIG_H264_CUVID_DECODER)  += cuvid.o
-OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec_h264.o
+OBJS-$(CONFIG_H264_MEDIACODEC_DECODER) += mediacodecdec_h2645.o
 OBJS-$(CONFIG_H264_MMAL_DECODER)   += mmaldec.o
 OBJS-$(CONFIG_H264_NVENC_ENCODER)  += nvenc_h264.o
 OBJS-$(CONFIG_NVENC_ENCODER)   += nvenc_h264.o
@@ -333,6 +333,7 @@ OBJS-$(CONFIG_HEVC_DECODER)+= hevc.o hevc_mvs.o 
hevc_ps.o hevc_sei.o
   hevc_cabac.o hevc_refs.o hevcpred.o  
  \
   hevcdsp.o hevc_filter.o 
h2645_parse.o hevc_data.o
 OBJS-$(CONFIG_HEVC_CUVID_DECODER)  += cuvid.o
+OBJS-$(CONFIG_HEVC_MEDIACODEC_DECODER) += mediacodecdec_h2645.o hevc_parse.o
 OBJS-$(CONFIG_HEVC_NVENC_ENCODER)  += nvenc_hevc.o
 OBJS-$(CONFIG_NVENC_HEVC_ENCODER)  += nvenc_hevc.o
 OBJS-$(CONFIG_HEVC_QSV_DECODER)+= qsvdec_h2645.o
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index a26a80e..142ccba 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -84,6 +84,7 @@ void avcodec_register_all(void)
 REGISTER_HWACCEL(HEVC_CUVID,hevc_cuvid);
 REGISTER_HWACCEL(HEVC_D3D11VA,  hevc_d3d11va);
 REGISTER_HWACCEL(HEVC_DXVA2,hevc_dxva2);
+REGISTER_HWACCEL(HEVC_MEDIACODEC,   hevc_mediacodec);
 REGISTER_HWACCEL(HEVC_QSV,  hevc_qsv);
 REGISTER_HWACCEL(HEVC_VAAPI,hevc_vaapi);
 REGISTER_HWACCEL(HEVC_VDPAU,hevc_vdpau);
@@ -644,6 +645,7 @@ void avcodec_register_all(void)
 REGISTER_ENCODER(NVENC_HEVC,nvenc_hevc);
 #endif
 REGISTER_DECODER(HEVC_CUVID,hevc_cuvid);
+REGISTER_DECODER(HEVC_MEDIACODEC,   hevc_mediacodec);
 REGISTER_ENCODER(HEVC_NVENC,hevc_nvenc);
 REGISTER_ENCODER(HEVC_QSV,  hevc_qsv);
 REGISTER_ENCODER(HEVC_VAAPI,hevc_vaapi);
diff --git a/libavcodec/hevc_parse.c b/libavcodec/hevc_parse.c
new file mode 100644
index 000..cf04bc2
--- /dev/null
+++ b/libavcodec/hevc_parse.c
@@ -0,0 +1,134 @@
+/*
+ * 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 Stre

[FFmpeg-cvslog] libavformat/webm_chunk: Option to specify HTTP header

2016-09-15 Thread Vignesh Venkatasubramanian
ffmpeg | branch: master | Vignesh Venkatasubramanian 
 | Thu Sep 15 14:29:24 2016 -0700| 
[7238c53048e494d4914e6f8692ca844086f3ae65] | committer: Michael Niedermayer

libavformat/webm_chunk: Option to specify HTTP header

Add an option to specify HTTP header in the WebM Chunk Muxer (this
works the same way as the 'method' parameter in the HLS muxer).

Signed-off-by: Vignesh Venkatasubramanian 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7238c53048e494d4914e6f8692ca844086f3ae65
---

 libavformat/webm_chunk.c | 14 --
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c
index bfcde78..f8dbaa3 100644
--- a/libavformat/webm_chunk.c
+++ b/libavformat/webm_chunk.c
@@ -50,6 +50,7 @@ typedef struct WebMChunkContext {
 char *header_filename;
 int chunk_duration;
 int chunk_index;
+char *http_method;
 uint64_t duration_written;
 int prev_pts;
 AVOutputFormat *oformat;
@@ -112,6 +113,7 @@ static int webm_chunk_write_header(AVFormatContext *s)
 AVFormatContext *oc = NULL;
 int ret;
 int i;
+AVDictionary *options = NULL;
 
 // DASH Streams can only have either one track per file.
 if (s->nb_streams != 1) { return AVERROR_INVALIDDATA; }
@@ -128,7 +130,10 @@ static int webm_chunk_write_header(AVFormatContext *s)
 ret = get_chunk_filename(s, 1, oc->filename);
 if (ret < 0)
 return ret;
-ret = s->io_open(s, &oc->pb, oc->filename, AVIO_FLAG_WRITE, NULL);
+if (wc->http_method)
+av_dict_set(&options, "method", wc->http_method, 0);
+ret = s->io_open(s, &oc->pb, oc->filename, AVIO_FLAG_WRITE, &options);
+av_dict_free(&options);
 if (ret < 0)
 return ret;
 
@@ -166,6 +171,7 @@ static int chunk_end(AVFormatContext *s)
 uint8_t *buffer;
 AVIOContext *pb;
 char filename[MAX_FILENAME_SIZE];
+AVDictionary *options = NULL;
 
 if (wc->chunk_start_index == wc->chunk_index)
 return 0;
@@ -175,13 +181,16 @@ static int chunk_end(AVFormatContext *s)
 ret = get_chunk_filename(s, 0, filename);
 if (ret < 0)
 goto fail;
-ret = s->io_open(s, &pb, filename, AVIO_FLAG_WRITE, NULL);
+if (wc->http_method)
+av_dict_set(&options, "method", wc->http_method, 0);
+ret = s->io_open(s, &pb, filename, AVIO_FLAG_WRITE, &options);
 if (ret < 0)
 goto fail;
 avio_write(pb, buffer, buffer_size);
 ff_format_io_close(s, &pb);
 oc->pb = NULL;
 fail:
+av_dict_free(&options);
 av_free(buffer);
 return (ret < 0) ? ret : 0;
 }
@@ -243,6 +252,7 @@ static const AVOption options[] = {
 { "chunk_start_index",  "start index of the chunk", 
OFFSET(chunk_start_index), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, 
AV_OPT_FLAG_ENCODING_PARAM },
 { "header", "filename of the header where the initialization data will be 
written", OFFSET(header_filename), AV_OPT_TYPE_STRING, { 0 }, 0, 0, 
AV_OPT_FLAG_ENCODING_PARAM },
 { "audio_chunk_duration", "duration of each chunk in milliseconds", 
OFFSET(chunk_duration), AV_OPT_TYPE_INT, {.i64 = 5000}, 0, INT_MAX, 
AV_OPT_FLAG_ENCODING_PARAM },
+{ "method", "set the HTTP method", OFFSET(http_method), 
AV_OPT_TYPE_STRING, {.str = NULL},  0, 0, AV_OPT_FLAG_ENCODING_PARAM },
 { NULL },
 };
 

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