audio: make audiofragment be multichannel

parent 40b24e83
......@@ -168,6 +168,8 @@ gegl_param_audio_finalize (GParamSpec *self)
param_audio->default_audio = NULL;
}
g_warning ("...\n");
parent_class->finalize (self);
}
......
......@@ -33,13 +33,17 @@ G_BEGIN_DECLS
typedef struct _GeglAudioClass GeglAudioClass;
typedef struct _GeglAudioPrivate GeglAudioPrivate;
#define GEGL_MAX_AUDIO_CHANNELS 6
#define GEGL_MAX_AUDIO_SAMPLES 4800
struct _GeglAudio
{
GObject parent_instance;
float left[4000];
float right[4000];
int samples;
int samplerate;
GObject parent_instance;
int sample_rate;
int samples;
int channels;
int channel_layout;/* unused - assumed channels = 1 is mono 2 stereo */
float data[GEGL_MAX_AUDIO_CHANNELS][GEGL_MAX_AUDIO_SAMPLES];
GeglAudioPrivate *priv;
};
......
......@@ -83,8 +83,6 @@ typedef struct
glong prevframe; /* previously decoded frame number */
gdouble prevpts; /* timestamp in seconds of last decoded frame */
} Priv;
#define MAX_AUDIO_CHANNELS 6
......@@ -638,17 +636,17 @@ process (GeglOperation *operation,
if (p->audio_stream && p->audio_stream->codec) // XXX: remove second clause
{
o->audio->samplerate = p->audio_stream->codec->sample_rate;
o->audio->sample_rate = p->audio_stream->codec->sample_rate;
o->audio->samples = samples_per_frame (o->frame,
o->frame_rate, o->audio->samplerate,
o->frame_rate, o->audio->sample_rate,
&sample_start);
decode_audio (operation, p->prevpts, p->prevpts + 5.0);
{
int i;
for (i = 0; i < o->audio->samples; i++)
{
get_sample_data (p, sample_start + i, &o->audio->left[i],
&o->audio->right[i]);
get_sample_data (p, sample_start + i, &o->audio->data[0][i],
&o->audio->data[1][i]);
}
}
}
......
......@@ -265,11 +265,11 @@ open_audio (GeglProperties *o, AVFormatContext * oc, AVStream * st)
{
if (o->audio)
{
if (o->audio->samplerate == 0)
if (o->audio->sample_rate == 0)
{
o->audio->samplerate = 48000; // XXX: should skip adding audiostream instead
o->audio->sample_rate = 48000; // XXX: should skip adding audiostream instead
}
p->audio_sample_rate = o->audio->samplerate;
p->audio_sample_rate = o->audio->sample_rate;
}
}
c->sample_rate = p->audio_sample_rate;
......@@ -343,8 +343,8 @@ write_audio_frame (GeglProperties *o, AVFormatContext * oc, AVStream * st)
af->len = o->audio->samples;
for (i = 0; i < af->len; i++)
{
af->data[0][i] = o->audio->left[i];
af->data[1][i] = o->audio->right[i];
af->data[0][i] = o->audio->data[0][i];
af->data[1][i] = o->audio->data[1][i];
}
af->pos = p->audio_pos;
p->audio_pos += af->len;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment