[libav-commits] Check if an mp3 header is using a reserved sample rate.

2014-06-26 Thread Justin Ruggles
Module: libav
Branch: release/10
Commit: fcbcc561e0fdc95a7dd48b92db53846726aec27e

Author:Justin Ruggles justin.rugg...@gmail.com
Committer: Luca Barbato lu_z...@gentoo.org
Date:  Sun Jun 22 13:11:32 2014 -0400

Check if an mp3 header is using a reserved sample rate.

Fixes an invalid read past the end of avpriv_mpa_freq_tab.
Fixes divide-by-zero due to sample_rate being set to 0.

Bug-Id: 705

CC:libav-sta...@libav.org
(cherry picked from commit 44127546b0a81dc9dd6190739a62d48f0044c6f3)
Signed-off-by: Luca Barbato lu_z...@gentoo.org

---

 libavcodec/mpegaudiodecheader.c |4 
 1 file changed, 4 insertions(+)

diff --git a/libavcodec/mpegaudiodecheader.c b/libavcodec/mpegaudiodecheader.c
index 69dda45..25e7319 100644
--- a/libavcodec/mpegaudiodecheader.c
+++ b/libavcodec/mpegaudiodecheader.c
@@ -24,6 +24,8 @@
  * MPEG Audio header decoder.
  */
 
+#include libavutil/common.h
+
 #include avcodec.h
 #include mpegaudio.h
 #include mpegaudiodata.h
@@ -45,6 +47,8 @@ int avpriv_mpegaudio_decode_header(MPADecodeHeader *s, 
uint32_t header)
 s-layer = 4 - ((header  17)  3);
 /* extract frequency */
 sample_rate_index = (header  10)  3;
+if (sample_rate_index = FF_ARRAY_ELEMS(avpriv_mpa_freq_tab))
+sample_rate_index = 0;
 sample_rate = avpriv_mpa_freq_tab[sample_rate_index]  (s-lsf + mpeg25);
 sample_rate_index += 3 * (s-lsf + mpeg25);
 s-sample_rate_index = sample_rate_index;

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] jpeg2000: fix dereferencing invalid pointers during cleanup

2014-06-26 Thread Vittorio Giovara
Module: libav
Branch: release/10
Commit: 74f6df745a05d3d8b3dcfc28992c69a70ae87957

Author:Vittorio Giovara vittorio.giov...@gmail.com
Committer: Luca Barbato lu_z...@gentoo.org
Date:  Sun Mar  9 18:52:40 2014 +0100

jpeg2000: fix dereferencing invalid pointers during cleanup

CC: libav-sta...@libav.org
Found-by: Laurent Butti laure...@gmail.com
Signed-off-by: Vittorio Giovara vittorio.giov...@gmail.com

---

 libavcodec/jpeg2000.c |   31 +++
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/libavcodec/jpeg2000.c b/libavcodec/jpeg2000.c
index bf46398..154409e 100644
--- a/libavcodec/jpeg2000.c
+++ b/libavcodec/jpeg2000.c
@@ -228,7 +228,7 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
 if (!comp-i_data)
 return AVERROR(ENOMEM);
 }
-comp-reslevel = av_malloc_array(codsty-nreslevels, 
sizeof(*comp-reslevel));
+comp-reslevel = av_mallocz_array(codsty-nreslevels, 
sizeof(*comp-reslevel));
 if (!comp-reslevel)
 return AVERROR(ENOMEM);
 /* LOOP on resolution levels */
@@ -276,7 +276,7 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
 reslevel-log2_prec_height) -
 (reslevel-coord[1][0]  reslevel-log2_prec_height);
 
-reslevel-band = av_malloc_array(reslevel-nbands, 
sizeof(*reslevel-band));
+reslevel-band = av_mallocz_array(reslevel-nbands, 
sizeof(*reslevel-band));
 if (!reslevel-band)
 return AVERROR(ENOMEM);
 
@@ -372,9 +372,9 @@ int ff_jpeg2000_init_component(Jpeg2000Component *comp,
 for (j = 0; j  2; j++)
 band-coord[1][j] = ff_jpeg2000_ceildiv(band-coord[1][j], dy);
 
-band-prec = av_malloc_array(reslevel-num_precincts_x *
- reslevel-num_precincts_y,
- sizeof(*band-prec));
+band-prec = av_mallocz_array(reslevel-num_precincts_x *
+  reslevel-num_precincts_y,
+  sizeof(*band-prec));
 if (!band-prec)
 return AVERROR(ENOMEM);
 
@@ -487,15 +487,30 @@ void ff_jpeg2000_cleanup(Jpeg2000Component *comp, 
Jpeg2000CodingStyle *codsty)
 for (reslevelno = 0;
  comp-reslevel  reslevelno  codsty-nreslevels;
  reslevelno++) {
-Jpeg2000ResLevel *reslevel = comp-reslevel + reslevelno;
+Jpeg2000ResLevel *reslevel;
+
+if (!comp-reslevel)
+continue;
 
+reslevel = comp-reslevel + reslevelno;
 for (bandno = 0; bandno  reslevel-nbands; bandno++) {
-Jpeg2000Band *band = reslevel-band + bandno;
+Jpeg2000Band *band;
+
+if (!reslevel-band)
+continue;
+
+band = reslevel-band + bandno;
 for (precno = 0; precno  reslevel-num_precincts_x * 
reslevel-num_precincts_y; precno++) {
-Jpeg2000Prec *prec = band-prec + precno;
+Jpeg2000Prec *prec;
+
+if (!band-prec)
+continue;
+
+prec = band-prec + precno;
 av_freep(prec-zerobits);
 av_freep(prec-cblkincl);
 av_freep(prec-cblk);
+
 }
 
 av_freep(band-prec);

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] adpcm: Avoid reading out of bounds in the IMA QT trellis encoder

2014-06-26 Thread Martin Storsjö
Module: libav
Branch: release/10
Commit: 771564945aa9aebe2f30192b925fcf4909225eca

Author:Martin Storsjö mar...@martin.st
Committer: Luca Barbato lu_z...@gentoo.org
Date:  Thu Jun  5 11:48:53 2014 +0300

adpcm: Avoid reading out of bounds in the IMA QT trellis encoder

This was broken in 095be4fb - samples+ch (for the previous
non-planar case) equals samples_p[ch][0]. The confusion
probably stemmed from the IMA WAV case where it originally
was samples[avctx-channels + ch], which was correctly
changed into samples_p[ch][1].

CC: libav-sta...@libav.org
Signed-off-by: Martin Storsjö mar...@martin.st
(cherry picked from commit 3d79d0c93e5b37a35b1b22d6c18699c233aad1ba)
Signed-off-by: Luca Barbato lu_z...@gentoo.org

---

 libavcodec/adpcmenc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index fb3ce0d..2cf8d6f 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -549,7 +549,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 put_bits(pb, 7,  status-step_index);
 if (avctx-trellis  0) {
 uint8_t buf[64];
-adpcm_compress_trellis(avctx, samples_p[ch][1], buf, status,
+adpcm_compress_trellis(avctx, samples_p[ch][0], buf, status,
64, 1);
 for (i = 0; i  64; i++)
 put_bits(pb, 4, buf[i ^ 1]);

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits

[libav-commits] oggenc: Set the right AVOption size for the pref_duration option

2014-06-26 Thread Martin Storsjö
Module: libav
Branch: release/10
Commit: 16f7cbef5610a878317596134607d2a89da66ecf

Author:Martin Storsjö mar...@martin.st
Committer: Luca Barbato lu_z...@gentoo.org
Date:  Fri Jun  6 13:59:14 2014 +0300

oggenc: Set the right AVOption size for the pref_duration option

On big endian machines, the default value set via the faulty
AVOption ended up as 2^32 times too big.

This fixes the fate-lavf-ogg test which currently is broken on
big endian machines, broken since 3831362. Since that commit,
a final zero-sized packet is written to the ogg muxer in that test,
which caused different flushing behaviour on little and big endian
depending on whether the pref_duration option was handled as it
should or not.

CC: libav-sta...@libav.org
Signed-off-by: Martin Storsjö mar...@martin.st
(cherry picked from commit 103243ca649cc305129ed0352bf4d97e5ddf4d80)
Signed-off-by: Luca Barbato lu_z...@gentoo.org

---

 libavformat/oggenc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/oggenc.c b/libavformat/oggenc.c
index fd102c8..a03ac15 100644
--- a/libavformat/oggenc.c
+++ b/libavformat/oggenc.c
@@ -80,7 +80,7 @@ static const AVOption options[] = {
 { pagesize, preferred page size in bytes (deprecated),
 OFFSET(pref_size), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, MAX_PAGE_SIZE, 
PARAM },
 { page_duration, preferred page duration, in microseconds,
-OFFSET(pref_duration), AV_OPT_TYPE_INT, { .i64 = 100 }, 0, 
INT64_MAX, PARAM },
+OFFSET(pref_duration), AV_OPT_TYPE_INT64, { .i64 = 100 }, 0, 
INT64_MAX, PARAM },
 { NULL },
 };
 

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits

[libav-commits] adpcm: Write the proper predictor in trellis mode in IMA QT

2014-06-26 Thread Martin Storsjö
Module: libav
Branch: release/9
Commit: 21d3e0ac9e1719d8444b3f5466983587ac0ad240

Author:Martin Storsjö mar...@martin.st
Committer: Luca Barbato lu_z...@gentoo.org
Date:  Thu Jun  5 14:49:14 2014 +0300

adpcm: Write the proper predictor in trellis mode in IMA QT

The actual predictor value, set by the trellis code, never
was written back into the variable that was written into
the block header. This was accidentally removed in b304244b.

This significantly improves the audio quality of the trellis
case, which was plain broken since b304244b.

Encoding IMA QT with trellis still actually gives a slightly
worse quality than without trellis, since the trellis encoder
doesn't use the exact same way of rounding as in
adpcm_ima_qt_compress_sample and adpcm_ima_qt_expand_nibble.

CC: libav-sta...@libav.org
Signed-off-by: Martin Storsjö mar...@martin.st
(cherry picked from commit 0776e0ef6ba4160281ef3fabea43e670f3792b4a)
Signed-off-by: Luca Barbato lu_z...@gentoo.org

---

 libavcodec/adpcmenc.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index 116458b..aa88395 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -561,6 +561,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
64, 1);
 for (i = 0; i  64; i++)
 put_bits(pb, 4, buf[i ^ 1]);
+status-prev_sample = status-predictor;
 } else {
 for (i = 0; i  64; i += 2) {
 int t1, t2;

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits

[libav-commits] adpcm: Avoid reading out of bounds in the IMA QT trellis encoder

2014-06-26 Thread Martin Storsjö
Module: libav
Branch: release/9
Commit: 744e7eea5d815efea777b6179d96e8d94b63ccfa

Author:Martin Storsjö mar...@martin.st
Committer: Luca Barbato lu_z...@gentoo.org
Date:  Thu Jun  5 11:48:53 2014 +0300

adpcm: Avoid reading out of bounds in the IMA QT trellis encoder

This was broken in 095be4fb - samples+ch (for the previous
non-planar case) equals samples_p[ch][0]. The confusion
probably stemmed from the IMA WAV case where it originally
was samples[avctx-channels + ch], which was correctly
changed into samples_p[ch][1].

CC: libav-sta...@libav.org
Signed-off-by: Martin Storsjö mar...@martin.st
(cherry picked from commit 3d79d0c93e5b37a35b1b22d6c18699c233aad1ba)
Signed-off-by: Luca Barbato lu_z...@gentoo.org

---

 libavcodec/adpcmenc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c
index f81d7fd..116458b 100644
--- a/libavcodec/adpcmenc.c
+++ b/libavcodec/adpcmenc.c
@@ -557,7 +557,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 put_bits(pb, 7,  status-step_index);
 if (avctx-trellis  0) {
 uint8_t buf[64];
-adpcm_compress_trellis(avctx, samples_p[ch][1], buf, status,
+adpcm_compress_trellis(avctx, samples_p[ch][0], buf, status,
64, 1);
 for (i = 0; i  64; i++)
 put_bits(pb, 4, buf[i ^ 1]);

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits

[libav-commits] hevc: remove unused array min_cb_addr_zs

2014-06-26 Thread Gildas Cocherel
Module: libav
Branch: master
Commit: a0e1c3517a656dd32293f054a339e0ac73328138

Author:Gildas Cocherel gildas.coche...@laposte.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Wed Jun 25 21:08:12 2014 +0200

hevc: remove unused array min_cb_addr_zs

Signed-off-by: Anton Khirnov an...@khirnov.net

---

 libavcodec/hevc.h|1 -
 libavcodec/hevc_ps.c |   19 +--
 2 files changed, 1 insertion(+), 19 deletions(-)

diff --git a/libavcodec/hevc.h b/libavcodec/hevc.h
index 959cd58..4b8bcf8 100644
--- a/libavcodec/hevc.h
+++ b/libavcodec/hevc.h
@@ -523,7 +523,6 @@ typedef struct HEVCPPS {
 int *ctb_addr_ts_to_rs; /// CtbAddrTSToRS
 int *tile_id;   /// TileId
 int *tile_pos_rs;   /// TilePosRS
-int *min_cb_addr_zs;/// MinCbAddrZS
 int *min_tb_addr_zs;/// MinTbAddrZS
 } HEVCPPS;
 
diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 65f41b2..4d1d027 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -980,7 +980,6 @@ static void hevc_pps_free(void *opaque, uint8_t *data)
 av_freep(pps-ctb_addr_ts_to_rs);
 av_freep(pps-tile_pos_rs);
 av_freep(pps-tile_id);
-av_freep(pps-min_cb_addr_zs);
 av_freep(pps-min_tb_addr_zs);
 
 av_freep(pps);
@@ -1235,10 +1234,9 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
 pps-ctb_addr_rs_to_ts = av_malloc_array(pic_area_in_ctbs,
sizeof(*pps-ctb_addr_rs_to_ts));
 pps-ctb_addr_ts_to_rs = av_malloc_array(pic_area_in_ctbs,
sizeof(*pps-ctb_addr_ts_to_rs));
 pps-tile_id   = av_malloc_array(pic_area_in_ctbs,
sizeof(*pps-tile_id));
-pps-min_cb_addr_zs= av_malloc_array(pic_area_in_min_cbs, 
sizeof(*pps-min_cb_addr_zs));
 pps-min_tb_addr_zs= av_malloc_array(pic_area_in_min_tbs, 
sizeof(*pps-min_tb_addr_zs));
 if (!pps-ctb_addr_rs_to_ts || !pps-ctb_addr_ts_to_rs ||
-!pps-tile_id || !pps-min_cb_addr_zs || !pps-min_tb_addr_zs) {
+!pps-tile_id || !pps-min_tb_addr_zs) {
 ret = AVERROR(ENOMEM);
 goto err;
 }
@@ -1292,21 +1290,6 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
 for (i = 0; i  pps-num_tile_columns; i++)
 pps-tile_pos_rs[j * pps-num_tile_columns + i] = pps-row_bd[j] * 
sps-ctb_width + pps-col_bd[i];
 
-for (y = 0; y  sps-min_cb_height; y++) {
-for (x = 0; x  sps-min_cb_width; x++) {
-int tb_x= x  sps-log2_diff_max_min_coding_block_size;
-int tb_y= y  sps-log2_diff_max_min_coding_block_size;
-int ctb_addr_rs = sps-ctb_width * tb_y + tb_x;
-int val = pps-ctb_addr_rs_to_ts[ctb_addr_rs] 
-  (sps-log2_diff_max_min_coding_block_size * 2);
-for (i = 0; i  sps-log2_diff_max_min_coding_block_size; i++) {
-int m = 1  i;
-val += (m  x ? m * m : 0) + (m  y ? 2 * m * m : 0);
-}
-pps-min_cb_addr_zs[y * sps-min_cb_width + x] = val;
-}
-}
-
 log2_diff_ctb_min_tb_size = sps-log2_ctb_size - sps-log2_min_tb_size;
 for (y = 0; y  sps-min_tb_height; y++) {
 for (x = 0; x  sps-min_tb_width; x++) {

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] hevc: Allow out of bound values for num_reorder_pics

2014-06-26 Thread Kieran Kunhya
Module: libav
Branch: master
Commit: 9b60d9197970658e91daf4b586397f450de9af69

Author:Kieran Kunhya kier...@obe.tv
Committer: Anton Khirnov an...@khirnov.net
Date:  Sun Jun 15 23:44:15 2014 +0200

hevc: Allow out of bound values for num_reorder_pics

This fixes decoding for a sample that cannot be shared

Signed-off-by: Anton Khirnov an...@khirnov.net

---

 libavcodec/hevc_ps.c |   15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index 5e5d4a7..65f41b2 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -375,9 +375,10 @@ int ff_hevc_decode_nal_vps(HEVCContext *s)
 goto err;
 }
 if (vps-vps_num_reorder_pics[i]  vps-vps_max_dec_pic_buffering[i] - 
1) {
-av_log(s-avctx, AV_LOG_ERROR, vps_max_num_reorder_pics out of 
range: %d\n,
+av_log(s-avctx, AV_LOG_WARNING, vps_max_num_reorder_pics out of 
range: %d\n,
vps-vps_num_reorder_pics[i]);
-goto err;
+if (s-avctx-err_recognition  AV_EF_EXPLODE)
+goto err;
 }
 }
 
@@ -760,10 +761,14 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
 goto err;
 }
 if (sps-temporal_layer[i].num_reorder_pics  
sps-temporal_layer[i].max_dec_pic_buffering - 1) {
-av_log(s-avctx, AV_LOG_ERROR, sps_max_num_reorder_pics out of 
range: %d\n,
+av_log(s-avctx, AV_LOG_WARNING, sps_max_num_reorder_pics out of 
range: %d\n,
sps-temporal_layer[i].num_reorder_pics);
-ret = AVERROR_INVALIDDATA;
-goto err;
+if (s-avctx-err_recognition  AV_EF_EXPLODE ||
+sps-temporal_layer[i].num_reorder_pics  MAX_DPB_SIZE - 1) {
+ret = AVERROR_INVALIDDATA;
+goto err;
+}
+sps-temporal_layer[i].max_dec_pic_buffering = 
sps-temporal_layer[i].num_reorder_pics + 1;
 }
 }
 

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] output example: free the muxing format context properly

2014-06-26 Thread Anton Khirnov
Module: libav
Branch: master
Commit: a5864e9a253143437471dba61a533e7fa9acec1c

Author:Anton Khirnov an...@khirnov.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Tue Jun 24 11:10:57 2014 +0200

output example: free the muxing format context properly

---

 doc/examples/output.c |8 +---
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/doc/examples/output.c b/doc/examples/output.c
index 7c29df1..0985659 100644
--- a/doc/examples/output.c
+++ b/doc/examples/output.c
@@ -549,18 +549,12 @@ int main(int argc, char **argv)
 if (have_audio)
 close_stream(oc, audio_st);
 
-/* Free the streams. */
-for (i = 0; i  oc-nb_streams; i++) {
-av_freep(oc-streams[i]-codec);
-av_freep(oc-streams[i]);
-}
-
 if (!(fmt-flags  AVFMT_NOFILE))
 /* Close the output file. */
 avio_close(oc-pb);
 
 /* free the stream */
-av_free(oc);
+avformat_free_context(oc);
 
 return 0;
 }

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] lavc: do not allocate edges in the default get_buffer2()

2014-06-26 Thread Anton Khirnov
Module: libav
Branch: master
Commit: 1b04eb20f7e3f0a71f73ba91efcc3d60a435e443

Author:Anton Khirnov an...@khirnov.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Fri Dec 20 16:00:07 2013 +0100

lavc: do not allocate edges in the default get_buffer2()

---

 libavcodec/utils.c |   22 +-
 1 file changed, 1 insertion(+), 21 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 33983f8..d6019d9 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -359,11 +359,6 @@ static int update_frame_pool(AVCodecContext *avctx, 
AVFrame *frame)
 
 avcodec_align_dimensions2(avctx, w, h, pool-stride_align);
 
-if (!(avctx-flags  CODEC_FLAG_EMU_EDGE)) {
-w += EDGE_WIDTH * 2;
-h += EDGE_WIDTH * 2;
-}
-
 do {
 // NOTE: do not align linesizes individually, this breaks e.g. 
assumptions
 // that linesize[0] == 2*linesize[1] in the MPEG-encoder for 4:2:2
@@ -487,9 +482,6 @@ fail:
 static int video_get_buffer(AVCodecContext *s, AVFrame *pic)
 {
 FramePool *pool = s-internal-pool;
-const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pic-format);
-int pixel_size = desc-comp[0].step_minus1 + 1;
-int h_chroma_shift, v_chroma_shift;
 int i;
 
 if (pic-data[0] != NULL) {
@@ -500,26 +492,14 @@ static int video_get_buffer(AVCodecContext *s, AVFrame 
*pic)
 memset(pic-data, 0, sizeof(pic-data));
 pic-extended_data = pic-data;
 
-av_pix_fmt_get_chroma_sub_sample(s-pix_fmt, h_chroma_shift, 
v_chroma_shift);
-
 for (i = 0; i  4  pool-pools[i]; i++) {
-const int h_shift = i == 0 ? 0 : h_chroma_shift;
-const int v_shift = i == 0 ? 0 : v_chroma_shift;
-
 pic-linesize[i] = pool-linesize[i];
 
 pic-buf[i] = av_buffer_pool_get(pool-pools[i]);
 if (!pic-buf[i])
 goto fail;
 
-// no edge if EDGE EMU or not planar YUV
-if ((s-flags  CODEC_FLAG_EMU_EDGE) || !pool-pools[2])
-pic-data[i] = pic-buf[i]-data;
-else {
-pic-data[i] = pic-buf[i]-data +
-FFALIGN((pic-linesize[i] * EDGE_WIDTH  v_shift) +
-(pixel_size * EDGE_WIDTH  h_shift), 
pool-stride_align[i]);
-}
+pic-data[i] = pic-buf[i]-data;
 }
 for (; i  AV_NUM_DATA_POINTERS; i++) {
 pic-data[i] = NULL;

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] output example: set output channel layout

2014-06-26 Thread Anton Khirnov
Module: libav
Branch: master
Commit: ac85f631c9a9cc59aaca1c8dd6894fb1f701c594

Author:Anton Khirnov an...@khirnov.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Mon Jun 23 21:38:37 2014 +0200

output example: set output channel layout

---

 doc/examples/output.c |2 ++
 1 file changed, 2 insertions(+)

diff --git a/doc/examples/output.c b/doc/examples/output.c
index 620be15..3d14449 100644
--- a/doc/examples/output.c
+++ b/doc/examples/output.c
@@ -34,6 +34,7 @@
 #include string.h
 #include math.h
 
+#include libavutil/channel_layout.h
 #include libavutil/mathematics.h
 #include libavformat/avformat.h
 #include libswscale/swscale.h
@@ -90,6 +91,7 @@ static AVStream *add_audio_stream(AVFormatContext *oc, enum 
AVCodecID codec_id)
 c-bit_rate= 64000;
 c-sample_rate = 44100;
 c-channels= 2;
+c-channel_layout = AV_CH_LAYOUT_STEREO;
 
 // some formats want stream headers to be separate
 if (oc-oformat-flags  AVFMT_GLOBALHEADER)

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] dump_stream: print the timebase as is, do not reduce it

2014-06-26 Thread Anton Khirnov
Module: libav
Branch: master
Commit: 3f4edf012593c73941caa0ef9b292da00225c3df

Author:Anton Khirnov an...@khirnov.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Tue Jun 24 07:39:35 2014 +0200

dump_stream: print the timebase as is, do not reduce it

It makes more sense to print the timebase exactly as it is set. Also,
this avoids a divide by zero when av_dump_format() is called on a format
context before writing the header.

---

 libavformat/dump.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libavformat/dump.c b/libavformat/dump.c
index 1e385ab..aae23af 100644
--- a/libavformat/dump.c
+++ b/libavformat/dump.c
@@ -279,7 +279,6 @@ static void dump_stream_format(AVFormatContext *ic, int i,
 char buf[256];
 int flags = (is_output ? ic-oformat-flags : ic-iformat-flags);
 AVStream *st = ic-streams[i];
-int g = av_gcd(st-time_base.num, st-time_base.den);
 AVDictionaryEntry *lang = av_dict_get(st-metadata, language, NULL, 0);
 
 avcodec_string(buf, sizeof(buf), st-codec, is_output);
@@ -292,7 +291,7 @@ static void dump_stream_format(AVFormatContext *ic, int i,
 if (lang)
 av_log(NULL, AV_LOG_INFO, (%s), lang-value);
 av_log(NULL, AV_LOG_DEBUG, , %d, %d/%d, st-codec_info_nb_frames,
-   st-time_base.num / g, st-time_base.den / g);
+   st-time_base.num, st-time_base.den);
 av_log(NULL, AV_LOG_INFO, : %s, buf);
 
 if (st-sample_aspect_ratio.num  // default

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] output example: store the scaling context in the stream context

2014-06-26 Thread Anton Khirnov
Module: libav
Branch: master
Commit: a7fcd4122b19b0f934020f4e261d0c44c4c32e11

Author:Anton Khirnov an...@khirnov.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Tue Jun 24 10:21:07 2014 +0200

output example: store the scaling context in the stream context

---

 doc/examples/output.c |   20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/doc/examples/output.c b/doc/examples/output.c
index ffc6e55..d8321be 100644
--- a/doc/examples/output.c
+++ b/doc/examples/output.c
@@ -55,6 +55,8 @@ typedef struct OutputStream {
 AVFrame *tmp_frame;
 
 float t, tincr, tincr2;
+
+struct SwsContext *sws_ctx;
 } OutputStream;
 
 /**/
@@ -327,7 +329,6 @@ static void write_video_frame(AVFormatContext *oc, 
OutputStream *ost)
 {
 int ret;
 AVCodecContext *c;
-static struct SwsContext *img_convert_ctx;
 
 c = ost-st-codec;
 
@@ -339,20 +340,20 @@ static void write_video_frame(AVFormatContext *oc, 
OutputStream *ost)
 if (c-pix_fmt != AV_PIX_FMT_YUV420P) {
 /* as we only generate a YUV420P picture, we must convert it
  * to the codec pixel format if needed */
-if (img_convert_ctx == NULL) {
-img_convert_ctx = sws_getContext(c-width, c-height,
- AV_PIX_FMT_YUV420P,
- c-width, c-height,
- c-pix_fmt,
- SCALE_FLAGS, NULL, NULL, 
NULL);
-if (img_convert_ctx == NULL) {
+if (!ost-sws_ctx) {
+ost-sws_ctx = sws_getContext(c-width, c-height,
+  AV_PIX_FMT_YUV420P,
+  c-width, c-height,
+  c-pix_fmt,
+  SCALE_FLAGS, NULL, NULL, NULL);
+if (!ost-sws_ctx) {
 fprintf(stderr,
 Cannot initialize the conversion context\n);
 exit(1);
 }
 }
 fill_yuv_image(ost-tmp_frame, frame_count, c-width, c-height);
-sws_scale(img_convert_ctx, ost-tmp_frame-data, 
ost-tmp_frame-linesize,
+sws_scale(ost-sws_ctx, ost-tmp_frame-data, 
ost-tmp_frame-linesize,
   0, c-height, ost-frame-data, ost-frame-linesize);
 } else {
 fill_yuv_image(ost-frame, frame_count, c-width, c-height);
@@ -401,6 +402,7 @@ static void close_stream(AVFormatContext *oc, OutputStream 
*ost)
 avcodec_close(ost-st-codec);
 av_frame_free(ost-frame);
 av_frame_free(ost-tmp_frame);
+sws_freeContext(ost-sws_ctx);
 }
 
 /**/

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] output example: use the new AVFrame API to allocate audio frames

2014-06-26 Thread Anton Khirnov
Module: libav
Branch: master
Commit: 5e7b125b6ae36893dfd9cb5661c99b67363cbb38

Author:Anton Khirnov an...@khirnov.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Tue Jun 24 07:51:18 2014 +0200

output example: use the new AVFrame API to allocate audio frames

---

 doc/examples/output.c |   43 ---
 1 file changed, 24 insertions(+), 19 deletions(-)

diff --git a/doc/examples/output.c b/doc/examples/output.c
index 3d14449..1f8ff96 100644
--- a/doc/examples/output.c
+++ b/doc/examples/output.c
@@ -59,7 +59,6 @@ typedef struct OutputStream {
 /* audio output */
 
 static float t, tincr, tincr2;
-static int16_t *samples;
 static int audio_input_frame_size;
 
 /*
@@ -122,20 +121,24 @@ static void open_audio(AVFormatContext *oc, AVStream *st)
 audio_input_frame_size = 1;
 else
 audio_input_frame_size = c-frame_size;
-samples = av_malloc(audio_input_frame_size *
-av_get_bytes_per_sample(c-sample_fmt) *
-c-channels);
 }
 
 /* Prepare a 16 bit dummy audio frame of 'frame_size' samples and
  * 'nb_channels' channels. */
-static void get_audio_frame(int16_t *samples, int frame_size, int nb_channels)
+static void get_audio_frame(AVFrame *frame, int nb_channels)
 {
-int j, i, v;
-int16_t *q;
+int j, i, v, ret;
+int16_t *q = (int16_t*)frame-data[0];
 
-q = samples;
-for (j = 0; j  frame_size; j++) {
+/* when we pass a frame to the encoder, it may keep a reference to it
+ * internally;
+ * make sure we do not overwrite it here
+ */
+ret = av_frame_make_writable(frame);
+if (ret  0)
+exit(1);
+
+for (j = 0; j  frame-nb_samples; j++) {
 v = (int)(sin(t) * 1);
 for (i = 0; i  nb_channels; i++)
 *q++ = v;
@@ -149,18 +152,22 @@ static void write_audio_frame(AVFormatContext *oc, 
AVStream *st)
 AVCodecContext *c;
 AVPacket pkt = { 0 }; // data and size must be 0;
 AVFrame *frame = av_frame_alloc();
-int got_packet;
+int got_packet, ret;
 
 av_init_packet(pkt);
 c = st-codec;
 
-get_audio_frame(samples, audio_input_frame_size, c-channels);
-frame-nb_samples = audio_input_frame_size;
-avcodec_fill_audio_frame(frame, c-channels, c-sample_fmt,
- (uint8_t *)samples,
- audio_input_frame_size *
- av_get_bytes_per_sample(c-sample_fmt) *
- c-channels, 1);
+frame-sample_rate= c-sample_rate;
+frame-nb_samples = audio_input_frame_size;
+frame-format = AV_SAMPLE_FMT_S16;
+frame-channel_layout = c-channel_layout;
+ret = av_frame_get_buffer(frame, 0);
+if (ret  0) {
+fprintf(stderr, Could not allocate an audio frame.\n);
+exit(1);
+}
+
+get_audio_frame(frame, c-channels);
 
 avcodec_encode_audio2(c, pkt, frame, got_packet);
 if (!got_packet)
@@ -179,8 +186,6 @@ static void write_audio_frame(AVFormatContext *oc, AVStream 
*st)
 static void close_audio(AVFormatContext *oc, AVStream *st)
 {
 avcodec_close(st-codec);
-
-av_free(samples);
 }
 
 /**/

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] output example: use a struct to bundle the video stream variables together

2014-06-26 Thread Anton Khirnov
Module: libav
Branch: master
Commit: 294daf71a7a1303b5ddd3cbefebed3b732d610f3

Author:Anton Khirnov an...@khirnov.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Sat Jun 21 17:17:40 2014 +0200

output example: use a struct to bundle the video stream variables together

---

 doc/examples/output.c |   93 ++---
 1 file changed, 50 insertions(+), 43 deletions(-)

diff --git a/doc/examples/output.c b/doc/examples/output.c
index 52b01d0..620be15 100644
--- a/doc/examples/output.c
+++ b/doc/examples/output.c
@@ -46,6 +46,14 @@
 
 static int sws_flags = SWS_BICUBIC;
 
+// a wrapper around a single output AVStream
+typedef struct OutputStream {
+AVStream *st;
+
+AVFrame *frame;
+AVFrame *tmp_frame;
+} OutputStream;
+
 /**/
 /* audio output */
 
@@ -176,14 +184,13 @@ static void close_audio(AVFormatContext *oc, AVStream *st)
 /**/
 /* video output */
 
-static AVFrame *picture, *tmp_picture;
 static int frame_count;
 
 /* Add a video output stream. */
-static AVStream *add_video_stream(AVFormatContext *oc, enum AVCodecID codec_id)
+static void add_video_stream(OutputStream *ost, AVFormatContext *oc,
+ enum AVCodecID codec_id)
 {
 AVCodecContext *c;
-AVStream *st;
 AVCodec *codec;
 
 /* find the video encoder */
@@ -193,13 +200,13 @@ static AVStream *add_video_stream(AVFormatContext *oc, 
enum AVCodecID codec_id)
 exit(1);
 }
 
-st = avformat_new_stream(oc, codec);
-if (!st) {
+ost-st = avformat_new_stream(oc, codec);
+if (!ost-st) {
 fprintf(stderr, Could not alloc stream\n);
 exit(1);
 }
 
-c = st-codec;
+c = ost-st-codec;
 
 /* Put sample parameters. */
 c-bit_rate = 40;
@@ -227,8 +234,6 @@ static AVStream *add_video_stream(AVFormatContext *oc, enum 
AVCodecID codec_id)
 /* Some formats want stream headers to be separate. */
 if (oc-oformat-flags  AVFMT_GLOBALHEADER)
 c-flags |= CODEC_FLAG_GLOBAL_HEADER;
-
-return st;
 }
 
 static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, int width, int 
height)
@@ -254,11 +259,11 @@ static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, 
int width, int height)
 return picture;
 }
 
-static void open_video(AVFormatContext *oc, AVStream *st)
+static void open_video(AVFormatContext *oc, OutputStream *ost)
 {
 AVCodecContext *c;
 
-c = st-codec;
+c = ost-st-codec;
 
 /* open the codec */
 if (avcodec_open2(c, NULL, NULL)  0) {
@@ -267,8 +272,8 @@ static void open_video(AVFormatContext *oc, AVStream *st)
 }
 
 /* Allocate the encoded raw picture. */
-picture = alloc_picture(c-pix_fmt, c-width, c-height);
-if (!picture) {
+ost-frame = alloc_picture(c-pix_fmt, c-width, c-height);
+if (!ost-frame) {
 fprintf(stderr, Could not allocate picture\n);
 exit(1);
 }
@@ -276,10 +281,10 @@ static void open_video(AVFormatContext *oc, AVStream *st)
 /* If the output format is not YUV420P, then a temporary YUV420P
  * picture is needed too. It is then converted to the required
  * output format. */
-tmp_picture = NULL;
+ost-tmp_frame = NULL;
 if (c-pix_fmt != AV_PIX_FMT_YUV420P) {
-tmp_picture = alloc_picture(AV_PIX_FMT_YUV420P, c-width, c-height);
-if (!tmp_picture) {
+ost-tmp_frame = alloc_picture(AV_PIX_FMT_YUV420P, c-width, 
c-height);
+if (!ost-tmp_frame) {
 fprintf(stderr, Could not allocate temporary picture\n);
 exit(1);
 }
@@ -316,13 +321,13 @@ static void fill_yuv_image(AVFrame *pict, int frame_index,
 }
 }
 
-static void write_video_frame(AVFormatContext *oc, AVStream *st)
+static void write_video_frame(AVFormatContext *oc, OutputStream *ost)
 {
 int ret;
 AVCodecContext *c;
 static struct SwsContext *img_convert_ctx;
 
-c = st-codec;
+c = ost-st-codec;
 
 if (frame_count = STREAM_NB_FRAMES) {
 /* No more frames to compress. The codec has a latency of a few
@@ -344,11 +349,11 @@ static void write_video_frame(AVFormatContext *oc, 
AVStream *st)
 exit(1);
 }
 }
-fill_yuv_image(tmp_picture, frame_count, c-width, c-height);
-sws_scale(img_convert_ctx, tmp_picture-data, 
tmp_picture-linesize,
-  0, c-height, picture-data, picture-linesize);
+fill_yuv_image(ost-tmp_frame, frame_count, c-width, c-height);
+sws_scale(img_convert_ctx, ost-tmp_frame-data, 
ost-tmp_frame-linesize,
+  0, c-height, ost-frame-data, ost-frame-linesize);
 } else {
-fill_yuv_image(picture, frame_count, c-width, c-height);
+fill_yuv_image(ost-frame, frame_count, c-width, c-height);
 }
 }
 
@@ -359,8 +364,8 @@ static void 

[libav-commits] output example: use the new AVFrame API for allocating the video frame

2014-06-26 Thread Anton Khirnov
Module: libav
Branch: master
Commit: 38d044429dabcd28928693240e955c6d4430cca9

Author:Anton Khirnov an...@khirnov.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Mon Jun 16 13:20:51 2014 +0200

output example: use the new AVFrame API for allocating the video frame

---

 doc/examples/output.c |   39 +++
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/doc/examples/output.c b/doc/examples/output.c
index 0239791..52b01d0 100644
--- a/doc/examples/output.c
+++ b/doc/examples/output.c
@@ -234,20 +234,23 @@ static AVStream *add_video_stream(AVFormatContext *oc, 
enum AVCodecID codec_id)
 static AVFrame *alloc_picture(enum AVPixelFormat pix_fmt, int width, int 
height)
 {
 AVFrame *picture;
-uint8_t *picture_buf;
-int size;
+int ret;
 
 picture = av_frame_alloc();
 if (!picture)
 return NULL;
-size= avpicture_get_size(pix_fmt, width, height);
-picture_buf = av_malloc(size);
-if (!picture_buf) {
-av_free(picture);
-return NULL;
+
+picture-format = pix_fmt;
+picture-width  = width;
+picture-height = height;
+
+/* allocate the buffers for the frame data */
+ret = av_frame_get_buffer(picture, 32);
+if (ret  0) {
+fprintf(stderr, Could not allocate frame data.\n);
+exit(1);
 }
-avpicture_fill((AVPicture *)picture, picture_buf,
-   pix_fmt, width, height);
+
 return picture;
 }
 
@@ -287,7 +290,15 @@ static void open_video(AVFormatContext *oc, AVStream *st)
 static void fill_yuv_image(AVFrame *pict, int frame_index,
int width, int height)
 {
-int x, y, i;
+int x, y, i, ret;
+
+/* when we pass a frame to the encoder, it may keep a reference to it
+ * internally;
+ * make sure we do not overwrite it here
+ */
+ret = av_frame_make_writable(pict);
+if (ret  0)
+exit(1);
 
 i = frame_index;
 
@@ -381,12 +392,8 @@ static void write_video_frame(AVFormatContext *oc, 
AVStream *st)
 static void close_video(AVFormatContext *oc, AVStream *st)
 {
 avcodec_close(st-codec);
-av_free(picture-data[0]);
-av_free(picture);
-if (tmp_picture) {
-av_free(tmp_picture-data[0]);
-av_free(tmp_picture);
-}
+av_frame_free(picture);
+av_frame_free(tmp_picture);
 }
 
 /**/

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] output example: rewrite encoding logic

2014-06-26 Thread Anton Khirnov
Module: libav
Branch: master
Commit: 182d3f8221c23716ea4eafa460bdb94968f71f26

Author:Anton Khirnov an...@khirnov.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Tue Jun 24 10:52:26 2014 +0200

output example: rewrite encoding logic

Properly generate pts for the frames sent to the encoder, avoid
using private and deprecated AVStream.pts.

---

 doc/examples/output.c |  183 -
 1 file changed, 106 insertions(+), 77 deletions(-)

diff --git a/doc/examples/output.c b/doc/examples/output.c
index d8321be..7c29df1 100644
--- a/doc/examples/output.c
+++ b/doc/examples/output.c
@@ -51,6 +51,9 @@
 typedef struct OutputStream {
 AVStream *st;
 
+/* pts of the next frame that will be generated */
+int64_t next_pts;
+
 AVFrame *frame;
 AVFrame *tmp_frame;
 
@@ -139,57 +142,72 @@ static void open_audio(AVFormatContext *oc, OutputStream 
*ost)
 
 /* Prepare a 16 bit dummy audio frame of 'frame_size' samples and
  * 'nb_channels' channels. */
-static void get_audio_frame(OutputStream *ost, AVFrame *frame, int nb_channels)
+static AVFrame *get_audio_frame(OutputStream *ost)
 {
 int j, i, v, ret;
-int16_t *q = (int16_t*)frame-data[0];
+int16_t *q = (int16_t*)ost-frame-data[0];
+
+/* check if we want to generate more frames */
+if (av_compare_ts(ost-next_pts, ost-st-codec-time_base,
+  STREAM_DURATION, (AVRational){ 1, 1 }) = 0)
+return NULL;
 
 /* when we pass a frame to the encoder, it may keep a reference to it
  * internally;
  * make sure we do not overwrite it here
  */
-ret = av_frame_make_writable(frame);
+ret = av_frame_make_writable(ost-frame);
 if (ret  0)
 exit(1);
 
-for (j = 0; j  frame-nb_samples; j++) {
+for (j = 0; j  ost-frame-nb_samples; j++) {
 v = (int)(sin(ost-t) * 1);
-for (i = 0; i  nb_channels; i++)
+for (i = 0; i  ost-st-codec-channels; i++)
 *q++ = v;
 ost-t += ost-tincr;
 ost-tincr += ost-tincr2;
 }
+
+ost-frame-pts = ost-next_pts;
+ost-next_pts  += ost-frame-nb_samples;
+
+return ost-frame;
 }
 
-static void write_audio_frame(AVFormatContext *oc, OutputStream *ost)
+/*
+ * encode one audio frame and send it to the muxer
+ * return 1 when encoding is finished, 0 otherwise
+ */
+static int write_audio_frame(AVFormatContext *oc, OutputStream *ost)
 {
 AVCodecContext *c;
 AVPacket pkt = { 0 }; // data and size must be 0;
-int got_packet, ret;
+AVFrame *frame;
+int got_packet;
 
 av_init_packet(pkt);
 c = ost-st-codec;
 
-get_audio_frame(ost, ost-frame, c-channels);
+frame = get_audio_frame(ost);
 
-avcodec_encode_audio2(c, pkt, ost-frame, got_packet);
-if (!got_packet)
-return;
+avcodec_encode_audio2(c, pkt, frame, got_packet);
 
-pkt.stream_index = ost-st-index;
+if (got_packet) {
+pkt.stream_index = ost-st-index;
 
-/* Write the compressed frame to the media file. */
-if (av_interleaved_write_frame(oc, pkt) != 0) {
-fprintf(stderr, Error while writing audio frame\n);
-exit(1);
+/* Write the compressed frame to the media file. */
+if (av_interleaved_write_frame(oc, pkt) != 0) {
+fprintf(stderr, Error while writing audio frame\n);
+exit(1);
+}
 }
+
+return (frame || got_packet) ? 0 : 1;
 }
 
 /**/
 /* video output */
 
-static int frame_count;
-
 /* Add a video output stream. */
 static void add_video_stream(OutputStream *ost, AVFormatContext *oc,
  enum AVCodecID codec_id)
@@ -325,76 +343,99 @@ static void fill_yuv_image(AVFrame *pict, int frame_index,
 }
 }
 
-static void write_video_frame(AVFormatContext *oc, OutputStream *ost)
+static AVFrame *get_video_frame(OutputStream *ost)
 {
-int ret;
-AVCodecContext *c;
+AVCodecContext *c = ost-st-codec;
 
-c = ost-st-codec;
+/* check if we want to generate more frames */
+if (av_compare_ts(ost-next_pts, ost-st-codec-time_base,
+  STREAM_DURATION, (AVRational){ 1, 1 }) = 0)
+return NULL;
 
-if (frame_count = STREAM_NB_FRAMES) {
-/* No more frames to compress. The codec has a latency of a few
- * frames if using B-frames, so we get the last frames by
- * passing the same picture again. */
-} else {
-if (c-pix_fmt != AV_PIX_FMT_YUV420P) {
-/* as we only generate a YUV420P picture, we must convert it
- * to the codec pixel format if needed */
+if (c-pix_fmt != AV_PIX_FMT_YUV420P) {
+/* as we only generate a YUV420P picture, we must convert it
+ * to the codec pixel format if needed */
+if (!ost-sws_ctx) {
+ost-sws_ctx = sws_getContext(c-width, c-height,
+  AV_PIX_FMT_YUV420P,
+

[libav-commits] output example: use OutputStream for audio streams as well

2014-06-26 Thread Anton Khirnov
Module: libav
Branch: master
Commit: edd5f957646dcbf1bb55718bc7bf1e5481c25bcb

Author:Anton Khirnov an...@khirnov.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Tue Jun 24 08:56:27 2014 +0200

output example: use OutputStream for audio streams as well

---

 doc/examples/output.c |   81 -
 1 file changed, 39 insertions(+), 42 deletions(-)

diff --git a/doc/examples/output.c b/doc/examples/output.c
index 1f8ff96..768f1b6 100644
--- a/doc/examples/output.c
+++ b/doc/examples/output.c
@@ -53,21 +53,21 @@ typedef struct OutputStream {
 
 AVFrame *frame;
 AVFrame *tmp_frame;
+
+float t, tincr, tincr2;
+int audio_input_frame_size;
 } OutputStream;
 
 /**/
 /* audio output */
 
-static float t, tincr, tincr2;
-static int audio_input_frame_size;
-
 /*
  * add an audio output stream
  */
-static AVStream *add_audio_stream(AVFormatContext *oc, enum AVCodecID codec_id)
+static void add_audio_stream(OutputStream *ost, AVFormatContext *oc,
+ enum AVCodecID codec_id)
 {
 AVCodecContext *c;
-AVStream *st;
 AVCodec *codec;
 
 /* find the audio encoder */
@@ -77,13 +77,13 @@ static AVStream *add_audio_stream(AVFormatContext *oc, enum 
AVCodecID codec_id)
 exit(1);
 }
 
-st = avformat_new_stream(oc, codec);
-if (!st) {
+ost-st = avformat_new_stream(oc, codec);
+if (!ost-st) {
 fprintf(stderr, Could not alloc stream\n);
 exit(1);
 }
 
-c = st-codec;
+c = ost-st-codec;
 
 /* put sample parameters */
 c-sample_fmt  = AV_SAMPLE_FMT_S16;
@@ -95,15 +95,13 @@ static AVStream *add_audio_stream(AVFormatContext *oc, enum 
AVCodecID codec_id)
 // some formats want stream headers to be separate
 if (oc-oformat-flags  AVFMT_GLOBALHEADER)
 c-flags |= CODEC_FLAG_GLOBAL_HEADER;
-
-return st;
 }
 
-static void open_audio(AVFormatContext *oc, AVStream *st)
+static void open_audio(AVFormatContext *oc, OutputStream *ost)
 {
 AVCodecContext *c;
 
-c = st-codec;
+c = ost-st-codec;
 
 /* open it */
 if (avcodec_open2(c, NULL, NULL)  0) {
@@ -112,20 +110,20 @@ static void open_audio(AVFormatContext *oc, AVStream *st)
 }
 
 /* init signal generator */
-t = 0;
-tincr = 2 * M_PI * 110.0 / c-sample_rate;
+ost-t = 0;
+ost-tincr = 2 * M_PI * 110.0 / c-sample_rate;
 /* increment frequency by 110 Hz per second */
-tincr2 = 2 * M_PI * 110.0 / c-sample_rate / c-sample_rate;
+ost-tincr2 = 2 * M_PI * 110.0 / c-sample_rate / c-sample_rate;
 
 if (c-codec-capabilities  CODEC_CAP_VARIABLE_FRAME_SIZE)
-audio_input_frame_size = 1;
+ost-audio_input_frame_size = 1;
 else
-audio_input_frame_size = c-frame_size;
+ost-audio_input_frame_size = c-frame_size;
 }
 
 /* Prepare a 16 bit dummy audio frame of 'frame_size' samples and
  * 'nb_channels' channels. */
-static void get_audio_frame(AVFrame *frame, int nb_channels)
+static void get_audio_frame(OutputStream *ost, AVFrame *frame, int nb_channels)
 {
 int j, i, v, ret;
 int16_t *q = (int16_t*)frame-data[0];
@@ -139,15 +137,15 @@ static void get_audio_frame(AVFrame *frame, int 
nb_channels)
 exit(1);
 
 for (j = 0; j  frame-nb_samples; j++) {
-v = (int)(sin(t) * 1);
+v = (int)(sin(ost-t) * 1);
 for (i = 0; i  nb_channels; i++)
 *q++ = v;
-t += tincr;
-tincr += tincr2;
+ost-t += ost-tincr;
+ost-tincr += ost-tincr2;
 }
 }
 
-static void write_audio_frame(AVFormatContext *oc, AVStream *st)
+static void write_audio_frame(AVFormatContext *oc, OutputStream *ost)
 {
 AVCodecContext *c;
 AVPacket pkt = { 0 }; // data and size must be 0;
@@ -155,10 +153,10 @@ static void write_audio_frame(AVFormatContext *oc, 
AVStream *st)
 int got_packet, ret;
 
 av_init_packet(pkt);
-c = st-codec;
+c = ost-st-codec;
 
 frame-sample_rate= c-sample_rate;
-frame-nb_samples = audio_input_frame_size;
+frame-nb_samples = ost-audio_input_frame_size;
 frame-format = AV_SAMPLE_FMT_S16;
 frame-channel_layout = c-channel_layout;
 ret = av_frame_get_buffer(frame, 0);
@@ -167,13 +165,13 @@ static void write_audio_frame(AVFormatContext *oc, 
AVStream *st)
 exit(1);
 }
 
-get_audio_frame(frame, c-channels);
+get_audio_frame(ost, frame, c-channels);
 
 avcodec_encode_audio2(c, pkt, frame, got_packet);
 if (!got_packet)
 return;
 
-pkt.stream_index = st-index;
+pkt.stream_index = ost-st-index;
 
 /* Write the compressed frame to the media file. */
 if (av_interleaved_write_frame(oc, pkt) != 0) {
@@ -183,9 +181,9 @@ static void write_audio_frame(AVFormatContext *oc, AVStream 
*st)
 av_frame_free(frame);
 }
 
-static void close_audio(AVFormatContext *oc, 

[libav-commits] output example: allocate the audio frame only once

2014-06-26 Thread Anton Khirnov
Module: libav
Branch: master
Commit: 63fd0d866c8300a8f251a15b1535e9ce40a407fb

Author:Anton Khirnov an...@khirnov.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Tue Jun 24 09:02:25 2014 +0200

output example: allocate the audio frame only once

---

 doc/examples/output.c |   49 +++--
 1 file changed, 23 insertions(+), 26 deletions(-)

diff --git a/doc/examples/output.c b/doc/examples/output.c
index 768f1b6..36b4229 100644
--- a/doc/examples/output.c
+++ b/doc/examples/output.c
@@ -55,7 +55,6 @@ typedef struct OutputStream {
 AVFrame *tmp_frame;
 
 float t, tincr, tincr2;
-int audio_input_frame_size;
 } OutputStream;
 
 /**/
@@ -100,6 +99,7 @@ static void add_audio_stream(OutputStream *ost, 
AVFormatContext *oc,
 static void open_audio(AVFormatContext *oc, OutputStream *ost)
 {
 AVCodecContext *c;
+int ret;
 
 c = ost-st-codec;
 
@@ -115,10 +115,24 @@ static void open_audio(AVFormatContext *oc, OutputStream 
*ost)
 /* increment frequency by 110 Hz per second */
 ost-tincr2 = 2 * M_PI * 110.0 / c-sample_rate / c-sample_rate;
 
+ost-frame = av_frame_alloc();
+if (!ost-frame)
+exit(1);
+
+ost-frame-sample_rate= c-sample_rate;
+ost-frame-format = AV_SAMPLE_FMT_S16;
+ost-frame-channel_layout = c-channel_layout;
+
 if (c-codec-capabilities  CODEC_CAP_VARIABLE_FRAME_SIZE)
-ost-audio_input_frame_size = 1;
+ost-frame-nb_samples = 1;
 else
-ost-audio_input_frame_size = c-frame_size;
+ost-frame-nb_samples = c-frame_size;
+
+ret = av_frame_get_buffer(ost-frame, 0);
+if (ret  0) {
+fprintf(stderr, Could not allocate an audio frame.\n);
+exit(1);
+}
 }
 
 /* Prepare a 16 bit dummy audio frame of 'frame_size' samples and
@@ -149,25 +163,14 @@ static void write_audio_frame(AVFormatContext *oc, 
OutputStream *ost)
 {
 AVCodecContext *c;
 AVPacket pkt = { 0 }; // data and size must be 0;
-AVFrame *frame = av_frame_alloc();
 int got_packet, ret;
 
 av_init_packet(pkt);
 c = ost-st-codec;
 
-frame-sample_rate= c-sample_rate;
-frame-nb_samples = ost-audio_input_frame_size;
-frame-format = AV_SAMPLE_FMT_S16;
-frame-channel_layout = c-channel_layout;
-ret = av_frame_get_buffer(frame, 0);
-if (ret  0) {
-fprintf(stderr, Could not allocate an audio frame.\n);
-exit(1);
-}
-
-get_audio_frame(ost, frame, c-channels);
+get_audio_frame(ost, ost-frame, c-channels);
 
-avcodec_encode_audio2(c, pkt, frame, got_packet);
+avcodec_encode_audio2(c, pkt, ost-frame, got_packet);
 if (!got_packet)
 return;
 
@@ -178,12 +181,6 @@ static void write_audio_frame(AVFormatContext *oc, 
OutputStream *ost)
 fprintf(stderr, Error while writing audio frame\n);
 exit(1);
 }
-av_frame_free(frame);
-}
-
-static void close_audio(AVFormatContext *oc, OutputStream *ost)
-{
-avcodec_close(ost-st-codec);
 }
 
 /**/
@@ -399,7 +396,7 @@ static void write_video_frame(AVFormatContext *oc, 
OutputStream *ost)
 frame_count++;
 }
 
-static void close_video(AVFormatContext *oc, OutputStream *ost)
+static void close_stream(AVFormatContext *oc, OutputStream *ost)
 {
 avcodec_close(ost-st-codec);
 av_frame_free(ost-frame);
@@ -411,7 +408,7 @@ static void close_video(AVFormatContext *oc, OutputStream 
*ost)
 
 int main(int argc, char **argv)
 {
-OutputStream video_st, audio_st;
+OutputStream video_st = { 0 }, audio_st = { 0 };
 const char *filename;
 AVOutputFormat *fmt;
 AVFormatContext *oc;
@@ -517,9 +514,9 @@ int main(int argc, char **argv)
 
 /* Close each codec. */
 if (have_video)
-close_video(oc, video_st);
+close_stream(oc, video_st);
 if (have_audio)
-close_audio(oc, audio_st);
+close_stream(oc, audio_st);
 
 /* Free the streams. */
 for (i = 0; i  oc-nb_streams; i++) {

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] indeo2: rename stride to pitch for consistency with other Indeo decoders

2014-06-26 Thread Kostya Shishkov
Module: libav
Branch: master
Commit: 422e14f721c22cf9c19a8e7aae051ba9d559f6b6

Author:Kostya Shishkov kostya.shish...@gmail.com
Committer: Kostya Shishkov kostya.shish...@gmail.com
Date:  Wed Jun 25 20:28:22 2014 +0200

indeo2: rename stride to pitch for consistency with other Indeo decoders

---

 libavcodec/indeo2.c |   16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c
index 7df6e69..4221e9e 100644
--- a/libavcodec/indeo2.c
+++ b/libavcodec/indeo2.c
@@ -49,7 +49,7 @@ static inline int ir2_get_code(GetBitContext *gb)
 }
 
 static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t 
*dst,
-int stride, const uint8_t *table)
+int pitch, const uint8_t *table)
 {
 int i;
 int j;
@@ -74,7 +74,7 @@ static int ir2_decode_plane(Ir2Context *ctx, int width, int 
height, uint8_t *dst
 dst[out++] = table[(c * 2) + 1];
 }
 }
-dst += stride;
+dst += pitch;
 
 for (j = 1; j  height; j++) {
 out = 0;
@@ -85,27 +85,27 @@ static int ir2_decode_plane(Ir2Context *ctx, int width, int 
height, uint8_t *dst
 if (out + c*2  width)
 return AVERROR_INVALIDDATA;
 for (i = 0; i  c * 2; i++) {
-dst[out] = dst[out - stride];
+dst[out] = dst[out - pitch];
 out++;
 }
 } else { /* add two deltas from table */
-t= dst[out - stride] + (table[c * 2] - 128);
+t= dst[out - pitch] + (table[c * 2] - 128);
 t= av_clip_uint8(t);
 dst[out] = t;
 out++;
-t= dst[out - stride] + (table[(c * 2) + 1] - 128);
+t= dst[out - pitch] + (table[(c * 2) + 1] - 128);
 t= av_clip_uint8(t);
 dst[out] = t;
 out++;
 }
 }
-dst += stride;
+dst += pitch;
 }
 return 0;
 }
 
 static int ir2_decode_plane_inter(Ir2Context *ctx, int width, int height, 
uint8_t *dst,
-  int stride, const uint8_t *table)
+  int pitch, const uint8_t *table)
 {
 int j;
 int out = 0;
@@ -133,7 +133,7 @@ static int ir2_decode_plane_inter(Ir2Context *ctx, int 
width, int height, uint8_
 out++;
 }
 }
-dst += stride;
+dst += pitch;
 }
 return 0;
 }

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] indeo4: B-frames decoding

2014-06-26 Thread Dirk Ausserhaus
Module: libav
Branch: master
Commit: 5ec6d152e26c570c0a16ec72c1f354db95708179

Author:Dirk Ausserhaus dausserh...@gmail.com
Committer: Kostya Shishkov kostya.shish...@gmail.com
Date:  Sun Jun  8 13:44:17 2014 +0200

indeo4: B-frames decoding

Signed-off-by: Kostya Shishkov kostya.shish...@gmail.com

---

 libavcodec/indeo4.c |   49 -
 libavcodec/indeo5.c |4 +-
 libavcodec/ivi_common.c |  138 ---
 libavcodec/ivi_common.h |   14 +++--
 libavcodec/ivi_dsp.c|   43 ---
 libavcodec/ivi_dsp.h|   48 +
 6 files changed, 238 insertions(+), 58 deletions(-)

diff --git a/libavcodec/indeo4.c b/libavcodec/indeo4.c
index 6893077..35f266e 100644
--- a/libavcodec/indeo4.c
+++ b/libavcodec/indeo4.c
@@ -194,7 +194,7 @@ static int decode_pic_hdr(IVI45DecContext *ctx, 
AVCodecContext *avctx)
 
 /* check if picture layout was changed and reallocate buffers */
 if (ivi_pic_config_cmp(pic_conf, ctx-pic_conf)) {
-if (ff_ivi_init_planes(ctx-planes, pic_conf)) {
+if (ff_ivi_init_planes(ctx-planes, pic_conf, 1)) {
 av_log(avctx, AV_LOG_ERROR, Couldn't reallocate color planes!\n);
 ctx-pic_conf.luma_bands = 0;
 return AVERROR(ENOMEM);
@@ -462,6 +462,8 @@ static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc 
*band,
 mb-xpos = x;
 mb-ypos = y;
 mb-buf_offs = mb_offset;
+mb-b_mv_x   =
+mb-b_mv_y   = 0;
 
 if (get_bits1(ctx-gb)) {
 if (ctx-frame_type == IVI4_FRAMETYPE_INTRA) {
@@ -537,6 +539,24 @@ static int decode_mb_info(IVI45DecContext *ctx, 
IVIBandDesc *band,
 mv_x += IVI_TOSIGNED(mv_delta);
 mb-mv_x = mv_x;
 mb-mv_y = mv_y;
+if (mb-type == 3) {
+mv_delta = get_vlc2(ctx-gb,
+ctx-mb_vlc.tab-table,
+IVI_VLC_BITS, 1);
+mv_y += IVI_TOSIGNED(mv_delta);
+mv_delta = get_vlc2(ctx-gb,
+ctx-mb_vlc.tab-table,
+IVI_VLC_BITS, 1);
+mv_x += IVI_TOSIGNED(mv_delta);
+mb-b_mv_x = -mv_x;
+mb-b_mv_y = -mv_y;
+}
+}
+if (mb-type == 2) {
+mb-b_mv_x = -mb-mv_x;
+mb-b_mv_y = -mb-mv_y;
+mb-mv_x = 0;
+mb-mv_y = 0;
 }
 }
 }
@@ -563,32 +583,30 @@ static int decode_mb_info(IVI45DecContext *ctx, 
IVIBandDesc *band,
  */
 static void switch_buffers(IVI45DecContext *ctx)
 {
+int is_prev_ref = 0, is_ref = 0;
+
 switch (ctx-prev_frame_type) {
 case IVI4_FRAMETYPE_INTRA:
 case IVI4_FRAMETYPE_INTRA1:
 case IVI4_FRAMETYPE_INTER:
-ctx-buf_switch ^= 1;
-ctx-dst_buf = ctx-buf_switch;
-ctx-ref_buf = ctx-buf_switch ^ 1;
-break;
-case IVI4_FRAMETYPE_INTER_NOREF:
+is_prev_ref = 1;
 break;
 }
 
 switch (ctx-frame_type) {
 case IVI4_FRAMETYPE_INTRA:
 case IVI4_FRAMETYPE_INTRA1:
-ctx-buf_switch = 0;
-/* FALLTHROUGH */
 case IVI4_FRAMETYPE_INTER:
-ctx-dst_buf = ctx-buf_switch;
-ctx-ref_buf = ctx-buf_switch ^ 1;
-break;
-case IVI4_FRAMETYPE_INTER_NOREF:
-case IVI4_FRAMETYPE_NULL_FIRST:
-case IVI4_FRAMETYPE_NULL_LAST:
+is_ref = 1;
 break;
 }
+
+if (is_prev_ref  is_ref) {
+FFSWAP(int, ctx-dst_buf, ctx-ref_buf);
+} else if (is_prev_ref) {
+FFSWAP(int, ctx-ref_buf, ctx-b_ref_buf);
+FFSWAP(int, ctx-dst_buf, ctx-ref_buf);
+}
 }
 
 
@@ -622,6 +640,9 @@ static av_cold int decode_init(AVCodecContext *avctx)
 
 ctx-is_indeo4 = 1;
 
+ctx-dst_buf   = 0;
+ctx-ref_buf   = 1;
+ctx-b_ref_buf = 3; /* buffer 2 is used for scalability mode */
 ctx-p_frame = av_frame_alloc();
 if (!ctx-p_frame)
 return AVERROR(ENOMEM);
diff --git a/libavcodec/indeo5.c b/libavcodec/indeo5.c
index 2465ce6..5a112f9 100644
--- a/libavcodec/indeo5.c
+++ b/libavcodec/indeo5.c
@@ -113,7 +113,7 @@ static int decode_gop_header(IVI45DecContext *ctx, 
AVCodecContext *avctx)
 
 /* check if picture layout was changed and reallocate buffers */
 if (ivi_pic_config_cmp(pic_conf, ctx-pic_conf) || ctx-gop_invalid) {
-result = ff_ivi_init_planes(ctx-planes, pic_conf);
+result = ff_ivi_init_planes(ctx-planes, pic_conf, 0);
 if (result  0) {
 av_log(avctx, AV_LOG_ERROR, Couldn't reallocate color planes!\n);
 return result;

[libav-commits] fate: Add dependencies for dct/fft/mdct/rdft tests

2014-06-26 Thread Diego Biurrun
Module: libav
Branch: master
Commit: 24f45c16224d4c5d482e928676714766ffdda4fc

Author:Diego Biurrun di...@biurrun.de
Committer: Diego Biurrun di...@biurrun.de
Date:  Wed Jun 25 17:09:13 2014 -0700

fate: Add dependencies for dct/fft/mdct/rdft tests

---

 libavcodec/fft-test.c |   22 ++
 tests/fate/fft.mak|   32 
 2 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/libavcodec/fft-test.c b/libavcodec/fft-test.c
index d0c22d0..142a61d 100644
--- a/libavcodec/fft-test.c
+++ b/libavcodec/fft-test.c
@@ -113,6 +113,7 @@ static void fft_ref(FFTComplex *tabr, FFTComplex *tab, int 
nbits)
 }
 }
 
+#if CONFIG_MDCT
 static void imdct_ref(FFTSample *out, FFTSample *in, int nbits)
 {
 int n = 1nbits;
@@ -147,8 +148,10 @@ static void mdct_ref(FFTSample *output, FFTSample *input, 
int nbits)
 output[k] = REF_SCALE(s, nbits - 1);
 }
 }
+#endif /* CONFIG_MDCT */
 
 #if FFT_FLOAT
+#if CONFIG_DCT
 static void idct_ref(float *output, float *input, int nbits)
 {
 int n = 1nbits;
@@ -181,6 +184,7 @@ static void dct_ref(float *output, float *input, int nbits)
 output[k] = s;
 }
 }
+#endif /* CONFIG_DCT */
 #endif
 
 
@@ -304,6 +308,7 @@ int main(int argc, char **argv)
 tab2 = av_malloc(fft_size * sizeof(FFTSample));
 
 switch (transform) {
+#if CONFIG_MDCT
 case TRANSFORM_MDCT:
 av_log(NULL, AV_LOG_INFO,Scale factor is set to %f\n, scale);
 if (do_inverse)
@@ -312,6 +317,7 @@ int main(int argc, char **argv)
 av_log(NULL, AV_LOG_INFO,MDCT);
 ff_mdct_init(m, fft_nbits, do_inverse, scale);
 break;
+#endif /* CONFIG_MDCT */
 case TRANSFORM_FFT:
 if (do_inverse)
 av_log(NULL, AV_LOG_INFO,IFFT);
@@ -321,6 +327,7 @@ int main(int argc, char **argv)
 fft_ref_init(fft_nbits, do_inverse);
 break;
 #if FFT_FLOAT
+#if CONFIG_RDFT
 case TRANSFORM_RDFT:
 if (do_inverse)
 av_log(NULL, AV_LOG_INFO,IDFT_C2R);
@@ -329,6 +336,8 @@ int main(int argc, char **argv)
 ff_rdft_init(r, fft_nbits, do_inverse ? IDFT_C2R : DFT_R2C);
 fft_ref_init(fft_nbits, do_inverse);
 break;
+#endif /* CONFIG_RDFT */
+#if CONFIG_DCT
 case TRANSFORM_DCT:
 if (do_inverse)
 av_log(NULL, AV_LOG_INFO,DCT_III);
@@ -336,6 +345,7 @@ int main(int argc, char **argv)
 av_log(NULL, AV_LOG_INFO,DCT_II);
 ff_dct_init(d, fft_nbits, do_inverse ? DCT_III : DCT_II);
 break;
+#endif /* CONFIG_DCT */
 #endif
 default:
 av_log(NULL, AV_LOG_ERROR, Requested transform not supported\n);
@@ -354,6 +364,7 @@ int main(int argc, char **argv)
 av_log(NULL, AV_LOG_INFO,Checking...\n);
 
 switch (transform) {
+#if CONFIG_MDCT
 case TRANSFORM_MDCT:
 if (do_inverse) {
 imdct_ref((FFTSample *)tab_ref, (FFTSample *)tab1, fft_nbits);
@@ -367,6 +378,7 @@ int main(int argc, char **argv)
 err = check_diff((FFTSample *)tab_ref, tab2, fft_size / 2, scale);
 }
 break;
+#endif /* CONFIG_MDCT */
 case TRANSFORM_FFT:
 memcpy(tab, tab1, fft_size * sizeof(FFTComplex));
 s-fft_permute(s, tab);
@@ -376,6 +388,7 @@ int main(int argc, char **argv)
 err = check_diff((FFTSample *)tab_ref, (FFTSample *)tab, fft_size * 2, 
1.0);
 break;
 #if FFT_FLOAT
+#if CONFIG_RDFT
 case TRANSFORM_RDFT:
 fft_size_2 = fft_size  1;
 if (do_inverse) {
@@ -407,6 +420,8 @@ int main(int argc, char **argv)
 err = check_diff((float *)tab_ref, (float *)tab2, fft_size, 1.0);
 }
 break;
+#endif /* CONFIG_RDFT */
+#if CONFIG_DCT
 case TRANSFORM_DCT:
 memcpy(tab, tab1, fft_size * sizeof(FFTComplex));
 d-dct_calc(d, tab);
@@ -417,6 +432,7 @@ int main(int argc, char **argv)
 }
 err = check_diff((float *)tab_ref, (float *)tab, fft_size, 1.0);
 break;
+#endif /* CONFIG_DCT */
 #endif
 }
 
@@ -468,19 +484,25 @@ int main(int argc, char **argv)
 }
 
 switch (transform) {
+#if CONFIG_MDCT
 case TRANSFORM_MDCT:
 ff_mdct_end(m);
 break;
+#endif /* CONFIG_MDCT */
 case TRANSFORM_FFT:
 ff_fft_end(s);
 break;
 #if FFT_FLOAT
+#if CONFIG_RDFT
 case TRANSFORM_RDFT:
 ff_rdft_end(r);
 break;
+#endif /* CONFIG_RDFT */
+#if CONFIG_DCT
 case TRANSFORM_DCT:
 ff_dct_end(d);
 break;
+#endif /* CONFIG_DCT */
 #endif
 }
 
diff --git a/tests/fate/fft.mak b/tests/fate/fft.mak
index 20d5638..d2a3904 100644
--- a/tests/fate/fft.mak
+++ b/tests/fate/fft.mak
@@ -1,8 +1,8 @@
 define DEF_FFT
-FATE_FFT += fate-fft-$(1)   fate-ifft-$(1)   \
-fate-mdct-$(1)  fate-imdct-$(1)  \
-fate-rdft-$(1)  fate-irdft-$(1)  \
-fate-dct1d-$(1) fate-idct1d-$(1)
+FATE_FFT-$(CONFIG_DCT)  += fate-dct1d-$(1) fate-idct1d-$(1)
+FATE_FFT-$(CONFIG_FFT)  += fate-fft-$(1)   

[libav-commits] dsputil: Move MMX/SSE2-optimized IDCT bits to the x86 subdirectory

2014-06-26 Thread Diego Biurrun
Module: libav
Branch: master
Commit: d2869aea0494d3a20d53d5034cd41dbb488eb133

Author:Diego Biurrun di...@biurrun.de
Committer: Diego Biurrun di...@biurrun.de
Date:  Thu Jan 23 17:25:16 2014 +0100

dsputil: Move MMX/SSE2-optimized IDCT bits to the x86 subdirectory

---

 libavcodec/dsputil.c  |   27 +--
 libavcodec/dsputil.h  |2 ++
 libavcodec/x86/dsputil_init.c |   33 +
 3 files changed, 40 insertions(+), 22 deletions(-)

diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
index 5d706bd..ca0c8ef 100644
--- a/libavcodec/dsputil.c
+++ b/libavcodec/dsputil.c
@@ -48,20 +48,6 @@ uint32_t ff_square_tab[512] = { 0, };
 #define BIT_DEPTH 8
 #include dsputilenc_template.c
 
-/* Input permutation for the simple_idct_mmx */
-static const uint8_t simple_mmx_permutation[64] = {
-0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
-0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
-0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
-0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F,
-0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F,
-0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D,
-0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
-0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
-};
-
-static const uint8_t idct_sse2_row_perm[8] = { 0, 4, 1, 5, 2, 6, 3, 7 };
-
 av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st,
const uint8_t *src_scantable)
 {
@@ -88,6 +74,11 @@ av_cold void ff_init_scantable_permutation(uint8_t 
*idct_permutation,
 {
 int i;
 
+if (ARCH_X86)
+if (ff_init_scantable_permutation_x86(idct_permutation,
+  idct_permutation_type))
+return;
+
 switch (idct_permutation_type) {
 case FF_NO_IDCT_PERM:
 for (i = 0; i  64; i++)
@@ -97,10 +88,6 @@ av_cold void ff_init_scantable_permutation(uint8_t 
*idct_permutation,
 for (i = 0; i  64; i++)
 idct_permutation[i] = (i  0x38) | ((i  6)  1) | ((i  1)  2);
 break;
-case FF_SIMPLE_IDCT_PERM:
-for (i = 0; i  64; i++)
-idct_permutation[i] = simple_mmx_permutation[i];
-break;
 case FF_TRANSPOSE_IDCT_PERM:
 for (i = 0; i  64; i++)
 idct_permutation[i] = ((i  7)  3) | (i  3);
@@ -109,10 +96,6 @@ av_cold void ff_init_scantable_permutation(uint8_t 
*idct_permutation,
 for (i = 0; i  64; i++)
 idct_permutation[i] = (i  0x24) | ((i  3)  3) | ((i  3)  3);
 break;
-case FF_SSE2_IDCT_PERM:
-for (i = 0; i  64; i++)
-idct_permutation[i] = (i  0x38) | idct_sse2_row_perm[i  7];
-break;
 default:
 av_log(NULL, AV_LOG_ERROR,
Internal error, IDCT permutation not set\n);
diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
index 1dbc784..b271dcc 100644
--- a/libavcodec/dsputil.h
+++ b/libavcodec/dsputil.h
@@ -57,6 +57,8 @@ void ff_init_scantable(uint8_t *permutation, ScanTable *st,
const uint8_t *src_scantable);
 void ff_init_scantable_permutation(uint8_t *idct_permutation,
int idct_permutation_type);
+int ff_init_scantable_permutation_x86(uint8_t *idct_permutation,
+  int idct_permutation_type);
 
 /**
  * DSPContext.
diff --git a/libavcodec/x86/dsputil_init.c b/libavcodec/x86/dsputil_init.c
index 90e6271..74dab48 100644
--- a/libavcodec/x86/dsputil_init.c
+++ b/libavcodec/x86/dsputil_init.c
@@ -26,6 +26,39 @@
 #include dsputil_x86.h
 #include idct_xvid.h
 
+/* Input permutation for the simple_idct_mmx */
+static const uint8_t simple_mmx_permutation[64] = {
+0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
+0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
+0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
+0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F,
+0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F,
+0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D,
+0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
+0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
+};
+
+static const uint8_t idct_sse2_row_perm[8] = { 0, 4, 1, 5, 2, 6, 3, 7 };
+
+av_cold int ff_init_scantable_permutation_x86(uint8_t *idct_permutation,
+  int idct_permutation_type)
+{
+int i;
+
+switch (idct_permutation_type) {
+case FF_SIMPLE_IDCT_PERM:
+for (i = 0; i  64; i++)
+idct_permutation[i] = simple_mmx_permutation[i];
+return 1;
+case FF_SSE2_IDCT_PERM:
+for (i = 0; i  64; i++)
+idct_permutation[i] = (i  0x38) | idct_sse2_row_perm[i  7];
+return 1;
+}
+
+return 0;
+}
+
 static av_cold void dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx,
  int cpu_flags, unsigned high_bit_depth)
 {

___

[libav-commits] Update Changelog for v10.2

2014-06-26 Thread Reinhard Tartler
Module: libav
Branch: release/10
Commit: 52dd1a933ed4717fa577ec516ce9e65075a5a04d

Author:Reinhard Tartler siret...@tauware.de
Committer: Reinhard Tartler siret...@tauware.de
Date:  Thu Jun 26 21:11:20 2014 -0400

Update Changelog for v10.2

---

 Changelog |   13 +
 1 file changed, 13 insertions(+)

diff --git a/Changelog b/Changelog
index 30e63c9..566de4b 100644
--- a/Changelog
+++ b/Changelog
@@ -1,6 +1,19 @@
 Entries are sorted chronologically from oldest to youngest within each release,
 releases are sorted from youngest to oldest.
 
+version 10.2:
+- adpcm: Write the proper predictor in trellis mode in IMA QT
+- adpcm: Avoid reading out of bounds in the IMA QT trellis encoder
+- oggenc: Set the right AVOption size for the pref_duration option
+- avpacket: fix copying side data in av_packet_copy_props()
+- jpeg2000: fix dereferencing invalid pointers during cleanup
+- Check mp3 header before calling avpriv_mpegaudio_decode_header() (bug/705)
+- Check if an mp3 header is using a reserved sample rate
+- lzo: Handle integer overflow (bug/704)
+- avconv: make -shortest work with streamcopy
+- ppc: Fix compilation for ppc64le (ELFv2) (ubuntu/1263802)
+- aarch64: Use the correct syntax for relocations (debian/751856, 
ubuntu/1323144)
+
 version 10.1:
 - pcm-dvd: Fix 20bit decoding (bug/592)
 - avi: Improve non-interleaved detection (bug/666)

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] Prepare for 10.2 Release

2014-06-26 Thread Reinhard Tartler
Module: libav
Branch: release/10
Commit: 40dd29653ab85812d21fa64e9a665ceb316701ad

Author:Reinhard Tartler siret...@tauware.de
Committer: Reinhard Tartler siret...@tauware.de
Date:  Thu Jun 26 21:14:55 2014 -0400

Prepare for 10.2 Release

---

 RELEASE |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/RELEASE b/RELEASE
index ae425d6..e2498ea 100644
--- a/RELEASE
+++ b/RELEASE
@@ -1 +1 @@
-10.1
+10.2

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] Update Changelog for v9.14

2014-06-26 Thread Reinhard Tartler
Module: libav
Branch: release/9
Commit: 3ecbd911ff9177097820e5d00401c9bf29e5d167

Author:Reinhard Tartler siret...@tauware.de
Committer: Reinhard Tartler siret...@tauware.de
Date:  Thu Jun 26 21:27:56 2014 -0400

Update Changelog for v9.14

---

 Changelog |8 
 1 file changed, 8 insertions(+)

diff --git a/Changelog b/Changelog
index 8a74804..b23f5ef 100644
--- a/Changelog
+++ b/Changelog
@@ -1,5 +1,13 @@
 Releases are sorted from youngest to oldest.
 
+version 9.14:
+- adpcm: Write the proper predictor in trellis mode in IMA QT
+- adpcm: Avoid reading out of bounds in the IMA QT trellis encoder
+- Check mp3 header before calling avpriv_mpegaudio_decode_header() (bug/705)
+- Check if an mp3 header is using a reserved sample rate
+- lzo: Handle integer overflow (bug/704)
+- avconv: make -shortest work with streamcopy
+
 Version 9.13:
 - swscale: Fix an undefined behaviour
 - matroska: add the Opus mapping

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] Prepare for 9.14 Release

2014-06-26 Thread Reinhard Tartler
Module: libav
Branch: release/9
Commit: 5e8eaa26b227255505f52b4d980c7a3c2f52b1fd

Author:Reinhard Tartler siret...@tauware.de
Committer: Reinhard Tartler siret...@tauware.de
Date:  Thu Jun 26 21:23:39 2014 -0400

Prepare for 9.14 Release

---

 RELEASE |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/RELEASE b/RELEASE
index 2645a7f..3f678b4 100644
--- a/RELEASE
+++ b/RELEASE
@@ -1 +1 @@
-9.13
+9.14

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] Update Changelog for 0.8.13

2014-06-26 Thread Reinhard Tartler
Module: libav
Branch: release/0.8
Commit: e122fb594a5feb6729cce86a70aafd93d10202d8

Author:Reinhard Tartler siret...@tauware.de
Committer: Reinhard Tartler siret...@tauware.de
Date:  Thu Jun 26 21:34:03 2014 -0400

Update Changelog for 0.8.13

---

 Changelog |5 +
 1 file changed, 5 insertions(+)

diff --git a/Changelog b/Changelog
index d325786..5ba4bf1 100644
--- a/Changelog
+++ b/Changelog
@@ -1,6 +1,11 @@
 Entries are sorted chronologically from oldest to youngest within each release,
 releases are sorted from youngest to oldest.
 
+version 0.8.13:
+
+- lzo: Handle integer overflow
+- sgidec: fix an incorrect backport
+
 version 0.8.12:
 
 - h264: set parameters from SPS whenever it changes

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits