all repos — mgba @ db4f1ecb2deb6dcc0c17057770f84240f7fe60be

mGBA Game Boy Advance Emulator

FFmpeg: Minor lossless encoding improvements
Vicki Pfau vi@endrift.com
Fri, 10 Jul 2020 23:53:55 -0700
commit

db4f1ecb2deb6dcc0c17057770f84240f7fe60be

parent

1b755e17d062cef0e94c1e509e58a62e3a94d03a

1 files changed, 13 insertions(+), 5 deletions(-)

jump to
M src/feature/ffmpeg/ffmpeg-encoder.csrc/feature/ffmpeg/ffmpeg-encoder.c

@@ -390,12 +390,18 @@ strcasecmp(encoder->containerFormat, "mov"))) {

// QuickTime and a few other things require YUV420 encoder->video->pix_fmt = AV_PIX_FMT_YUV420P; } -#if LIBAVCODEC_VERSION_MAJOR >= 57 if (encoder->video->codec->id == AV_CODEC_ID_FFV1) { +#if LIBAVCODEC_VERSION_MAJOR >= 57 av_opt_set(encoder->video->priv_data, "coder", "range_tab", 0); + av_opt_set_int(encoder->video->priv_data, "context", 1, 0); +#endif + encoder->video->gop_size = 128; + encoder->video->level = 3; } -#endif + if (encoder->video->codec->id == AV_CODEC_ID_PNG) { + encoder->video->compression_level = 8; + } if (strcmp(vcodec->name, "libx264") == 0) { // Try to adaptively figure out when you can use a slower encoder if (encoder->width * encoder->height > 1000000) {

@@ -406,13 +412,15 @@ } else {

av_opt_set(encoder->video->priv_data, "preset", "faster", 0); } if (encoder->videoBitrate == 0) { - av_opt_set(encoder->video->priv_data, "crf", "0", 0); + av_opt_set(encoder->video->priv_data, "qp", "0", 0); encoder->video->pix_fmt = AV_PIX_FMT_YUV444P; } } if (strcmp(vcodec->name, "libvpx-vp9") == 0 && encoder->videoBitrate == 0) { - av_opt_set(encoder->video->priv_data, "lossless", "1", 0); - encoder->video->pix_fmt = AV_PIX_FMT_YUV444P; + av_opt_set_int(encoder->video->priv_data, "lossless", 1, 0); + av_opt_set_int(encoder->video->priv_data, "crf", 0, 0); + encoder->video->gop_size = 120; + encoder->video->pix_fmt = AV_PIX_FMT_GBRP; } if (strcmp(vcodec->name, "libwebp_anim") == 0 && encoder->videoBitrate == 0) { av_opt_set(encoder->video->priv_data, "lossless", "1", 0);