X-Git-Url: https://granicus.if.org/sourcecode?a=blobdiff_plain;f=tools_common.c;h=20b259ca94b8405868c06c1a321dc868cc5dcf5c;hb=b6d874d73bc2514c99603eecf025ab882567e549;hp=30fd3520519987c2bbebb26a4ee03aa4a96c590c;hpb=f6ff752c6321af8502be8fd0bc6b6192a825c76b;p=libvpx diff --git a/tools_common.c b/tools_common.c index 30fd35205..20b259ca9 100644 --- a/tools_common.c +++ b/tools_common.c @@ -16,11 +16,11 @@ #include "./tools_common.h" -#if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER +#if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER || CONFIG_VP10_ENCODER #include "vpx/vp8cx.h" #endif -#if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER +#if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER || CONFIG_VP10_DECODER #include "vpx/vp8dx.h" #endif @@ -130,7 +130,13 @@ int read_yuv_frame(struct VpxInputContext *input_ctx, vpx_image_t *yuv_frame) { return shortread; } +#if CONFIG_ENCODERS + static const VpxInterface vpx_encoders[] = { +#if CONFIG_VP10_ENCODER + {"vp10", VP10_FOURCC, &vpx_codec_vp10_cx}, +#endif + #if CONFIG_VP8_ENCODER {"vp8", VP8_FOURCC, &vpx_codec_vp8_cx}, #endif @@ -140,7 +146,7 @@ static const VpxInterface vpx_encoders[] = { #endif }; -int get_vpx_encoder_count() { +int get_vpx_encoder_count(void) { return sizeof(vpx_encoders) / sizeof(vpx_encoders[0]); } @@ -160,6 +166,10 @@ const VpxInterface *get_vpx_encoder_by_name(const char *name) { return NULL; } +#endif // CONFIG_ENCODERS + +#if CONFIG_DECODERS + static const VpxInterface vpx_decoders[] = { #if CONFIG_VP8_DECODER {"vp8", VP8_FOURCC, &vpx_codec_vp8_dx}, @@ -168,9 +178,13 @@ static const VpxInterface vpx_decoders[] = { #if CONFIG_VP9_DECODER {"vp9", VP9_FOURCC, &vpx_codec_vp9_dx}, #endif + +#if CONFIG_VP10_DECODER + {"vp10", VP10_FOURCC, &vpx_codec_vp10_dx}, +#endif }; -int get_vpx_decoder_count() { +int get_vpx_decoder_count(void) { return sizeof(vpx_decoders) / sizeof(vpx_decoders[0]); } @@ -202,6 +216,8 @@ const VpxInterface *get_vpx_decoder_by_fourcc(uint32_t fourcc) { return NULL; } +#endif // CONFIG_DECODERS + // TODO(dkovalev): move this function to vpx_image.{c, h}, so it will be part // of vpx_image_t support int vpx_img_plane_width(const vpx_image_t *img, int plane) { @@ -270,13 +286,13 @@ double sse_to_psnr(double samples, double peak, double sse) { } // TODO(debargha): Consolidate the functions below into a separate file. -#if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH +#if CONFIG_VP9_HIGHBITDEPTH static void highbd_img_upshift(vpx_image_t *dst, vpx_image_t *src, int input_shift) { // Note the offset is 1 less than half. const int offset = input_shift > 0 ? (1 << (input_shift - 1)) - 1 : 0; int plane; - if (dst->w != src->w || dst->h != src->h || + if (dst->d_w != src->d_w || dst->d_h != src->d_h || dst->x_chroma_shift != src->x_chroma_shift || dst->y_chroma_shift != src->y_chroma_shift || dst->fmt != src->fmt || input_shift < 0) { @@ -293,12 +309,12 @@ static void highbd_img_upshift(vpx_image_t *dst, vpx_image_t *src, break; } for (plane = 0; plane < 3; plane++) { - int w = src->w; - int h = src->h; + int w = src->d_w; + int h = src->d_h; int x, y; if (plane) { - w >>= src->x_chroma_shift; - h >>= src->y_chroma_shift; + w = (w + src->x_chroma_shift) >> src->x_chroma_shift; + h = (h + src->y_chroma_shift) >> src->y_chroma_shift; } for (y = 0; y < h; y++) { uint16_t *p_src = @@ -316,7 +332,7 @@ static void lowbd_img_upshift(vpx_image_t *dst, vpx_image_t *src, // Note the offset is 1 less than half. const int offset = input_shift > 0 ? (1 << (input_shift - 1)) - 1 : 0; int plane; - if (dst->w != src->w || dst->h != src->h || + if (dst->d_w != src->d_w || dst->d_h != src->d_h || dst->x_chroma_shift != src->x_chroma_shift || dst->y_chroma_shift != src->y_chroma_shift || dst->fmt != src->fmt + VPX_IMG_FMT_HIGHBITDEPTH || @@ -334,8 +350,8 @@ static void lowbd_img_upshift(vpx_image_t *dst, vpx_image_t *src, break; } for (plane = 0; plane < 3; plane++) { - int w = src->w; - int h = src->h; + int w = src->d_w; + int h = src->d_h; int x, y; if (plane) { w = (w + src->x_chroma_shift) >> src->x_chroma_shift; @@ -384,15 +400,15 @@ void vpx_img_truncate_16_to_8(vpx_image_t *dst, vpx_image_t *src) { int h = src->d_h; int x, y; if (plane) { - w >>= src->x_chroma_shift; - h >>= src->y_chroma_shift; + w = (w + src->x_chroma_shift) >> src->x_chroma_shift; + h = (h + src->y_chroma_shift) >> src->y_chroma_shift; } for (y = 0; y < h; y++) { uint16_t *p_src = (uint16_t *)(src->planes[plane] + y * src->stride[plane]); uint8_t *p_dst = dst->planes[plane] + y * dst->stride[plane]; for (x = 0; x < w; x++) { - *p_dst++ = *p_src++; + *p_dst++ = (uint8_t)(*p_src++); } } } @@ -483,4 +499,4 @@ void vpx_img_downshift(vpx_image_t *dst, vpx_image_t *src, lowbd_img_downshift(dst, src, down_shift); } } -#endif // CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH +#endif // CONFIG_VP9_HIGHBITDEPTH