diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-04-06 03:01:14 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-04-10 03:48:41 +0200 |
commit | 059fc2d9da5364627613fb3e6424079e14dbdfd3 (patch) | |
tree | ed91afb8711dd2a9f62327cdad8deda50b07f2f7 /fftools/ffmpeg_filter.c | |
parent | 48cda7d02b768d965db6582271a2f8591f2a3a10 (diff) |
avcodec/mjpegenc: Include all supported pix_fmts in mpegenc pix_fmts
Currently said list contains only the pixel formats that are always
supported irrespective of the range and the value of
strict_std_compliance. This makes the MJPEG encoder an outlier as all
other codecs put all potentially supported pixel formats into said list
and error out if the chosen pixel format is unsupported. This commit
brings it therefore in line with the other encoders.
The behaviour of fftools/ffmpeg_filter.c has been preserved. A more
informed decision would be possible if colour range were available
at this point, but it isn't.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'fftools/ffmpeg_filter.c')
-rw-r--r-- | fftools/ffmpeg_filter.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 4ab769c07b..5c44b75eff 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -39,22 +39,16 @@ #include "libavutil/imgutils.h" #include "libavutil/samplefmt.h" -static const enum AVPixelFormat *get_compliance_unofficial_pix_fmts(enum AVCodecID codec_id, const enum AVPixelFormat default_formats[]) +// FIXME: YUV420P etc. are actually supported with full color range, +// yet the latter information isn't available here. +static const enum AVPixelFormat *get_compliance_normal_pix_fmts(enum AVCodecID codec_id, const enum AVPixelFormat default_formats[]) { static const enum AVPixelFormat mjpeg_formats[] = { AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ422P, AV_PIX_FMT_YUVJ444P, - AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE }; - static const enum AVPixelFormat ljpeg_formats[] = - { AV_PIX_FMT_BGR24 , AV_PIX_FMT_BGRA , AV_PIX_FMT_BGR0, - AV_PIX_FMT_YUVJ420P, AV_PIX_FMT_YUVJ444P, AV_PIX_FMT_YUVJ422P, - AV_PIX_FMT_YUV420P , AV_PIX_FMT_YUV444P , AV_PIX_FMT_YUV422P, - AV_PIX_FMT_NONE}; if (codec_id == AV_CODEC_ID_MJPEG) { return mjpeg_formats; - } else if (codec_id == AV_CODEC_ID_LJPEG) { - return ljpeg_formats; } else { return default_formats; } @@ -70,8 +64,8 @@ static enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx int has_alpha = desc ? desc->nb_components % 2 == 0 : 0; enum AVPixelFormat best= AV_PIX_FMT_NONE; - if (enc_ctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) { - p = get_compliance_unofficial_pix_fmts(enc_ctx->codec_id, p); + if (enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) { + p = get_compliance_normal_pix_fmts(enc_ctx->codec_id, p); } for (; *p != AV_PIX_FMT_NONE; p++) { best = av_find_best_pix_fmt_of_2(best, *p, target, has_alpha, NULL); @@ -118,8 +112,8 @@ static char *choose_pix_fmts(OutputFilter *ofilter) exit_program(1); p = ost->enc->pix_fmts; - if (ost->enc_ctx->strict_std_compliance <= FF_COMPLIANCE_UNOFFICIAL) { - p = get_compliance_unofficial_pix_fmts(ost->enc_ctx->codec_id, p); + if (ost->enc_ctx->strict_std_compliance > FF_COMPLIANCE_UNOFFICIAL) { + p = get_compliance_normal_pix_fmts(ost->enc_ctx->codec_id, p); } for (; *p != AV_PIX_FMT_NONE; p++) { |