[FFmpeg-devel] [PATCH 3/3] libx265: Add crf private option

Michael Niedermayer michaelni at gmx.at
Wed Feb 18 00:56:59 CET 2015


On Tue, Feb 17, 2015 at 05:02:31PM -0500, Derek Buitenhuis wrote:
> Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
> ---
>  libavcodec/libx265.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/libx265.c b/libavcodec/libx265.c
> index c35f6c2..0d546d8 100644
> --- a/libavcodec/libx265.c
> +++ b/libavcodec/libx265.c
> @@ -25,6 +25,7 @@
>  #endif
>  
>  #include <x265.h>
> +#include <float.h>
>  
>  #include "libavutil/internal.h"
>  #include "libavutil/common.h"
> @@ -39,6 +40,7 @@ typedef struct libx265Context {
>      x265_encoder *encoder;
>      x265_param   *params;
>  
> +    float crf;
>      char *preset;
>      char *tune;
>      char *x265_opts;
> @@ -138,7 +140,15 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
>          break;
>      }
>  
> -    if (avctx->bit_rate > 0) {
> +    if (ctx->crf >= 0) {
> +        char crf[6];
> +
> +        snprintf(crf, sizeof(crf), "%2.2f", ctx->crf);
> +        if (x265_param_parse(ctx->params, "crf", crf) == X265_PARAM_BAD_VALUE) {
> +            av_log(avctx, AV_LOG_ERROR, "Invalid crf: %2.2f.\n", ctx->crf);
> +            return AVERROR_INVALIDDATA;

this should be EINVAL too i think
otherwise patch LGTM

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150218/68a8631a/attachment.asc>


More information about the ffmpeg-devel mailing list