[FFmpeg-devel] [PATCH 4/7] Adds gray floating-point pixel formats.
Martin Vignali
martin.vignali at gmail.com
Thu Aug 2 22:22:38 EEST 2018
>
> +static int uint_y_to_float_y_wrapper(SwsContext *c, const uint8_t *src[],
> + int srcStride[], int srcSliceY,
> + int srcSliceH, uint8_t *dst[], int
> dstStride[])
> +{
> + int y, x;
> + int dstStrideFloat = dstStride[0] >> 2;;
> + const uint8_t *srcPtr = src[0];
> + float *dstPtr = (float *)(dst[0] + dstStride[0] * srcSliceY);
> +
> + for (y = 0; y < srcSliceH; ++y){
> + for (x = 0; x < c->srcW; ++x){
> + dstPtr[x] = (float)srcPtr[x] / 255.0f;
> + }
> + srcPtr += srcStride[0];
> + dstPtr += dstStrideFloat;
> + }
> +
> + return srcSliceH;
> +}
> +
> +static int float_y_to_uint_y_wrapper(SwsContext *c, const uint8_t* src[],
> + int srcStride[], int srcSliceY,
> + int srcSliceH, uint8_t* dst[], int
> dstStride[])
> +{
> + int y, x;
> + int srcStrideFloat = srcStride[0] >> 2;
> + const float *srcPtr = (const float *)src[0];
> + uint8_t *dstPtr = dst[0] + dstStride[0] * srcSliceY;
> +
> + for (y = 0; y < srcSliceH; ++y){
> + for (x = 0; x < c->srcW; ++x){
> + dstPtr[x] = (uint8_t)(255.0f * FFMIN(FFMAX(srcPtr[x], 0.0f),
> 1.0f));
> + }
> + srcPtr += srcStrideFloat;
> + dstPtr += dstStride[0];
> + }
> +
> + return srcSliceH;
> +}
>
Maybe you can avoid to use float for these conversions
like in libavcodec/exr.c, where there is a float to uint16 conversion
Martin
More information about the ffmpeg-devel
mailing list