From 5feec0317fea4e258be0b8fcdd7b4bc2b5bb54d3 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 8 Mar 2015 19:49:48 -0700 Subject: [PATCH] Video: Fix FFmpeg encoder support for 15- and 16-bit video pixel formats --- src/platform/ffmpeg/ffmpeg-encoder.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/platform/ffmpeg/ffmpeg-encoder.c b/src/platform/ffmpeg/ffmpeg-encoder.c index 1c69d96dd..184ac5a8d 100644 --- a/src/platform/ffmpeg/ffmpeg-encoder.c +++ b/src/platform/ffmpeg/ffmpeg-encoder.c @@ -288,10 +288,18 @@ bool FFmpegEncoderOpen(struct FFmpegEncoder* encoder, const char* outfile) { encoder->videoFrame->height = encoder->video->height; encoder->videoFrame->pts = 0; encoder->scaleContext = sws_getContext(VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, +#ifdef COLOR_16_BIT +#ifdef COLOR_5_6_5 + AV_PIX_FMT_RGB565, +#else + AV_PIX_FMT_BGR555, +#endif +#else #ifndef USE_LIBAV AV_PIX_FMT_0BGR32, #else AV_PIX_FMT_BGR32, +#endif #endif encoder->videoFrame->width, encoder->videoFrame->height, encoder->video->pix_fmt, SWS_POINT, 0, 0, 0); @@ -416,7 +424,7 @@ void _ffmpegPostVideoFrame(struct GBAAVStream* stream, struct GBAVideoRenderer* uint8_t* pixels; unsigned stride; renderer->getPixels(renderer, &stride, (void**) &pixels); - stride *= 4; + stride *= BYTES_PER_PIXEL; AVPacket packet;