Browse code

Merge remote-tracking branch 'qatar/master'

* qatar/master: (23 commits)
avconv: Reformat s16 volume adjustment.
ARM: NEON optimised vector_fmac_scalar()
dca: use vector_fmac_scalar from dsputil
dsputil: add vector_fmac_scalar()
latmenc: Fix private options
vf_unsharp: store hsub/vsub in the filter context
vf_unsharp: adopt a more natural order of params in apply_unsharp()
vf_unsharp: rename method "unsharpen" to "apply_unsharp"
vf_scale: apply the same transform to the aspect during init that is applied per frame
vf_pad: fix "vsub" variable value computation
vf_scale: add a "sar" variable
lavfi: fix realloc size computation in avfilter_add_format()
vsrc_color: use internal timebase
lavfi: fix signature for avfilter_graph_parse() and avfilter_graph_config()
graphparser: prefer void * over AVClass * for log contexts
avfiltergraph: use meaningful error codes
avconv: Initialize return value for codec copy path.
fate: use 'run' helper for seek-test
fate: remove seek-mpeg2reuse test
Fix memory (re)allocation in matroskadec.c, related to MSVR-11-0080.
...

Conflicts:
doc/filters.texi
libavfilter/avfilter.h
libavfilter/avfiltergraph.c
libavfilter/avfiltergraph.h
libavfilter/graphparser.c
libavfilter/vf_scale.c
libavfilter/vsrc_color.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2011/09/29 08:03:02
Showing 13 changed files
... ...
@@ -153,7 +153,7 @@ static uint8_t *audio_buf;
153 153
 static uint8_t *audio_out;
154 154
 static unsigned int allocated_audio_out_size, allocated_audio_buf_size;
155 155
 
156
-static short *samples;
156
+static void *samples;
157 157
 
158 158
 #define DEFAULT_PASS_LOGFILENAME_PREFIX "av2pass"
159 159
 
... ...
@@ -1586,7 +1586,7 @@ static int output_packet(InputStream *ist, int ist_index,
1586 1586
 {
1587 1587
     AVFormatContext *os;
1588 1588
     OutputStream *ost;
1589
-    int ret, i;
1589
+    int ret = 0, i;
1590 1590
     int got_output;
1591 1591
     void *buffer_to_free = NULL;
1592 1592
     static unsigned int samples_size= 0;
... ...
@@ -1641,8 +1641,8 @@ static int output_packet(InputStream *ist, int ist_index,
1641 1641
         if (ist->decoding_needed) {
1642 1642
             switch(ist->st->codec->codec_type) {
1643 1643
             case AVMEDIA_TYPE_AUDIO:{
1644
-                if(pkt && samples_size < FFMAX(pkt->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE)) {
1645
-                    samples_size = FFMAX(pkt->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE);
1644
+                if(pkt && samples_size < FFMAX(pkt->size * bps, AVCODEC_MAX_AUDIO_FRAME_SIZE)) {
1645
+                    samples_size = FFMAX(pkt->size * bps, AVCODEC_MAX_AUDIO_FRAME_SIZE);
1646 1646
                     av_free(samples);
1647 1647
                     samples= av_malloc(samples_size);
1648 1648
                 }
... ...
@@ -1731,11 +1731,57 @@ static int output_packet(InputStream *ist, int ist_index,
1731 1731
         // preprocess audio (volume)
1732 1732
         if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
1733 1733
             if (audio_volume != 256) {
1734
-                short *volp;
1735
-                volp = samples;
1736
-                for(i=0;i<(decoded_data_size / sizeof(short));i++) {
1737
-                    int v = ((*volp) * audio_volume + 128) >> 8;
1738
-                    *volp++ = av_clip_int16(v);
1734
+                switch (ist->st->codec->sample_fmt) {
1735
+                case AV_SAMPLE_FMT_U8:
1736
+                {
1737
+                    uint8_t *volp = samples;
1738
+                    for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) {
1739
+                        int v = (((*volp - 128) * audio_volume + 128) >> 8) + 128;
1740
+                        *volp++ = av_clip_uint8(v);
1741
+                    }
1742
+                    break;
1743
+                }
1744
+                case AV_SAMPLE_FMT_S16:
1745
+                {
1746
+                    int16_t *volp = samples;
1747
+                    for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) {
1748
+                        int v = ((*volp) * audio_volume + 128) >> 8;
1749
+                        *volp++ = av_clip_int16(v);
1750
+                    }
1751
+                    break;
1752
+                }
1753
+                case AV_SAMPLE_FMT_S32:
1754
+                {
1755
+                    int32_t *volp = samples;
1756
+                    for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) {
1757
+                        int64_t v = (((int64_t)*volp * audio_volume + 128) >> 8);
1758
+                        *volp++ = av_clipl_int32(v);
1759
+                    }
1760
+                    break;
1761
+                }
1762
+                case AV_SAMPLE_FMT_FLT:
1763
+                {
1764
+                    float *volp = samples;
1765
+                    float scale = audio_volume / 256.f;
1766
+                    for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) {
1767
+                        *volp++ *= scale;
1768
+                    }
1769
+                    break;
1770
+                }
1771
+                case AV_SAMPLE_FMT_DBL:
1772
+                {
1773
+                    double *volp = samples;
1774
+                    double scale = audio_volume / 256.;
1775
+                    for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) {
1776
+                        *volp++ *= scale;
1777
+                    }
1778
+                    break;
1779
+                }
1780
+                default:
1781
+                    av_log(NULL, AV_LOG_FATAL,
1782
+                           "Audio volume adjustment on sample format %s is not supported.\n",
1783
+                           av_get_sample_fmt_name(ist->st->codec->sample_fmt));
1784
+                    exit_program(1);
1739 1785
                 }
1740 1786
             }
1741 1787
         }
... ...
@@ -1687,6 +1687,9 @@ input sample aspect ratio
1687 1687
 @item dar
1688 1688
 input display aspect ratio, it is the same as (@var{iw} / @var{ih}) * @var{sar}
1689 1689
 
1690
+@item sar
1691
+input sample aspect ratio
1692
+
1690 1693
 @item hsub, vsub
1691 1694
 horizontal and vertical chroma subsample values. For example for the
1692 1695
 pixel format "yuv422p" @var{hsub} is 2 and @var{vsub} is 1.
... ...
@@ -160,7 +160,7 @@ static uint8_t *audio_buf;
160 160
 static uint8_t *audio_out;
161 161
 static unsigned int allocated_audio_out_size, allocated_audio_buf_size;
162 162
 
163
-static short *samples;
163
+static void *samples;
164 164
 static uint8_t *input_tmp= NULL;
165 165
 
166 166
 #define DEFAULT_PASS_LOGFILENAME_PREFIX "ffmpeg2pass"
... ...
@@ -1596,7 +1596,7 @@ static int output_packet(InputStream *ist, int ist_index,
1596 1596
 {
1597 1597
     AVFormatContext *os;
1598 1598
     OutputStream *ost;
1599
-    int ret, i;
1599
+    int ret = 0, i;
1600 1600
     int got_output;
1601 1601
     void *buffer_to_free = NULL;
1602 1602
     static unsigned int samples_size= 0;
... ...
@@ -1651,8 +1651,8 @@ static int output_packet(InputStream *ist, int ist_index,
1651 1651
         if (ist->decoding_needed) {
1652 1652
             switch(ist->st->codec->codec_type) {
1653 1653
             case AVMEDIA_TYPE_AUDIO:{
1654
-                if(pkt && samples_size < FFMAX(pkt->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE)) {
1655
-                    samples_size = FFMAX(pkt->size*sizeof(*samples), AVCODEC_MAX_AUDIO_FRAME_SIZE);
1654
+                if(pkt && samples_size < FFMAX(pkt->size * bps, AVCODEC_MAX_AUDIO_FRAME_SIZE)) {
1655
+                    samples_size = FFMAX(pkt->size * bps, AVCODEC_MAX_AUDIO_FRAME_SIZE);
1656 1656
                     av_free(samples);
1657 1657
                     samples= av_malloc(samples_size);
1658 1658
                 }
... ...
@@ -1758,11 +1758,57 @@ static int output_packet(InputStream *ist, int ist_index,
1758 1758
         // preprocess audio (volume)
1759 1759
         if (ist->st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
1760 1760
             if (audio_volume != 256) {
1761
-                short *volp;
1762
-                volp = samples;
1763
-                for(i=0;i<(decoded_data_size / sizeof(short));i++) {
1764
-                    int v = ((*volp) * audio_volume + 128) >> 8;
1765
-                    *volp++ = av_clip_int16(v);
1761
+                switch (ist->st->codec->sample_fmt) {
1762
+                case AV_SAMPLE_FMT_U8:
1763
+                {
1764
+                    uint8_t *volp = samples;
1765
+                    for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) {
1766
+                        int v = (((*volp - 128) * audio_volume + 128) >> 8) + 128;
1767
+                        *volp++ = av_clip_uint8(v);
1768
+                    }
1769
+                    break;
1770
+                }
1771
+                case AV_SAMPLE_FMT_S16:
1772
+                {
1773
+                    int16_t *volp = samples;
1774
+                    for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) {
1775
+                        int v = ((*volp) * audio_volume + 128) >> 8;
1776
+                        *volp++ = av_clip_int16(v);
1777
+                    }
1778
+                    break;
1779
+                }
1780
+                case AV_SAMPLE_FMT_S32:
1781
+                {
1782
+                    int32_t *volp = samples;
1783
+                    for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) {
1784
+                        int64_t v = (((int64_t)*volp * audio_volume + 128) >> 8);
1785
+                        *volp++ = av_clipl_int32(v);
1786
+                    }
1787
+                    break;
1788
+                }
1789
+                case AV_SAMPLE_FMT_FLT:
1790
+                {
1791
+                    float *volp = samples;
1792
+                    float scale = audio_volume / 256.f;
1793
+                    for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) {
1794
+                        *volp++ *= scale;
1795
+                    }
1796
+                    break;
1797
+                }
1798
+                case AV_SAMPLE_FMT_DBL:
1799
+                {
1800
+                    double *volp = samples;
1801
+                    double scale = audio_volume / 256.;
1802
+                    for (i = 0; i < (decoded_data_size / sizeof(*volp)); i++) {
1803
+                        *volp++ *= scale;
1804
+                    }
1805
+                    break;
1806
+                }
1807
+                default:
1808
+                    av_log(NULL, AV_LOG_FATAL,
1809
+                           "Audio volume adjustment on sample format %s is not supported.\n",
1810
+                           av_get_sample_fmt_name(ist->st->codec->sample_fmt));
1811
+                    exit_program(1);
1766 1812
                 }
1767 1813
             }
1768 1814
         }
... ...
@@ -143,6 +143,8 @@ void ff_vector_fmul_window_neon(float *dst, const float *src0,
143 143
                                 const float *src1, const float *win, int len);
144 144
 void ff_vector_fmul_scalar_neon(float *dst, const float *src, float mul,
145 145
                                 int len);
146
+void ff_vector_fmac_scalar_neon(float *dst, const float *src, float mul,
147
+                                int len);
146 148
 void ff_butterflies_float_neon(float *v1, float *v2, int len);
147 149
 float ff_scalarproduct_float_neon(const float *v1, const float *v2, int len);
148 150
 void ff_vector_fmul_reverse_neon(float *dst, const float *src0,
... ...
@@ -305,6 +307,7 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx)
305 305
     c->vector_fmul                = ff_vector_fmul_neon;
306 306
     c->vector_fmul_window         = ff_vector_fmul_window_neon;
307 307
     c->vector_fmul_scalar         = ff_vector_fmul_scalar_neon;
308
+    c->vector_fmac_scalar         = ff_vector_fmac_scalar_neon;
308 309
     c->butterflies_float          = ff_butterflies_float_neon;
309 310
     c->scalarproduct_float        = ff_scalarproduct_float_neon;
310 311
     c->vector_fmul_reverse        = ff_vector_fmul_reverse_neon;
... ...
@@ -587,6 +587,54 @@ NOVFP   vdup.32         q8,  r2
587 587
         .unreq          len
588 588
 endfunc
589 589
 
590
+function ff_vector_fmac_scalar_neon, export=1
591
+VFP     len .req r2
592
+VFP     acc .req r3
593
+NOVFP   len .req r3
594
+NOVFP   acc .req r2
595
+VFP     vdup.32         q15, d0[0]
596
+NOVFP   vdup.32         q15, r2
597
+        bics            r12, len, #15
598
+        mov             acc, r0
599
+        beq             3f
600
+        vld1.32         {q0},     [r1,:128]!
601
+        vld1.32         {q8},     [acc,:128]!
602
+        vld1.32         {q1},     [r1,:128]!
603
+        vld1.32         {q9},     [acc,:128]!
604
+1:      vmla.f32        q8,  q0,  q15
605
+        vld1.32         {q2},     [r1,:128]!
606
+        vld1.32         {q10},    [acc,:128]!
607
+        vmla.f32        q9,  q1,  q15
608
+        vld1.32         {q3},     [r1,:128]!
609
+        vld1.32         {q11},    [acc,:128]!
610
+        vmla.f32        q10, q2,  q15
611
+        vst1.32         {q8},     [r0,:128]!
612
+        vmla.f32        q11, q3,  q15
613
+        vst1.32         {q9},     [r0,:128]!
614
+        subs            r12, r12, #16
615
+        beq             2f
616
+        vld1.32         {q0},     [r1,:128]!
617
+        vld1.32         {q8},     [acc,:128]!
618
+        vst1.32         {q10},    [r0,:128]!
619
+        vld1.32         {q1},     [r1,:128]!
620
+        vld1.32         {q9},     [acc,:128]!
621
+        vst1.32         {q11},    [r0,:128]!
622
+        b               1b
623
+2:      vst1.32         {q10},    [r0,:128]!
624
+        vst1.32         {q11},    [r0,:128]!
625
+        ands            len, len, #15
626
+        it              eq
627
+        bxeq            lr
628
+3:      vld1.32         {q0},     [r1,:128]!
629
+        vld1.32         {q8},     [acc,:128]!
630
+        vmla.f32        q8,  q0,  q15
631
+        vst1.32         {q8},     [r0,:128]!
632
+        subs            len, len, #4
633
+        bgt             3b
634
+        bx              lr
635
+        .unreq          len
636
+endfunc
637
+
590 638
 function ff_butterflies_float_neon, export=1
591 639
 1:      vld1.32         {q0},[r0,:128]
592 640
         vld1.32         {q1},[r1,:128]
... ...
@@ -1833,11 +1833,8 @@ static int dca_decode_frame(AVCodecContext * avctx,
1833 1833
             float* back_chan = s->samples + s->channel_order_tab[s->xch_base_channel] * 256;
1834 1834
             float* lt_chan   = s->samples + s->channel_order_tab[s->xch_base_channel - 2] * 256;
1835 1835
             float* rt_chan   = s->samples + s->channel_order_tab[s->xch_base_channel - 1] * 256;
1836
-            int j;
1837
-            for(j = 0; j < 256; ++j) {
1838
-                lt_chan[j] -= back_chan[j] * M_SQRT1_2;
1839
-                rt_chan[j] -= back_chan[j] * M_SQRT1_2;
1840
-            }
1836
+            s->dsp.vector_fmac_scalar(lt_chan, back_chan, -M_SQRT1_2, 256);
1837
+            s->dsp.vector_fmac_scalar(rt_chan, back_chan, -M_SQRT1_2, 256);
1841 1838
         }
1842 1839
 
1843 1840
         if (avctx->sample_fmt == AV_SAMPLE_FMT_FLT) {
... ...
@@ -2443,6 +2443,14 @@ static void vector_fmul_scalar_c(float *dst, const float *src, float mul,
2443 2443
         dst[i] = src[i] * mul;
2444 2444
 }
2445 2445
 
2446
+static void vector_fmac_scalar_c(float *dst, const float *src, float mul,
2447
+                                 int len)
2448
+{
2449
+    int i;
2450
+    for (i = 0; i < len; i++)
2451
+        dst[i] += src[i] * mul;
2452
+}
2453
+
2446 2454
 static void butterflies_float_c(float *restrict v1, float *restrict v2,
2447 2455
                                 int len)
2448 2456
 {
... ...
@@ -2978,6 +2986,7 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
2978 2978
     c->scalarproduct_float = scalarproduct_float_c;
2979 2979
     c->butterflies_float = butterflies_float_c;
2980 2980
     c->vector_fmul_scalar = vector_fmul_scalar_c;
2981
+    c->vector_fmac_scalar = vector_fmac_scalar_c;
2981 2982
 
2982 2983
     c->shrink[0]= av_image_copy_plane;
2983 2984
     c->shrink[1]= ff_shrink22;
... ...
@@ -424,6 +424,17 @@ typedef struct DSPContext {
424 424
     void (*vector_fmul_scalar)(float *dst, const float *src, float mul,
425 425
                                int len);
426 426
     /**
427
+     * Multiply a vector of floats by a scalar float and add to
428
+     * destination vector.  Source and destination vectors must
429
+     * overlap exactly or not at all.
430
+     * @param dst result vector, 16-byte aligned
431
+     * @param src input vector, 16-byte aligned
432
+     * @param mul scalar value
433
+     * @param len length of vector, multiple of 4
434
+     */
435
+    void (*vector_fmac_scalar)(float *dst, const float *src, float mul,
436
+                               int len);
437
+    /**
427 438
      * Calculate the scalar product of two vectors of floats.
428 439
      * @param v1  first vector, 16-byte aligned
429 440
      * @param v2  second vector, 16-byte aligned
... ...
@@ -30,7 +30,7 @@
30 30
 
31 31
 #define LIBAVFILTER_VERSION_MAJOR  2
32 32
 #define LIBAVFILTER_VERSION_MINOR 43
33
-#define LIBAVFILTER_VERSION_MICRO  5
33
+#define LIBAVFILTER_VERSION_MICRO  6
34 34
 
35 35
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
36 36
                                                LIBAVFILTER_VERSION_MINOR, \
... ...
@@ -171,4 +171,5 @@ int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const
171 171
 int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, int flags, double ts);
172 172
 
173 173
 
174
+
174 175
 #endif /* AVFILTER_AVFILTERGRAPH_H */
... ...
@@ -28,6 +28,7 @@
28 28
 #include "rawenc.h"
29 29
 
30 30
 typedef struct {
31
+    AVClass *av_class;
31 32
     int off;
32 33
     int channel_conf;
33 34
     int object_type;
... ...
@@ -967,6 +967,7 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size,
967 967
     uint8_t* data = *buf;
968 968
     int isize = *buf_size;
969 969
     uint8_t* pkt_data = NULL;
970
+    uint8_t* newpktdata;
970 971
     int pkt_size = isize;
971 972
     int result = 0;
972 973
     int olen;
... ...
@@ -996,7 +997,12 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size,
996 996
         zstream.avail_in = isize;
997 997
         do {
998 998
             pkt_size *= 3;
999
-            pkt_data = av_realloc(pkt_data, pkt_size);
999
+            newpktdata = av_realloc(pkt_data, pkt_size);
1000
+            if (!newpktdata) {
1001
+                inflateEnd(&zstream);
1002
+                goto failed;
1003
+            }
1004
+            pkt_data = newpktdata;
1000 1005
             zstream.avail_out = pkt_size - zstream.total_out;
1001 1006
             zstream.next_out = pkt_data + zstream.total_out;
1002 1007
             if (pkt_data) {
... ...
@@ -1020,7 +1026,12 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size,
1020 1020
         bzstream.avail_in = isize;
1021 1021
         do {
1022 1022
             pkt_size *= 3;
1023
-            pkt_data = av_realloc(pkt_data, pkt_size);
1023
+            newpktdata = av_realloc(pkt_data, pkt_size);
1024
+            if (!newpktdata) {
1025
+                BZ2_bzDecompressEnd(&bzstream);
1026
+                goto failed;
1027
+            }
1028
+            pkt_data = newpktdata;
1024 1029
             bzstream.avail_out = pkt_size - bzstream.total_out_lo32;
1025 1030
             bzstream.next_out = pkt_data + bzstream.total_out_lo32;
1026 1031
             if (pkt_data) {
... ...
@@ -105,7 +105,7 @@ seektest(){
105 105
                  file=$(echo tests/data/$d/$file)
106 106
                  ;;
107 107
     esac
108
-    $target_exec $target_path/libavformat/seek-test $target_path/$file
108
+    run libavformat/seek-test $target_path/$file
109 109
 }
110 110
 
111 111
 mkdir -p "$outdir"