[FFmpeg-devel,v2,4/6] ffv1enc: move plane info init into a separate function
Checks
Context |
Check |
Description |
yinshiyou/make_loongarch64 |
success
|
Make finished
|
yinshiyou/make_fate_loongarch64 |
success
|
Make fate finished
|
andriy/make_x86 |
success
|
Make finished
|
andriy/make_fate_x86 |
success
|
Make fate finished
|
Commit Message
---
libavcodec/ffv1enc.c | 40 ++++++++++++++++++++++++----------------
libavcodec/ffv1enc.h | 2 ++
2 files changed, 26 insertions(+), 16 deletions(-)
Comments
On Mon, Nov 11, 2024 at 04:40:16AM +0100, Lynne via ffmpeg-devel wrote:
> ---
> libavcodec/ffv1enc.c | 40 ++++++++++++++++++++++++----------------
> libavcodec/ffv1enc.h | 2 ++
> 2 files changed, 26 insertions(+), 16 deletions(-)
should be ok
thx
[...]
@@ -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);
@@ -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 */