summaryrefslogtreecommitdiff
path: root/src/liblame_wrapper.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/liblame_wrapper.cc')
-rw-r--r--src/liblame_wrapper.cc44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/liblame_wrapper.cc b/src/liblame_wrapper.cc
index b29acf9..5603d6f 100644
--- a/src/liblame_wrapper.cc
+++ b/src/liblame_wrapper.cc
@@ -118,27 +118,41 @@ Frame *LibLAMEWrapper::close(Frame *oldframe)
return frame;
}
+#include <math.h>
+static unsigned int sin_cnt = 0;
Frame *LibLAMEWrapper::encode(Frame *dvframe)
{
+ if(dvframe->mute) {
+ // Overwrite audiobuffer with dummy data
+ double volume = 1000; // Min:= 0 - Max := 32000
+ double frequency = 440; // in Hz
+
+ for(int cnt = 0; cnt < SAMPLES; cnt++) {
+ sin_cnt++;
+ double sin_val = (((double)sin_cnt / (double)OUTPUT_SAMPLE_RATE) * (double)M_PI) * frequency;
+ audio_buffer[0][cnt] = audio_buffer[1][cnt] = (short int)(sin(sin_val) * volume);
+ }
- if(!decoder) {
- decoder = dv_decoder_new(FALSE/*this value is unused*/, FALSE, FALSE);
- decoder->quality = DV_QUALITY_BEST;
-
- dv_parse_header(decoder, dvframe->data);
-
- decoder->system = e_dv_system_625_50; // PAL lines, PAL framerate
- decoder->sampling = e_dv_sample_422; // 4 bytes y, 2 bytes u, 2 bytes v
- decoder->std = e_dv_std_iec_61834;
- decoder->num_dif_seqs = 12;
+ // memset(audio_buffer[0], 0, sizeof(audio_buffer[0]));
+ // memset(audio_buffer[1], 0, sizeof(audio_buffer[1]));
+ } else {
+ // Decode audio from dv frame
+ if(!decoder) {
+ decoder = dv_decoder_new(FALSE/*this value is unused*/, FALSE, FALSE);
+ decoder->quality = DV_QUALITY_BEST;
+
+ dv_parse_header(decoder, dvframe->data);
+
+ decoder->system = e_dv_system_625_50; // PAL lines, PAL framerate
+ decoder->sampling = e_dv_sample_422; // 4 bytes y, 2 bytes u, 2 bytes v
+ decoder->std = e_dv_std_iec_61834;
+ decoder->num_dif_seqs = 12;
+ }
+ // Decode audio using libdv
+ dv_decode_full_audio( decoder, dvframe->data, audio_buffer );
}
/**
- * Decode audio using libdv
- */
- dv_decode_full_audio( decoder, dvframe->data, audio_buffer );
-
- /**
* input pcm data, output (maybe) mp3 frames.
* This routine handles all buffering, resampling and filtering for you.
*