--- libavcodec/ffv1enc.c | 40 ++++++++++++++++++++++++---------------- libavcodec/ffv1enc.h | 2 ++ 2 files changed, 26 insertions(+), 16 deletions(-)
diff --git a/libavcodec/ffv1enc.c b/libavcodec/ffv1enc.c index ca2c9f32e2..a106e2130a 100644 --- a/libavcodec/ffv1enc.c +++ b/libavcodec/ffv1enc.c @@ -731,22 +731,14 @@ av_cold int ff_ffv1_encode_init(AVCodecContext *avctx) return 0; } -static int encode_init_internal(AVCodecContext *avctx) +av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx, + enum AVPixelFormat pix_fmt) { - int ret; FFV1Context *s = avctx->priv_data; - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); - - if ((ret = ff_ffv1_common_init(avctx)) < 0) - return ret; - - if (s->ac == 1) // Compatbility with common command line usage - s->ac = AC_RANGE_CUSTOM_TAB; - else if (s->ac == AC_RANGE_DEFAULT_TAB_FORCE) - s->ac = AC_RANGE_DEFAULT_TAB; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); s->plane_count = 3; - switch(avctx->pix_fmt) { + switch(pix_fmt) { case AV_PIX_FMT_GRAY9: case AV_PIX_FMT_YUV444P9: case AV_PIX_FMT_YUV422P9: @@ -879,6 +871,26 @@ static int encode_init_internal(AVCodecContext *avctx) } av_assert0(s->bits_per_raw_sample >= 8); + return av_pix_fmt_get_chroma_sub_sample (avctx->pix_fmt, &s->chroma_h_shift, &s->chroma_v_shift); +} + +static int encode_init_internal(AVCodecContext *avctx) +{ + int ret; + FFV1Context *s = avctx->priv_data; + + if ((ret = ff_ffv1_common_init(avctx)) < 0) + return ret; + + if (s->ac == 1) // Compatbility with common command line usage + s->ac = AC_RANGE_CUSTOM_TAB; + else if (s->ac == AC_RANGE_DEFAULT_TAB_FORCE) + s->ac = AC_RANGE_DEFAULT_TAB; + + ret = ff_ffv1_encode_setup_plane_info(avctx, avctx->pix_fmt); + if (ret < 0) + return ret; + if (s->bits_per_raw_sample > 8) { if (s->ac == AC_GOLOMB_RICE) { av_log(avctx, AV_LOG_INFO, @@ -887,10 +899,6 @@ static int encode_init_internal(AVCodecContext *avctx) } } - ret = av_pix_fmt_get_chroma_sub_sample (avctx->pix_fmt, &s->chroma_h_shift, &s->chroma_v_shift); - if (ret) - return ret; - { int plane_count = 1 + 2*s->chroma_planes + s->transparency; int max_h_slices = AV_CEIL_RSHIFT(avctx->width , s->chroma_h_shift); diff --git a/libavcodec/ffv1enc.h b/libavcodec/ffv1enc.h index c062af0bf5..f7b2e6cdbf 100644 --- a/libavcodec/ffv1enc.h +++ b/libavcodec/ffv1enc.h @@ -26,5 +26,7 @@ #include "avcodec.h" av_cold int ff_ffv1_encode_init(AVCodecContext *avctx); +av_cold int ff_ffv1_encode_setup_plane_info(AVCodecContext *avctx, + enum AVPixelFormat pix_fmt); #endif /* AVCODEC_FFV1ENC_H */ -- 2.45.2.753.g447d99e1c3b _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".