Message ID | 20200720180142.1967039-1-jzern@google.com |
---|---|
State | Accepted |
Commit | b5f1e057e1d102606156fd982eea5d74b305fc74 |
Headers | show |
Series | [FFmpeg-devel] avcodec/libvpxenc: use pix_fmt descriptors where useful | expand |
Context | Check | Description |
---|---|---|
andriy/default | pending | |
andriy/make | success | Make finished |
andriy/make_fate | success | Make fate finished |
On 7/20/2020 3:01 PM, James Zern wrote: > similar to: > 36e51c190b avcodec/libaomenc: use pix_fmt descriptors where useful > > Signed-off-by: James Zern <jzern@google.com> > --- > libavcodec/libvpxenc.c | 13 +++---------- > 1 file changed, 3 insertions(+), 10 deletions(-) > > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c > index 8e0ea42375..3d5e6c12e3 100644 > --- a/libavcodec/libvpxenc.c > +++ b/libavcodec/libvpxenc.c > @@ -41,6 +41,7 @@ > #include "libavutil/intreadwrite.h" > #include "libavutil/mathematics.h" > #include "libavutil/opt.h" > +#include "libavutil/pixdesc.h" > > /** > * Portion of struct vpx_codec_cx_pkt from vpx_encoder.h. > @@ -546,7 +547,8 @@ static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps, > vpx_img_fmt_t *img_fmt) > { > VPxContext av_unused *ctx = avctx->priv_data; > - enccfg->g_bit_depth = enccfg->g_input_bit_depth = 8; > + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); > + enccfg->g_bit_depth = enccfg->g_input_bit_depth = desc->comp[0].depth; > switch (avctx->pix_fmt) { > case AV_PIX_FMT_YUV420P: > case AV_PIX_FMT_YUVA420P: > @@ -570,8 +572,6 @@ static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps, > case AV_PIX_FMT_YUV420P10: > case AV_PIX_FMT_YUV420P12: > if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) { > - enccfg->g_bit_depth = enccfg->g_input_bit_depth = > - avctx->pix_fmt == AV_PIX_FMT_YUV420P10 ? 10 : 12; > enccfg->g_profile = 2; > *img_fmt = VPX_IMG_FMT_I42016; > *flags |= VPX_CODEC_USE_HIGHBITDEPTH; > @@ -581,8 +581,6 @@ static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps, > case AV_PIX_FMT_YUV422P10: > case AV_PIX_FMT_YUV422P12: > if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) { > - enccfg->g_bit_depth = enccfg->g_input_bit_depth = > - avctx->pix_fmt == AV_PIX_FMT_YUV422P10 ? 10 : 12; > enccfg->g_profile = 3; > *img_fmt = VPX_IMG_FMT_I42216; > *flags |= VPX_CODEC_USE_HIGHBITDEPTH; > @@ -592,8 +590,6 @@ static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps, > case AV_PIX_FMT_YUV440P10: > case AV_PIX_FMT_YUV440P12: > if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) { > - enccfg->g_bit_depth = enccfg->g_input_bit_depth = > - avctx->pix_fmt == AV_PIX_FMT_YUV440P10 ? 10 : 12; > enccfg->g_profile = 3; > *img_fmt = VPX_IMG_FMT_I44016; > *flags |= VPX_CODEC_USE_HIGHBITDEPTH; > @@ -606,9 +602,6 @@ static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps, > case AV_PIX_FMT_YUV444P10: > case AV_PIX_FMT_YUV444P12: > if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) { > - enccfg->g_bit_depth = enccfg->g_input_bit_depth = > - avctx->pix_fmt == AV_PIX_FMT_YUV444P10 || > - avctx->pix_fmt == AV_PIX_FMT_GBRP10 ? 10 : 12; > enccfg->g_profile = 3; > *img_fmt = VPX_IMG_FMT_I44416; > *flags |= VPX_CODEC_USE_HIGHBITDEPTH; LGTM
On Mon, Jul 20, 2020 at 9:04 PM James Almer <jamrial@gmail.com> wrote: > > On 7/20/2020 3:01 PM, James Zern wrote: > > similar to: > > 36e51c190b avcodec/libaomenc: use pix_fmt descriptors where useful > > > > Signed-off-by: James Zern <jzern@google.com> > > --- > > libavcodec/libvpxenc.c | 13 +++---------- > > 1 file changed, 3 insertions(+), 10 deletions(-) > > > > diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c > > index 8e0ea42375..3d5e6c12e3 100644 > > --- a/libavcodec/libvpxenc.c > > +++ b/libavcodec/libvpxenc.c > > @@ -41,6 +41,7 @@ > > #include "libavutil/intreadwrite.h" > > #include "libavutil/mathematics.h" > > #include "libavutil/opt.h" > > +#include "libavutil/pixdesc.h" > > > > /** > > * Portion of struct vpx_codec_cx_pkt from vpx_encoder.h. > > @@ -546,7 +547,8 @@ static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps, > > vpx_img_fmt_t *img_fmt) > > { > > VPxContext av_unused *ctx = avctx->priv_data; > > - enccfg->g_bit_depth = enccfg->g_input_bit_depth = 8; > > + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); > > + enccfg->g_bit_depth = enccfg->g_input_bit_depth = desc->comp[0].depth; > > switch (avctx->pix_fmt) { > > case AV_PIX_FMT_YUV420P: > > case AV_PIX_FMT_YUVA420P: > > @@ -570,8 +572,6 @@ static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps, > > case AV_PIX_FMT_YUV420P10: > > case AV_PIX_FMT_YUV420P12: > > if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) { > > - enccfg->g_bit_depth = enccfg->g_input_bit_depth = > > - avctx->pix_fmt == AV_PIX_FMT_YUV420P10 ? 10 : 12; > > enccfg->g_profile = 2; > > *img_fmt = VPX_IMG_FMT_I42016; > > *flags |= VPX_CODEC_USE_HIGHBITDEPTH; > > @@ -581,8 +581,6 @@ static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps, > > case AV_PIX_FMT_YUV422P10: > > case AV_PIX_FMT_YUV422P12: > > if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) { > > - enccfg->g_bit_depth = enccfg->g_input_bit_depth = > > - avctx->pix_fmt == AV_PIX_FMT_YUV422P10 ? 10 : 12; > > enccfg->g_profile = 3; > > *img_fmt = VPX_IMG_FMT_I42216; > > *flags |= VPX_CODEC_USE_HIGHBITDEPTH; > > @@ -592,8 +590,6 @@ static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps, > > case AV_PIX_FMT_YUV440P10: > > case AV_PIX_FMT_YUV440P12: > > if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) { > > - enccfg->g_bit_depth = enccfg->g_input_bit_depth = > > - avctx->pix_fmt == AV_PIX_FMT_YUV440P10 ? 10 : 12; > > enccfg->g_profile = 3; > > *img_fmt = VPX_IMG_FMT_I44016; > > *flags |= VPX_CODEC_USE_HIGHBITDEPTH; > > @@ -606,9 +602,6 @@ static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps, > > case AV_PIX_FMT_YUV444P10: > > case AV_PIX_FMT_YUV444P12: > > if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) { > > - enccfg->g_bit_depth = enccfg->g_input_bit_depth = > > - avctx->pix_fmt == AV_PIX_FMT_YUV444P10 || > > - avctx->pix_fmt == AV_PIX_FMT_GBRP10 ? 10 : 12; > > enccfg->g_profile = 3; > > *img_fmt = VPX_IMG_FMT_I44416; > > *flags |= VPX_CODEC_USE_HIGHBITDEPTH; > > LGTM pushed.
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 8e0ea42375..3d5e6c12e3 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -41,6 +41,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/mathematics.h" #include "libavutil/opt.h" +#include "libavutil/pixdesc.h" /** * Portion of struct vpx_codec_cx_pkt from vpx_encoder.h. @@ -546,7 +547,8 @@ static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps, vpx_img_fmt_t *img_fmt) { VPxContext av_unused *ctx = avctx->priv_data; - enccfg->g_bit_depth = enccfg->g_input_bit_depth = 8; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); + enccfg->g_bit_depth = enccfg->g_input_bit_depth = desc->comp[0].depth; switch (avctx->pix_fmt) { case AV_PIX_FMT_YUV420P: case AV_PIX_FMT_YUVA420P: @@ -570,8 +572,6 @@ static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps, case AV_PIX_FMT_YUV420P10: case AV_PIX_FMT_YUV420P12: if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) { - enccfg->g_bit_depth = enccfg->g_input_bit_depth = - avctx->pix_fmt == AV_PIX_FMT_YUV420P10 ? 10 : 12; enccfg->g_profile = 2; *img_fmt = VPX_IMG_FMT_I42016; *flags |= VPX_CODEC_USE_HIGHBITDEPTH; @@ -581,8 +581,6 @@ static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps, case AV_PIX_FMT_YUV422P10: case AV_PIX_FMT_YUV422P12: if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) { - enccfg->g_bit_depth = enccfg->g_input_bit_depth = - avctx->pix_fmt == AV_PIX_FMT_YUV422P10 ? 10 : 12; enccfg->g_profile = 3; *img_fmt = VPX_IMG_FMT_I42216; *flags |= VPX_CODEC_USE_HIGHBITDEPTH; @@ -592,8 +590,6 @@ static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps, case AV_PIX_FMT_YUV440P10: case AV_PIX_FMT_YUV440P12: if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) { - enccfg->g_bit_depth = enccfg->g_input_bit_depth = - avctx->pix_fmt == AV_PIX_FMT_YUV440P10 ? 10 : 12; enccfg->g_profile = 3; *img_fmt = VPX_IMG_FMT_I44016; *flags |= VPX_CODEC_USE_HIGHBITDEPTH; @@ -606,9 +602,6 @@ static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps, case AV_PIX_FMT_YUV444P10: case AV_PIX_FMT_YUV444P12: if (codec_caps & VPX_CODEC_CAP_HIGHBITDEPTH) { - enccfg->g_bit_depth = enccfg->g_input_bit_depth = - avctx->pix_fmt == AV_PIX_FMT_YUV444P10 || - avctx->pix_fmt == AV_PIX_FMT_GBRP10 ? 10 : 12; enccfg->g_profile = 3; *img_fmt = VPX_IMG_FMT_I44416; *flags |= VPX_CODEC_USE_HIGHBITDEPTH;
similar to: 36e51c190b avcodec/libaomenc: use pix_fmt descriptors where useful Signed-off-by: James Zern <jzern@google.com> --- libavcodec/libvpxenc.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)