]> git.sesse.net Git - nageru/commitdiff
Move audio codec choice into defs.h.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 14 Nov 2015 00:00:16 +0000 (01:00 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 14 Nov 2015 00:00:16 +0000 (01:00 +0100)
defs.h
h264encode.cpp
httpd.cpp

diff --git a/defs.h b/defs.h
index fe278040ec51986c68827a1121b98449752ea6bb..9e3dfd581e72758985f08bff166c3ba24c5c1838 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -5,4 +5,8 @@
 #define OUTPUT_FREQUENCY 48000
 #define FPS 60
 
+#define AUDIO_OUTPUT_CODEC AV_CODEC_ID_MP3
+#define AUDIO_OUTPUT_SAMPLE_FMT AV_SAMPLE_FMT_FLTP
+#define AUDIO_OUTPUT_BIT_RATE 256000
+
 #endif  // !defined(_DEFS_H)
index dd2c80560840c52155dca439c1a8c1335145731f..6e946d961f54b7510dbd515976d2d224d1165a93 100644 (file)
@@ -1698,7 +1698,7 @@ int H264Encoder::save_codeddata(storage_task task)
 
         AVFrame *frame = avcodec_alloc_frame();
         frame->nb_samples = audio.size() / 2;
-        frame->format = AV_SAMPLE_FMT_FLT;
+        frame->format = AV_SAMPLE_FMT_FLTP;
         frame->channel_layout = AV_CH_LAYOUT_STEREO;
 
         unique_ptr<float[]> planar_samples(new float[audio.size()]);
@@ -1833,11 +1833,11 @@ static int print_input()
 H264Encoder::H264Encoder(QSurface *surface, int width, int height, HTTPD *httpd)
        : current_storage_frame(0), surface(surface), httpd(httpd)
 {
-       AVCodec *codec_audio = avcodec_find_encoder(AV_CODEC_ID_MP3);
+       AVCodec *codec_audio = avcodec_find_encoder(AUDIO_OUTPUT_CODEC);
        context_audio = avcodec_alloc_context3(codec_audio);
-       context_audio->bit_rate = 256000;
+       context_audio->bit_rate = AUDIO_OUTPUT_BIT_RATE;
        context_audio->sample_rate = OUTPUT_FREQUENCY;
-       context_audio->sample_fmt = AV_SAMPLE_FMT_FLTP;
+       context_audio->sample_fmt = AUDIO_OUTPUT_SAMPLE_FMT;
        context_audio->channels = 2;
        context_audio->channel_layout = AV_CH_LAYOUT_STEREO;
        context_audio->time_base = AVRational{1, TIMEBASE};
index 359bd7285d98c9cf50586e82ee73156551d9f134..281bbcf0b05e7e1ebed86403016ff57f7d0eab61 100644 (file)
--- a/httpd.cpp
+++ b/httpd.cpp
@@ -113,16 +113,16 @@ HTTPD::Mux::Mux(AVFormatContext *avctx, int width, int height)
        avstream_video->codec->chroma_sample_location = AVCHROMA_LOC_LEFT;  // Chroma sample location. See chroma_offset_0[] in Mixer::subsample_chroma().
        avstream_video->codec->field_order = AV_FIELD_PROGRESSIVE;
 
-       AVCodec *codec_audio = avcodec_find_encoder(AV_CODEC_ID_MP3);
+       AVCodec *codec_audio = avcodec_find_encoder(AUDIO_OUTPUT_CODEC);
        avstream_audio = avformat_new_stream(avctx, codec_audio);
        if (avstream_audio == nullptr) {
                fprintf(stderr, "avformat_new_stream() failed\n");
                exit(1);
        }
        avstream_audio->time_base = AVRational{1, TIMEBASE};
-       avstream_audio->codec->bit_rate = 256000;
+       avstream_audio->codec->bit_rate = AUDIO_OUTPUT_BIT_RATE;
        avstream_audio->codec->sample_rate = OUTPUT_FREQUENCY;
-       avstream_audio->codec->sample_fmt = AV_SAMPLE_FMT_FLTP;
+       avstream_audio->codec->sample_fmt = AUDIO_OUTPUT_SAMPLE_FMT;
        avstream_audio->codec->channels = 2;
        avstream_audio->codec->channel_layout = AV_CH_LAYOUT_STEREO;
        avstream_audio->codec->time_base = AVRational{1, TIMEBASE};