summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-11-05 17:02:04 +0100
committerwm4 <wm4@nowhere>2012-11-12 20:06:14 +0100
commitd4bdd0473d6f43132257c9fb3848d829755167a3 (patch)
tree8021c2f7da1841393c8c832105e20cd527826d6c /video
parentbd48deba77bd5582c5829d6fe73a7d2571088aba (diff)
downloadmpv-d4bdd0473d6f43132257c9fb3848d829755167a3.tar.bz2
mpv-d4bdd0473d6f43132257c9fb3848d829755167a3.tar.xz
Rename directories, move files (step 1 of 2) (does not compile)
Tis drops the silly lib prefixes, and attempts to organize the tree in a more logical way. Make the top-level directory less cluttered as well. Renames the following directories: libaf -> audio/filter libao2 -> audio/out libvo -> video/out libmpdemux -> demux Split libmpcodecs: vf* -> video/filter vd*, dec_video.* -> video/decode mp_image*, img_format*, ... -> video/ ad*, dec_audio.* -> audio/decode libaf/format.* is moved to audio/ - this is similar to how mp_image.* is located in video/. Move most top-level .c/.h files to core. (talloc.c/.h is left on top- level, because it's external.) Park some of the more annoying files in compat/. Some of these are relicts from the time mplayer used ffmpeg internals. sub/ is not split, because it's too much of a mess (subtitle code is mixed with OSD display and rendering). Maybe the organization of core is not ideal: it mixes playback core (like mplayer.c) and utility helpers (like bstr.c/h). Should the need arise, the playback core will be moved somewhere else, while core contains all helper and common code.
Diffstat (limited to 'video')
-rw-r--r--video/csputils.c391
-rw-r--r--video/csputils.h151
-rw-r--r--video/decode/dec_video.c448
-rw-r--r--video/decode/dec_video.h51
-rw-r--r--video/decode/vd.c273
-rw-r--r--video/decode/vd.h60
-rw-r--r--video/decode/vd_lavc.c857
-rw-r--r--video/filter/pullup.c817
-rw-r--r--video/filter/pullup.h102
-rw-r--r--video/filter/vf.c830
-rw-r--r--video/filter/vf.h189
-rw-r--r--video/filter/vf_crop.c196
-rw-r--r--video/filter/vf_delogo.c379
-rw-r--r--video/filter/vf_divtc.c723
-rw-r--r--video/filter/vf_dlopen.c389
-rw-r--r--video/filter/vf_dlopen.h88
-rw-r--r--video/filter/vf_down3dright.c166
-rw-r--r--video/filter/vf_dsize.c125
-rw-r--r--video/filter/vf_eq2.c519
-rw-r--r--video/filter/vf_expand.c350
-rw-r--r--video/filter/vf_flip.c110
-rw-r--r--video/filter/vf_format.c91
-rw-r--r--video/filter/vf_gradfun.c450
-rw-r--r--video/filter/vf_hqdn3d.c373
-rw-r--r--video/filter/vf_ilpack.c457
-rw-r--r--video/filter/vf_mirror.c131
-rw-r--r--video/filter/vf_noformat.c77
-rw-r--r--video/filter/vf_noise.c470
-rw-r--r--video/filter/vf_phase.c303
-rw-r--r--video/filter/vf_pp.c196
-rw-r--r--video/filter/vf_pullup.c333
-rw-r--r--video/filter/vf_rotate.c152
-rw-r--r--video/filter/vf_scale.c718
-rw-r--r--video/filter/vf_screenshot.c219
-rw-r--r--video/filter/vf_softpulldown.c182
-rw-r--r--video/filter/vf_stereo3d.c527
-rw-r--r--video/filter/vf_sub.c309
-rw-r--r--video/filter/vf_swapuv.c106
-rw-r--r--video/filter/vf_unsharp.c321
-rw-r--r--video/filter/vf_vo.c202
-rw-r--r--video/filter/vf_yadif.c533
-rw-r--r--video/fmt-conversion.c144
-rw-r--r--video/fmt-conversion.h27
-rw-r--r--video/image_writer.c327
-rw-r--r--video/image_writer.h53
-rw-r--r--video/img_format.c233
-rw-r--r--video/img_format.h243
-rw-r--r--video/memcpy_pic.h77
-rw-r--r--video/mp_image.c280
-rw-r--r--video/mp_image.h162
-rw-r--r--video/out/aspect.c148
-rw-r--r--video/out/aspect.h37
-rw-r--r--video/out/bitmap_packer.c227
-rw-r--r--video/out/bitmap_packer.h68
-rw-r--r--video/out/cocoa_common.h55
-rw-r--r--video/out/cocoa_common.m865
-rw-r--r--video/out/d3d_shader_yuv.h142
-rw-r--r--video/out/d3d_shader_yuv.hlsl44
-rw-r--r--video/out/d3d_shader_yuv_2ch.h170
-rw-r--r--video/out/filter_kernels.c279
-rw-r--r--video/out/filter_kernels.h45
-rw-r--r--video/out/geometry.c112
-rw-r--r--video/out/geometry.h29
-rw-r--r--video/out/gl_common.c2654
-rw-r--r--video/out/gl_common.h396
-rw-r--r--video/out/gl_header_fixes.h257
-rw-r--r--video/out/gl_osd.c324
-rw-r--r--video/out/gl_osd.h43
-rw-r--r--video/out/osx_common.c145
-rw-r--r--video/out/osx_common.h27
-rw-r--r--video/out/pnm_loader.c97
-rw-r--r--video/out/pnm_loader.h52
-rw-r--r--video/out/vo.c530
-rw-r--r--video/out/vo.h352
-rw-r--r--video/out/vo_caca.c395
-rw-r--r--video/out/vo_corevideo.h28
-rw-r--r--video/out/vo_corevideo.m457
-rw-r--r--video/out/vo_direct3d.c2101
-rw-r--r--video/out/vo_image.c198
-rw-r--r--video/out/vo_lavc.c553
-rw-r--r--video/out/vo_null.c103
-rw-r--r--video/out/vo_opengl.c2419
-rw-r--r--video/out/vo_opengl_old.c1166
-rw-r--r--video/out/vo_opengl_shaders.glsl355
-rw-r--r--video/out/vo_vdpau.c1718
-rw-r--r--video/out/vo_x11.c620
-rw-r--r--video/out/vo_xv.c716
-rw-r--r--video/out/w32_common.c757
-rw-r--r--video/out/w32_common.h66
-rw-r--r--video/out/x11_common.c2404
-rw-r--r--video/out/x11_common.h184
-rw-r--r--video/sws_utils.c199
-rw-r--r--video/sws_utils.h33
-rw-r--r--video/vfcap.h46
94 files changed, 36526 insertions, 0 deletions
diff --git a/video/csputils.c b/video/csputils.c
new file mode 100644
index 0000000000..23eb099f69
--- /dev/null
+++ b/video/csputils.c
@@ -0,0 +1,391 @@
+/*
+ * Common code related to colorspaces and conversion
+ *
+ * Copyleft (C) 2009 Reimar Döffinger <Reimar.Doeffinger@gmx.de>
+ *
+ * mp_invert_yuv2rgb based on DarkPlaces engine, original code (GPL2 or later)
+ *
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * You can alternatively redistribute this file and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ */
+
+#include <stdint.h>
+#include <math.h>
+#include <assert.h>
+#include <libavutil/common.h>
+
+#include "csputils.h"
+
+char * const mp_csp_names[MP_CSP_COUNT] = {
+ "Autoselect",
+ "BT.601 (SD)",
+ "BT.709 (HD)",
+ "SMPTE-240M",
+ "RGB",
+};
+
+char * const mp_csp_equalizer_names[MP_CSP_EQ_COUNT] = {
+ "brightness",
+ "contrast",
+ "hue",
+ "saturation",
+ "gamma",
+};
+
+enum mp_csp avcol_spc_to_mp_csp(enum AVColorSpace colorspace)
+{
+ switch (colorspace) {
+ case AVCOL_SPC_BT709: return MP_CSP_BT_709;
+ case AVCOL_SPC_BT470BG: return MP_CSP_BT_601;
+ case AVCOL_SPC_SMPTE170M: return MP_CSP_BT_601;
+ case AVCOL_SPC_SMPTE240M: return MP_CSP_SMPTE_240M;
+ case AVCOL_SPC_RGB: return MP_CSP_RGB;
+ default: return MP_CSP_AUTO;
+ }
+}
+
+enum mp_csp_levels avcol_range_to_mp_csp_levels(enum AVColorRange range)
+{
+ switch (range) {
+ case AVCOL_RANGE_MPEG: return MP_CSP_LEVELS_TV;
+ case AVCOL_RANGE_JPEG: return MP_CSP_LEVELS_PC;
+ default: return MP_CSP_LEVELS_AUTO;
+ }
+}
+
+enum AVColorSpace mp_csp_to_avcol_spc(enum mp_csp colorspace)
+{
+ switch (colorspace) {
+ case MP_CSP_BT_709: return AVCOL_SPC_BT709;
+ case MP_CSP_BT_601: return AVCOL_SPC_BT470BG;
+ case MP_CSP_SMPTE_240M: return AVCOL_SPC_SMPTE240M;
+ case MP_CSP_RGB: return AVCOL_SPC_RGB;
+ default: return AVCOL_SPC_UNSPECIFIED;
+ }
+}
+
+enum AVColorRange mp_csp_levels_to_avcol_range(enum mp_csp_levels range)
+{
+ switch (range) {
+ case MP_CSP_LEVELS_TV: return AVCOL_RANGE_MPEG;
+ case MP_CSP_LEVELS_PC: return AVCOL_RANGE_JPEG;
+ default: return AVCOL_RANGE_UNSPECIFIED;
+ }
+}
+
+enum mp_csp mp_csp_guess_colorspace(int width, int height)
+{
+ return width >= 1280 || height > 576 ? MP_CSP_BT_709 : MP_CSP_BT_601;
+}
+
+/**
+ * \brief little helper function to create a lookup table for gamma
+ * \param map buffer to create map into
+ * \param size size of buffer
+ * \param gamma gamma value
+ */
+void mp_gen_gamma_map(uint8_t *map, int size, float gamma)
+{
+ if (gamma == 1.0) {
+ for (int i = 0; i < size; i++)
+ map[i] = 255 * i / (size - 1);
+ return;
+ }
+ gamma = 1.0 / gamma;
+ for (int i = 0; i < size; i++) {
+ float tmp = (float)i / (size - 1.0);
+ tmp = pow(tmp, gamma);
+ if (tmp > 1.0)
+ tmp = 1.0;
+ if (tmp < 0.0)
+ tmp = 0.0;
+ map[i] = 255 * tmp;
+ }
+}
+
+/* Fill in the Y, U, V vectors of a yuv2rgb conversion matrix
+ * based on the given luma weights of the R, G and B components (lr, lg, lb).
+ * lr+lg+lb is assumed to equal 1.
+ * This function is meant for colorspaces satisfying the following
+ * conditions (which are true for common YUV colorspaces):
+ * - The mapping from input [Y, U, V] to output [R, G, B] is linear.
+ * - Y is the vector [1, 1, 1]. (meaning input Y component maps to 1R+1G+1B)
+ * - U maps to a value with zero R and positive B ([0, x, y], y > 0;
+ * i.e. blue and green only).
+ * - V maps to a value with zero B and positive R ([x, y, 0], x > 0;
+ * i.e. red and green only).
+ * - U and V are orthogonal to the luma vector [lr, lg, lb].
+ * - The magnitudes of the vectors U and V are the minimal ones for which
+ * the image of the set Y=[0...1],U=[-0.5...0.5],V=[-0.5...0.5] under the
+ * conversion function will cover the set R=[0...1],G=[0...1],B=[0...1]
+ * (the resulting matrix can be converted for other input/output ranges
+ * outside this function).
+ * Under these conditions the given parameters lr, lg, lb uniquely
+ * determine the mapping of Y, U, V to R, G, B.
+ */
+static void luma_coeffs(float m[3][4], float lr, float lg, float lb)
+{
+ assert(fabs(lr+lg+lb - 1) < 1e-6);
+ m[0][0] = m[1][0] = m[2][0] = 1;
+ m[0][1] = 0;
+ m[1][1] = -2 * (1-lb) * lb/lg;
+ m[2][1] = 2 * (1-lb);
+ m[0][2] = 2 * (1-lr);
+ m[1][2] = -2 * (1-lr) * lr/lg;
+ m[2][2] = 0;
+ // Constant coefficients (m[x][3]) not set here
+}
+
+/**
+ * \brief get the coefficients of the yuv -> rgb conversion matrix
+ * \param params struct specifying the properties of the conversion like
+ * brightness, ...
+ * \param m array to store coefficients into
+ */
+void mp_get_yuv2rgb_coeffs(struct mp_csp_params *params, float m[3][4])
+{
+ int format = params->colorspace.format;
+ if (format <= MP_CSP_AUTO || format >= MP_CSP_COUNT)
+ format = MP_CSP_BT_601;
+ switch (format) {
+ case MP_CSP_BT_601: luma_coeffs(m, 0.299, 0.587, 0.114 ); break;
+ case MP_CSP_BT_709: luma_coeffs(m, 0.2126, 0.7152, 0.0722); break;
+ case MP_CSP_SMPTE_240M: luma_coeffs(m, 0.2122, 0.7013, 0.0865); break;
+ default:
+ abort();
+ };
+
+ // Hue is equivalent to rotating input [U, V] subvector around the origin.
+ // Saturation scales [U, V].
+ float huecos = params->saturation * cos(params->hue);
+ float huesin = params->saturation * sin(params->hue);
+ for (int i = 0; i < 3; i++) {
+ float u = m[i][COL_U];
+ m[i][COL_U] = huecos * u - huesin * m[i][COL_V];
+ m[i][COL_V] = huesin * u + huecos * m[i][COL_V];
+ }
+
+ int levels_in = params->colorspace.levels_in;
+ if (levels_in <= MP_CSP_LEVELS_AUTO || levels_in >= MP_CSP_LEVELS_COUNT)
+ levels_in = MP_CSP_LEVELS_TV;
+ assert(params->input_bits >= 8);
+ assert(params->texture_bits >= params->input_bits);
+ double s = (1 << params->input_bits-8) / ((1<<params->texture_bits)-1.);
+ // The values below are written in 0-255 scale
+ struct yuvlevels { double ymin, ymax, cmin, cmid; }
+ yuvlim = { 16*s, 235*s, 16*s, 128*s },
+ yuvfull = { 0*s, 255*s, 1*s, 128*s }, // '1' for symmetry around 128
+ yuvlev;
+ switch (levels_in) {
+ case MP_CSP_LEVELS_TV: yuvlev = yuvlim; break;
+ case MP_CSP_LEVELS_PC: yuvlev = yuvfull; break;
+ default:
+ abort();
+ }
+
+ int levels_out = params->colorspace.levels_out;
+ if (levels_out <= MP_CSP_LEVELS_AUTO || levels_out >= MP_CSP_LEVELS_COUNT)
+ levels_out = MP_CSP_LEVELS_PC;
+ struct rgblevels { double min, max; }
+ rgblim = { 16/255., 235/255. },
+ rgbfull = { 0, 1 },
+ rgblev;
+ switch (levels_out) {
+ case MP_CSP_LEVELS_TV: rgblev = rgblim; break;
+ case MP_CSP_LEVELS_PC: rgblev = rgbfull; break;
+ default:
+ abort();
+ }
+
+ double ymul = (rgblev.max - rgblev.min) / (yuvlev.ymax - yuvlev.ymin);
+ double cmul = (rgblev.max - rgblev.min) / (yuvlev.cmid - yuvlev.cmin) / 2;
+ for (int i = 0; i < 3; i++) {
+ m[i][COL_Y] *= ymul;
+ m[i][COL_U] *= cmul;
+ m[i][COL_V] *= cmul;
+ // Set COL_C so that Y=umin,UV=cmid maps to RGB=min (black to black)
+ m[i][COL_C] = rgblev.min - m[i][COL_Y] * yuvlev.ymin
+ -(m[i][COL_U] + m[i][COL_V]) * yuvlev.cmid;
+ }
+
+ // Brightness adds a constant to output R,G,B.
+ // Contrast scales Y around 1/2 (not 0 in this implementation).
+ for (int i = 0; i < 3; i++) {
+ m[i][COL_C] += params->brightness;
+ m[i][COL_Y] *= params->contrast;
+ m[i][COL_C] += (rgblev.max-rgblev.min) * (1 - params->contrast)/2;
+ }
+
+ int in_bits = FFMAX(params->int_bits_in, 1);
+ int out_bits = FFMAX(params->int_bits_out, 1);
+ double in_scale = (1 << in_bits) - 1.0;
+ double out_scale = (1 << out_bits) - 1.0;
+ for (int i = 0; i < 3; i++) {
+ m[i][COL_C] *= out_scale; // constant is 1.0
+ for (int x = 0; x < 3; x++)
+ m[i][x] *= out_scale / in_scale;
+ }
+}
+
+//! size of gamma map use to avoid slow exp function in gen_yuv2rgb_map
+#define GMAP_SIZE (1024)
+/**
+ * \brief generate a 3D YUV -> RGB map
+ * \param params struct containing parameters like brightness, gamma, ...
+ * \param map where to store map. Must provide space for (size + 2)^3 elements
+ * \param size size of the map, excluding border
+ */
+void mp_gen_yuv2rgb_map(struct mp_csp_params *params, unsigned char *map, int size)
+{
+ int i, j, k, l;
+ float step = 1.0 / size;
+ float y, u, v;
+ float yuv2rgb[3][4];
+ unsigned char gmaps[3][GMAP_SIZE];
+ mp_gen_gamma_map(gmaps[0], GMAP_SIZE, params->rgamma);
+ mp_gen_gamma_map(gmaps[1], GMAP_SIZE, params->ggamma);
+ mp_gen_gamma_map(gmaps[2], GMAP_SIZE, params->bgamma);
+ mp_get_yuv2rgb_coeffs(params, yuv2rgb);
+ for (i = 0; i < 3; i++)
+ for (j = 0; j < 4; j++)
+ yuv2rgb[i][j] *= GMAP_SIZE - 1;
+ v = 0;
+ for (i = -1; i <= size; i++) {
+ u = 0;
+ for (j = -1; j <= size; j++) {
+ y = 0;
+ for (k = -1; k <= size; k++) {
+ for (l = 0; l < 3; l++) {
+ float rgb = yuv2rgb[l][COL_Y] * y + yuv2rgb[l][COL_U] * u +
+ yuv2rgb[l][COL_V] * v + yuv2rgb[l][COL_C];
+ *map++ = gmaps[l][av_clip(rgb, 0, GMAP_SIZE - 1)];
+ }
+ y += (k == -1 || k == size - 1) ? step / 2 : step;
+ }
+ u += (j == -1 || j == size - 1) ? step / 2 : step;
+ }
+ v += (i == -1 || i == size - 1) ? step / 2 : step;
+ }