summaryrefslogtreecommitdiff
path: root/libswscale/input.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-06-13 21:04:06 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-06-13 22:43:57 +0200
commitc7b9eab2be7099b0d4f2fed4feaf69a7dda379f0 (patch)
tree019d5b0a7eaa5e15782ec67d61100d9a3f91e916 /libswscale/input.c
parent4a6d790a6fc0de15112a7bbfe8b2b58ef058a48d (diff)
parent8517e9c476e8cf92d9ed25b6486bb43d3dc2c49d (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: rtmp: Add a new option 'rtmp_buffer', for setting the client buffer time rtmp: Set the client buffer time to 3s instead of 0.26s rtmp: Handle server bandwidth packets rtmp: Display a verbose message when an unknown packet type is received lavfi/audio: use av_samples_copy() instead of custom code. configure: add all filters hardcoded into avconv to avconv_deps avfiltergraph: remove a redundant call to avfilter_get_by_name(). lavfi: allow building without swscale. build: Do not delete tests/vsynth2 directory, which is no longer created. lavfi: replace AVFilterContext.input/output_count with nb_inputs/outputs lavfi: make AVFilterPad opaque after two major bumps. lavfi: add avfilter_pad_get_type() and avfilter_pad_get_name(). lavfi: make avfilter_get_video_buffer() private on next bump. jack: update to new latency range API as the old one has been deprecated rtmp: Tokenize the AMF connection parameters manually instead of using strtok_r ppc: Rename H.264 optimization template file for consistency. lavfi: add channelsplit audio filter. golomb: check remaining bits during unary decoding in get_ur_golomb_jpegls() sws: fix planar RGB input conversions for 9/10/16 bpp. Conflicts: Changelog configure doc/APIchanges ffmpeg.c libavcodec/golomb.h libavcodec/v210dec.h libavfilter/Makefile libavfilter/allfilters.c libavfilter/asrc_anullsrc.c libavfilter/audio.c libavfilter/avfilter.c libavfilter/avfilter.h libavfilter/avfiltergraph.c libavfilter/buffersrc.c libavfilter/formats.c libavfilter/version.h libavfilter/vf_frei0r.c libavfilter/vf_pad.c libavfilter/vf_scale.c libavfilter/video.h libavfilter/vsrc_color.c libavformat/rtmpproto.c libswscale/input.c tests/Makefile Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswscale/input.c')
-rw-r--r--libswscale/input.c138
1 files changed, 97 insertions, 41 deletions
diff --git a/libswscale/input.c b/libswscale/input.c
index 018cd30adb..c9c91d0bca 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -677,80 +677,120 @@ static void planar_rgb_to_y(uint16_t *dst, const uint8_t *src[4], int width)
}
}
-static void planar_rgb16le_to_y(uint8_t *_dst, const uint8_t *_src[4], int width)
+static void planar_rgb_to_uv(uint16_t *dstU, uint16_t *dstV, const uint8_t *src[4], int width)
{
int i;
- const uint16_t **src = (const uint16_t **)_src;
- uint16_t *dst = (uint16_t *)_dst;
for (i = 0; i < width; i++) {
- int g = AV_RL16(src[0] + i);
- int b = AV_RL16(src[1] + i);
- int r = AV_RL16(src[2] + i);
+ int g = src[0][i];
+ int b = src[1][i];
+ int r = src[2][i];
- dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
+ dstU[i] = (RU*r + GU*g + BU*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
+ dstV[i] = (RV*r + GV*g + BV*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
}
}
-static void planar_rgb16be_to_y(uint8_t *_dst, const uint8_t *_src[4], int width)
+#define rdpx(src) \
+ is_be ? AV_RB16(src) : AV_RL16(src)
+static av_always_inline void planar_rgb16_to_y(uint8_t *_dst, const uint8_t *_src[4],
+ int width, int bpc, int is_be)
{
int i;
const uint16_t **src = (const uint16_t **)_src;
uint16_t *dst = (uint16_t *)_dst;
for (i = 0; i < width; i++) {
- int g = AV_RB16(src[0] + i);
- int b = AV_RB16(src[1] + i);
- int r = AV_RB16(src[2] + i);
+ int g = rdpx(src[0] + i);
+ int b = rdpx(src[1] + i);
+ int r = rdpx(src[2] + i);
- dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT - 1))) >> RGB2YUV_SHIFT);
+ dst[i] = ((RY * r + GY * g + BY * b + (33 << (RGB2YUV_SHIFT + bpc - 9))) >> RGB2YUV_SHIFT);
}
}
-static void planar_rgb_to_uv(uint16_t *dstU, uint16_t *dstV, const uint8_t *src[4], int width)
+static void planar_rgb9le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
{
- int i;
- for (i = 0; i < width; i++) {
- int g = src[0][i];
- int b = src[1][i];
- int r = src[2][i];
+ planar_rgb16_to_y(dst, src, w, 9, 0);
+}
- dstU[i] = (RU*r + GU*g + BU*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
- dstV[i] = (RV*r + GV*g + BV*b + (0x4001<<(RGB2YUV_SHIFT-7))) >> (RGB2YUV_SHIFT-6);
- }
+static void planar_rgb9be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
+{
+ planar_rgb16_to_y(dst, src, w, 9, 1);
}
-static void planar_rgb16le_to_uv(uint8_t *_dstU, uint8_t *_dstV,
- const uint8_t *_src[4], int width)
+static void planar_rgb10le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
{
- int i;
- const uint16_t **src = (const uint16_t **)_src;
- uint16_t *dstU = (uint16_t *)_dstU;
- uint16_t *dstV = (uint16_t *)_dstV;
- for (i = 0; i < width; i++) {
- int g = AV_RL16(src[0] + i);
- int b = AV_RL16(src[1] + i);
- int r = AV_RL16(src[2] + i);
+ planar_rgb16_to_y(dst, src, w, 10, 0);
+}
- dstU[i] = (RU * r + GU * g + BU * b + (257 << RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT + 1);
- dstV[i] = (RV * r + GV * g + BV * b + (257 << RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT + 1);
- }
+static void planar_rgb10be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
+{
+ planar_rgb16_to_y(dst, src, w, 10, 1);
+}
+
+static void planar_rgb16le_to_y(uint8_t *dst, const uint8_t *src[4], int w)
+{
+ planar_rgb16_to_y(dst, src, w, 16, 0);
}
-static void planar_rgb16be_to_uv(uint8_t *_dstU, uint8_t *_dstV,
- const uint8_t *_src[4], int width)
+static void planar_rgb16be_to_y(uint8_t *dst, const uint8_t *src[4], int w)
+{
+ planar_rgb16_to_y(dst, src, w, 16, 1);
+}
+
+static av_always_inline void planar_rgb16_to_uv(uint8_t *_dstU, uint8_t *_dstV,
+ const uint8_t *_src[4], int width,
+ int bpc, int is_be)
{
int i;
const uint16_t **src = (const uint16_t **)_src;
uint16_t *dstU = (uint16_t *)_dstU;
uint16_t *dstV = (uint16_t *)_dstV;
for (i = 0; i < width; i++) {
- int g = AV_RB16(src[0] + i);
- int b = AV_RB16(src[1] + i);
- int r = AV_RB16(src[2] + i);
+ int g = rdpx(src[0] + i);
+ int b = rdpx(src[1] + i);
+ int r = rdpx(src[2] + i);
- dstU[i] = (RU * r + GU * g + BU * b + (257 << RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT + 1);
- dstV[i] = (RV * r + GV * g + BV * b + (257 << RGB2YUV_SHIFT)) >> (RGB2YUV_SHIFT + 1);
+ dstU[i] = (RU * r + GU * g + BU * b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> RGB2YUV_SHIFT;
+ dstV[i] = (RV * r + GV * g + BV * b + (257 << (RGB2YUV_SHIFT + bpc - 9))) >> RGB2YUV_SHIFT;
}
}
+#undef rdpx
+
+static void planar_rgb9le_to_uv(uint8_t *dstU, uint8_t *dstV,
+ const uint8_t *src[4], int w)
+{
+ planar_rgb16_to_uv(dstU, dstV, src, w, 9, 0);
+}
+
+static void planar_rgb9be_to_uv(uint8_t *dstU, uint8_t *dstV,
+ const uint8_t *src[4], int w)
+{
+ planar_rgb16_to_uv(dstU, dstV, src, w, 9, 1);
+}
+
+static void planar_rgb10le_to_uv(uint8_t *dstU, uint8_t *dstV,
+ const uint8_t *src[4], int w)
+{
+ planar_rgb16_to_uv(dstU, dstV, src, w, 10, 0);
+}
+
+static void planar_rgb10be_to_uv(uint8_t *dstU, uint8_t *dstV,
+ const uint8_t *src[4], int w)
+{
+ planar_rgb16_to_uv(dstU, dstV, src, w, 10, 1);
+}
+
+static void planar_rgb16le_to_uv(uint8_t *dstU, uint8_t *dstV,
+ const uint8_t *src[4], int w)
+{
+ planar_rgb16_to_uv(dstU, dstV, src, w, 16, 0);
+}
+
+static void planar_rgb16be_to_uv(uint8_t *dstU, uint8_t *dstV,
+ const uint8_t *src[4], int w)
+{
+ planar_rgb16_to_uv(dstU, dstV, src, w, 16, 1);
+}
av_cold void ff_sws_init_input_funcs(SwsContext *c)
{
@@ -778,12 +818,20 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
c->chrToYV12 = palToUV_c;
break;
case PIX_FMT_GBRP9LE:
+ c->readChrPlanar = planar_rgb9le_to_uv;
+ break;
case PIX_FMT_GBRP10LE:
+ c->readChrPlanar = planar_rgb10le_to_uv;
+ break;
case PIX_FMT_GBRP16LE:
c->readChrPlanar = planar_rgb16le_to_uv;
break;
case PIX_FMT_GBRP9BE:
+ c->readChrPlanar = planar_rgb9be_to_uv;
+ break;
case PIX_FMT_GBRP10BE:
+ c->readChrPlanar = planar_rgb10be_to_uv;
+ break;
case PIX_FMT_GBRP16BE:
c->readChrPlanar = planar_rgb16be_to_uv;
break;
@@ -975,12 +1023,20 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c)
c->alpToYV12 = NULL;
switch (srcFormat) {
case PIX_FMT_GBRP9LE:
+ c->readLumPlanar = planar_rgb9le_to_y;
+ break;
case PIX_FMT_GBRP10LE:
+ c->readLumPlanar = planar_rgb10le_to_y;
+ break;
case PIX_FMT_GBRP16LE:
c->readLumPlanar = planar_rgb16le_to_y;
break;
case PIX_FMT_GBRP9BE:
+ c->readLumPlanar = planar_rgb9be_to_y;
+ break;
case PIX_FMT_GBRP10BE:
+ c->readLumPlanar = planar_rgb10be_to_y;
+ break;
case PIX_FMT_GBRP16BE:
c->readLumPlanar = planar_rgb16be_to_y;
break;