]> git.sesse.net Git - nageru/blobdiff - nageru/mjpeg_encoder.cpp
Constify FFmpeg callbacks.
[nageru] / nageru / mjpeg_encoder.cpp
index 193027b38483e42359f9733a3d899dcad0b4f8db..b871af23e78a5004a2bdc6eff67c97a370f36ce1 100644 (file)
@@ -1,33 +1,59 @@
 #include "mjpeg_encoder.h"
 
+#include <Eigen/Core>
+#include <algorithm>
 #include <assert.h>
+#include <bmusb/bmusb.h>
 #include <jpeglib.h>
-#include <unistd.h>
+#include <math.h>
+#include <movit/colorspace_conversion_effect.h>
+#include <movit/effect.h>
+#include <movit/image_format.h>
+#include <movit/ycbcr.h>
+#include <mutex>
+#include <pthread.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <string>
+#include <thread>
+#include <type_traits>
+#include <utility>
+#include <va/va.h>
+#include <va/va_enc_jpeg.h>
+#include <vector>
 #if __SSE2__
 #include <immintrin.h>
 #endif
-#include <list>
 
 extern "C" {
+#include <libavcodec/codec_id.h>
+#include <libavcodec/defs.h>
+#include <libavcodec/packet.h>
 #include <libavformat/avformat.h>
+#include <libavformat/avio.h>
+#include <libavutil/avutil.h>
 #include <libavutil/channel_layout.h>
+#include <libavutil/dict.h>
+#include <libavutil/mathematics.h>
+#include <libavutil/mem.h>
+#include <libavutil/pixfmt.h>
+#include <libavutil/rational.h>
 }
 
-#include "defs.h"
-#include "shared/ffmpeg_raii.h"
 #include "flags.h"
+#include "pbo_frame_allocator.h"
+#include "ref_counted_frame.h"
+#include "shared/ffmpeg_raii.h"
 #include "shared/httpd.h"
 #include "shared/memcpy_interleaved.h"
 #include "shared/metrics.h"
-#include "pbo_frame_allocator.h"
+#include "shared/shared_defs.h"
 #include "shared/timebase.h"
 #include "shared/va_display.h"
-
-#include <movit/colorspace_conversion_effect.h>
-
-#include <va/va.h>
-#include <va/va_drm.h>
-#include <va/va_x11.h>
+#include "shared/va_resource_pool.h"
 
 using namespace Eigen;
 using namespace bmusb;
@@ -131,13 +157,13 @@ struct VectorDestinationManager {
 };
 static_assert(std::is_standard_layout<VectorDestinationManager>::value, "");
 
-int MJPEGEncoder::write_packet2_thunk(void *opaque, uint8_t *buf, int buf_size, AVIODataMarkerType type, int64_t time)
+int MJPEGEncoder::write_packet2_thunk(void *opaque, FF_MAYBE_CONST uint8_t *buf, int buf_size, AVIODataMarkerType type, int64_t time)
 {
        WritePacket2Context *ctx = (WritePacket2Context *)opaque;
        return ctx->mjpeg_encoder->write_packet2(ctx->stream_id, buf, buf_size, type, time);
 }
 
-int MJPEGEncoder::write_packet2(HTTPD::StreamID stream_id, uint8_t *buf, int buf_size, AVIODataMarkerType type, int64_t time)
+int MJPEGEncoder::write_packet2(HTTPD::StreamID stream_id, FF_MAYBE_CONST uint8_t *buf, int buf_size, AVIODataMarkerType type, int64_t time)
 {
        string *mux_header = &streams[stream_id].mux_header;
        if (type == AVIO_DATA_MARKER_HEADER) {
@@ -191,8 +217,9 @@ void add_audio_stream(AVFormatContext *avctx)
        stream->time_base = AVRational{ 1, OUTPUT_FREQUENCY };
        stream->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
        stream->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE;
-       stream->codecpar->channel_layout = AV_CH_LAYOUT_STEREO;
-       stream->codecpar->channels = 2;
+       stream->codecpar->ch_layout.order = AV_CHANNEL_ORDER_NATIVE;
+       stream->codecpar->ch_layout.nb_channels = 2;
+       stream->codecpar->ch_layout.u.mask = AV_CH_LAYOUT_STEREO;
        stream->codecpar->sample_rate = OUTPUT_FREQUENCY;
 }