[FFmpeg-devel] [PATCH]lavc/libx264: Support monochrome encoding

Carl Eugen Hoyos ceffmpeg at gmail.com
Tue Aug 7 21:43:32 EEST 2018


2018-08-07 20:31 GMT+02:00, James Almer <jamrial at gmail.com>:
> On 8/7/2018 3:25 PM, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> Attached patch allows monochrome encoding with libx264, supported in
>> master since a few hours.
>>
>> Please comment, Carl Eugen
>>
>>
>> 0001-lavc-libx264-Support-monochrome-encoding.patch
>>
>>
>> From a26245de63bdc9afc6b21ea6e97b95a2a7e1e765 Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos <ceffmpeg at gmail.com>
>> Date: Tue, 7 Aug 2018 20:23:06 +0200
>> Subject: [PATCH] lavc/libx264: Support monochrome encoding.
>>
>> ---
>>  libavcodec/libx264.c |   14 ++++++++++++++
>>  1 file changed, 14 insertions(+)
>>
>> diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
>> index 12379ff..cc9e5c8 100644
>> --- a/libavcodec/libx264.c
>> +++ b/libavcodec/libx264.c
>> @@ -443,6 +443,10 @@ static int convert_pix_fmt(enum AVPixelFormat
>> pix_fmt)
>>  #ifdef X264_CSP_NV21
>>      case AV_PIX_FMT_NV21:      return X264_CSP_NV21;
>>  #endif
>> +#ifdef X264_CSP_I400
>> +    case AV_PIX_FMT_GRAY8:
>> +    case AV_PIX_FMT_GRAY10:    return X264_CSP_I400;
>> +#endif
>>      };
>>      return 0;
>>  }
>> @@ -855,6 +859,9 @@ static const enum AVPixelFormat pix_fmts_8bit[] = {
>>  #ifdef X264_CSP_NV21
>>      AV_PIX_FMT_NV21,
>>  #endif
>> +#ifdef X264_CSP_I400
>> +    AV_PIX_FMT_GRAY8,
>> +#endif
>
> Unneeded. This array is only used with old x264 builds.
>
>>      AV_PIX_FMT_NONE
>>  };
>>  static const enum AVPixelFormat pix_fmts_9bit[] = {
>> @@ -867,6 +874,9 @@ static const enum AVPixelFormat pix_fmts_10bit[] = {
>>      AV_PIX_FMT_YUV422P10,
>>      AV_PIX_FMT_YUV444P10,
>>      AV_PIX_FMT_NV20,
>> +#ifdef X264_CSP_I400
>> +    AV_PIX_FMT_GRAY10,
>> +#endif
>>      AV_PIX_FMT_NONE
>>  };
>
> Same.
>
>>  static const enum AVPixelFormat pix_fmts_all[] = {
>> @@ -885,6 +895,10 @@ static const enum AVPixelFormat pix_fmts_all[] = {
>>      AV_PIX_FMT_YUV422P10,
>>      AV_PIX_FMT_YUV444P10,
>>      AV_PIX_FMT_NV20,
>> +#ifdef X264_CSP_I400
>> +    AV_PIX_FMT_GRAY8,
>> +    AV_PIX_FMT_GRAY10,
>> +#endif
>>      AV_PIX_FMT_NONE
>>  };
>>  #if CONFIG_LIBX264RGB_ENCODER
>> -- 1.7.10.4
>
> I think you need to add these two pixfmts to avfmt2_num_planes() as
> well, so they may return 1 instead of the default 3.

Pushed with these changes.

Thank you, Carl Eugen


More information about the ffmpeg-devel mailing list