[FFmpeg-devel] Test for FLAC

Michael Niedermayer michaelni at gmx.at
Fri Apr 10 04:03:38 CEST 2015


On Fri, Apr 10, 2015 at 03:45:33AM +0300, Ludmila Glinskih wrote:
> Hi!
> 
> I'm a newbie girl, interested in writing tests for the ffmpeg API. I
> would like to propose a simple test for the FLAC codec. Since there is
> no infrastructure for API testing yet, I added it to the examples
> directory. I hope it's not too bad=). I will be very grateful for you
> comments.
> 
> My pull request: https://github.com/FFmpeg/FFmpeg/pull/132

+/* select layout with the highest channel count */
+static int select_channel_layout(AVCodec *codec)

This should return uint64_t as the layout is 64bit


+{
+    const uint64_t *p;
+    uint64_t best_ch_layout = 0;
+    int best_nb_channels   = 0;
+
+    if (!codec->channel_layouts)
+        return AV_CH_LAYOUT_STEREO;
+
+    p = codec->channel_layouts;
+    while (*p) {
+        int nb_channels = av_get_channel_layout_nb_channels(*p);
+
+        if (nb_channels > best_nb_channels) {
+            best_ch_layout    = *p;
+            best_nb_channels = nb_channels;
+        }
+        p++;
+    }
+    return best_ch_layout;
+}

+/* generate i-th frame of test audio */
+static int generate_raw_frame(uint16_t *frame_data, int i, int sample_rate, int channels, int frame_size)
+{
+    float t, tincr, tincr2;
+    int j, k;
+
+    t = 0.0;
+    tincr = 2 * M_PI * 440.0 / sample_rate;
+    tincr2 = tincr / sample_rate;
+    for (j = 0; j < frame_size; j++)
+    {
+        frame_data[channels * j] = (int)(sin(t) * 10000);
+        for (k = 1; k < channels; k++)
+            frame_data[channels * j + k] = frame_data[channels * j] * 2;
+        t = i * tincr + (i * (i + 1) / 2.0 * tincr2);
+    }
+    return 0;
+}

the use of floats can lead the rounding differences between platforms
so that 2 platforms would then test with slight different test
signals
this may or may not be a problem depending on the exact use of the
signal


also if i assume correctly that this is for FFmpeg outreachy, make sure
you submit an application to outreachy before the deadline, aka
very very soon

and please post the next revission of the patch to this mailing list
not github

Thanks

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

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150410/edbc2ac0/attachment.asc>


More information about the ffmpeg-devel mailing list