summaryrefslogtreecommitdiffstats
path: root/libmpcodecs
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-10-16 07:30:30 +0200
committerwm4 <wm4@nowhere>2012-10-16 07:30:30 +0200
commit4e89851aa128a614f59ff4885af384a266cb24e6 (patch)
treec6ab9f34ef3e9c1d58f8ec837b93e249e79bdcf6 /libmpcodecs
parentf45eab6faea05834c1337175dbe51437707b8d7e (diff)
parent6557f206efeb4569a42f1e4810172bc97fd64619 (diff)
downloadmpv-4e89851aa128a614f59ff4885af384a266cb24e6.tar.bz2
mpv-4e89851aa128a614f59ff4885af384a266cb24e6.tar.xz
Merge branch 'master' into osd_changes
Conflicts: Makefile command.c libvo/gl_common.c libvo/vo_corevideo.m libvo/vo_opengl.c libvo/vo_opengl_old.c libvo/vo_opengl_shaders.glsl sub/ass_mp.c sub/osd_libass.c sub/sd_ass.c
Diffstat (limited to 'libmpcodecs')
-rw-r--r--libmpcodecs/ad_ffmpeg.c43
-rw-r--r--libmpcodecs/cmmx.h202
-rw-r--r--libmpcodecs/vd_null.c56
-rw-r--r--libmpcodecs/vf.c99
-rw-r--r--libmpcodecs/vf_1bpp.c207
-rw-r--r--libmpcodecs/vf_2xsai.c336
-rw-r--r--libmpcodecs/vf_blackframe.c148
-rw-r--r--libmpcodecs/vf_bmovl.c496
-rw-r--r--libmpcodecs/vf_boxblur.c214
-rw-r--r--libmpcodecs/vf_cropdetect.c200
-rw-r--r--libmpcodecs/vf_decimate.c198
-rw-r--r--libmpcodecs/vf_denoise3d.c268
-rw-r--r--libmpcodecs/vf_detc.c458
-rw-r--r--libmpcodecs/vf_dint.c214
-rw-r--r--libmpcodecs/vf_dvbscale.c67
-rw-r--r--libmpcodecs/vf_eq.c258
-rw-r--r--libmpcodecs/vf_field.c89
-rw-r--r--libmpcodecs/vf_fil.c116
-rw-r--r--libmpcodecs/vf_filmdint.c1442
-rw-r--r--libmpcodecs/vf_fixpts.c136
-rw-r--r--libmpcodecs/vf_framestep.c203
-rw-r--r--libmpcodecs/vf_fspp.c2112
-rw-r--r--libmpcodecs/vf_geq.c197
-rw-r--r--libmpcodecs/vf_halfpack.c254
-rw-r--r--libmpcodecs/vf_harddup.c92
-rw-r--r--libmpcodecs/vf_hue.c200
-rw-r--r--libmpcodecs/vf_il.c148
-rw-r--r--libmpcodecs/vf_ivtc.c555
-rw-r--r--libmpcodecs/vf_kerndeint.c345
-rw-r--r--libmpcodecs/vf_lavc.c178
-rw-r--r--libmpcodecs/vf_lavcdeint.c188
-rw-r--r--libmpcodecs/vf_mcdeint.c330
-rw-r--r--libmpcodecs/vf_ow.c322
-rw-r--r--libmpcodecs/vf_palette.c234
-rw-r--r--libmpcodecs/vf_perspective.c341
-rw-r--r--libmpcodecs/vf_pp7.c489
-rw-r--r--libmpcodecs/vf_qp.c177
-rw-r--r--libmpcodecs/vf_remove_logo.c908
-rw-r--r--libmpcodecs/vf_rgbtest.c171
-rw-r--r--libmpcodecs/vf_sab.c292
-rw-r--r--libmpcodecs/vf_smartblur.c236
-rw-r--r--libmpcodecs/vf_softskip.c102
-rw-r--r--libmpcodecs/vf_spp.c612
-rw-r--r--libmpcodecs/vf_telecine.c190
-rw-r--r--libmpcodecs/vf_test.c332
-rw-r--r--libmpcodecs/vf_tfields.c476
-rw-r--r--libmpcodecs/vf_tile.c332
-rw-r--r--libmpcodecs/vf_tinterlace.c235
-rw-r--r--libmpcodecs/vf_uspp.c384
-rw-r--r--libmpcodecs/vf_yuvcsp.c120
-rw-r--r--libmpcodecs/vf_yvu9.c104
-rw-r--r--libmpcodecs/vqf.h228
52 files changed, 37 insertions, 16297 deletions
diff --git a/libmpcodecs/ad_ffmpeg.c b/libmpcodecs/ad_ffmpeg.c
index c4d7c13941..cca7725490 100644
--- a/libmpcodecs/ad_ffmpeg.c
+++ b/libmpcodecs/ad_ffmpeg.c
@@ -52,6 +52,7 @@ struct priv {
AVCodecContext *avctx;
AVFrame *avframe;
char *output;
+ char *output_packed; // used by deplanarize to store packed audio samples
int output_left;
int unitsize;
int previous_data_left; // input demuxer packet data
@@ -71,7 +72,7 @@ static int setup_format(sh_audio_t *sh_audio,
const AVCodecContext *lavc_context)
{
int sample_format = sh_audio->sample_format;
- switch (lavc_context->sample_fmt) {
+ switch (av_get_packed_sample_fmt(lavc_context->sample_fmt)) {
case AV_SAMPLE_FMT_U8: sample_format = AF_FORMAT_U8; break;
case AV_SAMPLE_FMT_S16: sample_format = AF_FORMAT_S16_NE; break;
case AV_SAMPLE_FMT_S32: sample_format = AF_FORMAT_S32_NE; break;
@@ -218,7 +219,7 @@ static int init(sh_audio_t *sh_audio)
if (sh_audio->wf && sh_audio->wf->nAvgBytesPerSec)
sh_audio->i_bps = sh_audio->wf->nAvgBytesPerSec;
- switch (lavc_context->sample_fmt) {
+ switch (av_get_packed_sample_fmt(lavc_context->sample_fmt)) {
case AV_SAMPLE_FMT_U8:
case AV_SAMPLE_FMT_S16:
case AV_SAMPLE_FMT_S32:
@@ -264,6 +265,34 @@ static int control(sh_audio_t *sh, int cmd, void *arg, ...)
return CONTROL_UNKNOWN;
}
+static av_always_inline void deplanarize(struct sh_audio *sh)
+{
+ struct priv *priv = sh->context;
+
+ size_t bps = av_get_bytes_per_sample(priv->avctx->sample_fmt);
+ size_t nb_samples = priv->avframe->nb_samples;
+ size_t channels = priv->avctx->channels;
+ size_t size = bps * nb_samples * channels;
+
+ if (talloc_get_size(priv->output_packed) != size)
+ priv->output_packed =
+ talloc_realloc_size(priv, priv->output_packed, size);
+
+ size_t offset = 0;
+ unsigned char *output_ptr = priv->output_packed;
+ unsigned char **src = priv->avframe->data;
+
+ for (size_t s = 0; s < nb_samples; s++) {
+ for (size_t c = 0; c < channels; c++) {
+ memcpy(output_ptr, src[c] + offset, bps);
+ output_ptr += bps;
+ }
+ offset += bps;
+ }
+
+ priv->output = priv->output_packed;
+}
+
static int decode_new_packet(struct sh_audio *sh)
{
struct priv *priv = sh->context;
@@ -320,10 +349,6 @@ static int decode_new_packet(struct sh_audio *sh)
priv->previous_data_left = insize - ret;
if (!got_frame)
return 0;
- /* An error is reported later from output format checking, but make
- * sure we don't crash by overreading first plane. */
- if (av_sample_fmt_is_planar(avctx->sample_fmt) && avctx->channels > 1)
- return 0;
uint64_t unitsize = (uint64_t)av_get_bytes_per_sample(avctx->sample_fmt) *
avctx->channels;
if (unitsize > 100000)
@@ -333,7 +358,11 @@ static int decode_new_packet(struct sh_audio *sh)
if (output_left > 500000000)
abort();
priv->output_left = output_left;
- priv->output = priv->avframe->data[0];
+ if (av_sample_fmt_is_planar(avctx->sample_fmt) && avctx->channels > 1) {
+ deplanarize(sh);
+ } else {
+ priv->output = priv->avframe->data[0];
+ }
mp_dbg(MSGT_DECAUDIO, MSGL_DBG2, "Decoded %d -> %d \n", insize,
priv->output_left);
return 0;
diff --git a/libmpcodecs/cmmx.h b/libmpcodecs/cmmx.h
deleted file mode 100644
index 51ffd235bc..0000000000
--- a/libmpcodecs/cmmx.h
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * x86 MMX and MMX2 packed byte operations in portable C.
- * Extra instructions: pdiffub, pcmpzb, psumbw, pcmpgtub
- * Author: Zoltan Hidvegi
- *
- * 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.
- */
-
-#ifndef MPLAYER_CMMX_H
-#define MPLAYER_CMMX_H
-
-typedef unsigned long cmmx_t;
-
-#define ONE_BYTES (~(cmmx_t)0 / 255)
-#define SIGN_BITS (ONE_BYTES << 7)
-#define LOWBW_MASK (~(cmmx_t)0 / 257)
-
-static inline cmmx_t
-paddb(cmmx_t a, cmmx_t b)
-{
- return ((a & ~SIGN_BITS) + (b & ~SIGN_BITS)) ^ ((a^b) & SIGN_BITS);
-}
-
-static inline cmmx_t
-psubb(cmmx_t a, cmmx_t b)
-{
- return ((a | SIGN_BITS) - (b & ~SIGN_BITS)) ^ (~(a^b) & SIGN_BITS);
-}
-
-static inline cmmx_t
-paddusb(cmmx_t a, cmmx_t b)
-{
- cmmx_t s = (a & ~SIGN_BITS) + (b & ~SIGN_BITS);
- cmmx_t abs = (a | b) & SIGN_BITS;
- cmmx_t c = abs & (s | (a & b));
- return s | abs | (abs - (c >> 7));
-}
-
-static inline cmmx_t
-paddusb_s(cmmx_t a, cmmx_t b)
-{
- cmmx_t sum = a+b;
- cmmx_t ov = sum & SIGN_BITS;
- return sum + (sum ^ (ov - (ov>>7)));
-}
-
-static inline cmmx_t
-psubusb(cmmx_t a, cmmx_t b)
-{
- cmmx_t s = (a | SIGN_BITS) - (b & ~SIGN_BITS);
- cmmx_t anb = a & ~b;
- cmmx_t c = (anb | (s & ~(a^b))) & SIGN_BITS;
- return s & ((c & anb) | (c - (c >> 7)));
-}
-
-static inline cmmx_t
-psubusb_s(cmmx_t a, cmmx_t b)
-{
- cmmx_t d = (a|SIGN_BITS) - b;
- cmmx_t m = d & SIGN_BITS;
- return d & (m - (m>>7));
-}
-
-static inline cmmx_t
-pcmpgtub(cmmx_t b, cmmx_t a)
-{
- cmmx_t s = (a | SIGN_BITS) - (b & ~SIGN_BITS);
- cmmx_t ret = ((~a & b) | (~s & ~(a ^ b))) & SIGN_BITS;
- return ret | (ret - (ret >> 7));
-}
-
-static inline cmmx_t
-pdiffub(cmmx_t a, cmmx_t b)
-{
- cmmx_t xs = (~a ^ b) & SIGN_BITS;
- cmmx_t s = ((a | SIGN_BITS) - (b & ~SIGN_BITS)) ^ xs;
- cmmx_t gt = ((~a & b) | (s & xs)) & SIGN_BITS;
- cmmx_t gt7 = gt >> 7;
- return (s ^ gt ^ (gt - gt7)) + gt7;
-}
-
-static inline cmmx_t
-pdiffub_s(cmmx_t a, cmmx_t b)
-{
- cmmx_t d = (a|SIGN_BITS) - b;
- cmmx_t g = (~d & SIGN_BITS) >> 7;
- return (d ^ (SIGN_BITS-g)) + g;
-}
-
-static inline cmmx_t
-pmaxub(cmmx_t a, cmmx_t b)
-{
- return psubusb(a,b) + b;
-}
-
-static inline cmmx_t
-pminub(cmmx_t a, cmmx_t b)
-{
- return paddusb(a,~b) - ~b;
-}
-
-static inline cmmx_t
-pminub_s(cmmx_t a, cmmx_t b)
-{
- cmmx_t d = (a|SIGN_BITS) - b;
- cmmx_t m = ~SIGN_BITS + ((d&SIGN_BITS)>>7);
- return ((d&m) + b) & ~SIGN_BITS;
-}
-
-static inline cmmx_t
-pavgb(cmmx_t a, cmmx_t b)
-{
- cmmx_t ao = a & ONE_BYTES;
- cmmx_t bo = b & ONE_BYTES;
- return ((a^ao)>>1) + ((b^bo)>>1) + (ao|bo);
-}
-
-static inline cmmx_t
-pavgb_s(cmmx_t a, cmmx_t b)
-{
- return ((a+b+ONE_BYTES)>>1) & ~SIGN_BITS;
-}
-
-static inline cmmx_t
-p31avgb(cmmx_t a, cmmx_t b)
-{
- cmmx_t ao = a & (3*ONE_BYTES);
- cmmx_t bo = b & (3*ONE_BYTES);
- return 3*((a^ao)>>2) + ((b^bo)>>2) +
- (((3*ao+bo+2*ONE_BYTES)>>2) & (3*ONE_BYTES));
-}
-
-static inline cmmx_t
-p31avgb_s(cmmx_t a, cmmx_t b)
-{
- cmmx_t avg = ((a+b)>>1) & ~SIGN_BITS;
- return pavgb_s(avg, a);
-}
-
-static inline unsigned long
-psumbw(cmmx_t a)
-{
- cmmx_t t = (a & LOWBW_MASK) + ((a>>8) & LOWBW_MASK);
- unsigned long ret =
- (unsigned long)t + (unsigned long)(t >> (4*sizeof(cmmx_t)));
- if (sizeof(cmmx_t) > 4)
- ret += ret >> 16;
- return ret & 0xffff;
-}
-
-static inline unsigned long
-psumbw_s(cmmx_t a)
-{
- unsigned long ret =
- (unsigned long)a + (unsigned long)(a >> (4*sizeof(cmmx_t)));
- if (sizeof(cmmx_t) <= 4)
- return (ret & 0xff) + ((ret>>8) & 0xff);
- ret = (ret & 0xff00ff) + ((ret>>8) & 0xff00ff);
- ret += ret >> 16;
- return ret & 0xffff;
-}
-
-static inline unsigned long
-psadbw(cmmx_t a, cmmx_t b)
-{
- return psumbw(pdiffub(a,b));
-}
-
-static inline unsigned long
-psadbw_s(cmmx_t a, cmmx_t b)
-{
- return psumbw_s(pdiffub_s(a,b));
-}
-
-static inline cmmx_t
-pcmpzb(cmmx_t a)
-{
- cmmx_t ret = (((a | SIGN_BITS) - ONE_BYTES) | a) & SIGN_BITS;
- return ~(ret | (ret - (ret >> 7)));
-}
-
-static inline cmmx_t
-pcmpeqb(cmmx_t a, cmmx_t b)
-{
- return pcmpzb(a ^ b);
-}
-
-#endif /* MPLAYER_CMMX_H */
diff --git a/libmpcodecs/vd_null.c b/libmpcodecs/vd_null.c
deleted file mode 100644
index 894585b42f..0000000000
--- a/libmpcodecs/vd_null.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "config.h"
-#include "mp_msg.h"
-
-#include "vd_internal.h"
-
-static const vd_info_t info =
-{
- "Null video decoder",
- "null",
- "A'rpi",
- "A'rpi",
- "no decoding"
-};
-
-LIBVD_EXTERN(null)
-
-// to set/get/query special features/parameters
-static int control(sh_video_t *sh,int cmd,void* arg,...){
- return CONTROL_UNKNOWN;
-}
-
-// init driver
-static int init(sh_video_t *sh){
- if(!mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_BGR24)) return 0;
- return 1;
-}
-
-// uninit driver
-static void uninit(sh_video_t *sh){
-}
-
-// decode a frame
-static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
- return NULL;
-}
diff --git a/libmpcodecs/vf.c b/libmpcodecs/vf.c
index f847dd69b8..5ec7d19570 100644
--- a/libmpcodecs/vf.c
+++ b/libmpcodecs/vf.c
@@ -38,7 +38,6 @@
#include "libvo/fastmemcpy.h"
extern const vf_info_t vf_info_vo;
-extern const vf_info_t vf_info_bmovl;
extern const vf_info_t vf_info_crop;
extern const vf_info_t vf_info_expand;
extern const vf_info_t vf_info_pp;
@@ -48,161 +47,65 @@ extern const vf_info_t vf_info_noformat;
extern const vf_info_t vf_info_flip;
extern const vf_info_t vf_info_rotate;
extern const vf_info_t vf_info_mirror;
-extern const vf_info_t vf_info_palette;
-extern const vf_info_t vf_info_lavc;
-extern const vf_info_t vf_info_dvbscale;
-extern const vf_info_t vf_info_cropdetect;
-extern const vf_info_t vf_info_test;
extern const vf_info_t vf_info_noise;
-extern const vf_info_t vf_info_yvu9;
-extern const vf_info_t vf_info_lavcdeint;
-extern const vf_info_t vf_info_eq;
extern const vf_info_t vf_info_eq2;
extern const vf_info_t vf_info_gradfun;
-extern const vf_info_t vf_info_halfpack;
-extern const vf_info_t vf_info_dint;
-extern const vf_info_t vf_info_1bpp;
-extern const vf_info_t vf_info_2xsai;
extern const vf_info_t vf_info_unsharp;
extern const vf_info_t vf_info_swapuv;
-extern const vf_info_t vf_info_il;
-extern const vf_info_t vf_info_fil;
-extern const vf_info_t vf_info_boxblur;
-extern const vf_info_t vf_info_sab;
-extern const vf_info_t vf_info_smartblur;
-extern const vf_info_t vf_info_perspective;
extern const vf_info_t vf_info_down3dright;
-extern const vf_info_t vf_info_field;
-extern const vf_info_t vf_info_denoise3d;
extern const vf_info_t vf_info_hqdn3d;
-extern const vf_info_t vf_info_detc;
-extern const vf_info_t vf_info_telecine;
-extern const vf_info_t vf_info_tinterlace;
-extern const vf_info_t vf_info_tfields;
-extern const vf_info_t vf_info_ivtc;
extern const vf_info_t vf_info_ilpack;
extern const vf_info_t vf_info_dsize;
-extern const vf_info_t vf_info_decimate;
extern const vf_info_t vf_info_softpulldown;
extern const vf_info_t vf_info_pullup;
-extern const vf_info_t vf_info_filmdint;
-extern const vf_info_t vf_info_framestep;
-extern const vf_info_t vf_info_tile;
extern const vf_info_t vf_info_delogo;
-extern const vf_info_t vf_info_remove_logo;
-extern const vf_info_t vf_info_hue;
-extern const vf_info_t vf_info_spp;
-extern const vf_info_t vf_info_uspp;
-extern const vf_info_t vf_info_fspp;
-extern const vf_info_t vf_info_pp7;
-extern const vf_info_t vf_info_yuvcsp;
-extern const vf_info_t vf_info_kerndeint;
-extern const vf_info_t vf_info_rgbtest;
-extern const vf_info_t vf_info_qp;
extern const vf_info_t vf_info_phase;
extern const vf_info_t vf_info_divtc;
-extern const vf_info_t vf_info_harddup;
extern const vf_info_t vf_info_softskip;
extern const vf_info_t vf_info_screenshot;
extern const vf_info_t vf_info_screenshot_force;
extern const vf_info_t vf_info_ass;
-extern const vf_info_t vf_info_mcdeint;
extern const vf_info_t vf_info_yadif;
-extern const vf_info_t vf_info_blackframe;
-extern const vf_info_t vf_info_geq;
-extern const vf_info_t vf_info_ow;
-extern const vf_info_t vf_info_fixpts;
extern const vf_info_t vf_info_stereo3d;
extern const vf_info_t vf_info_dlopen;
// list of available filters:
static const vf_info_t *const filter_list[] = {
-#ifdef HAVE_POSIX_SELECT
- &vf_info_bmovl,
-#endif
&vf_info_crop,
&vf_info_expand,
&vf_info_scale,
-// &vf_info_osd,
&vf_info_vo,
&vf_info_format,
&vf_info_noformat,
&vf_info_flip,
&vf_info_rotate,
&vf_info_mirror,
- &vf_info_palette,
- &vf_info_pp7,
#ifdef CONFIG_LIBPOSTPROC
&vf_info_pp,
#endif
- &vf_info_lavc,
- &vf_info_lavcdeint,
+
&vf_info_screenshot,
&vf_info_screenshot_force,
- &vf_info_fspp,
- &vf_info_uspp,
- &vf_info_dvbscale,
- &vf_info_cropdetect,
- &vf_info_test,
&vf_info_noise,
- &vf_info_yvu9,
- &vf_info_eq,
&vf_info_eq2,
&vf_info_gradfun,
- &vf_info_halfpack,
- &vf_info_dint,
- &vf_info_1bpp,
- &vf_info_2xsai,
&vf_info_unsharp,
&vf_info_swapuv,
- &vf_info_il,
- &vf_info_fil,
- &vf_info_boxblur,
- &vf_info_sab,
- &vf_info_smartblur,
- &vf_info_perspective,
&vf_info_down3dright,
- &vf_info_field,
- &vf_info_denoise3d,
&vf_info_hqdn3d,
- &vf_info_detc,
- &vf_info_telecine,
- &vf_info_tinterlace,
- &vf_info_tfields,
- &vf_info_ivtc,
&vf_info_ilpack,
&vf_info_dsize,
- &vf_info_decimate,
&vf_info_softpulldown,
&vf_info_pullup,
- &vf_info_filmdint,
- &vf_info_framestep,
- &vf_info_tile,
&vf_info_delogo,
- &vf_info_remove_logo,
- &vf_info_hue,
-#ifdef CONFIG_FFMPEG_INTERNALS
- &vf_info_spp,
- &vf_info_mcdeint,
-#endif
- &vf_info_geq,
- &vf_info_qp,
- &vf_info_yuvcsp,
- &vf_info_kerndeint,
- &vf_info_rgbtest,
&vf_info_phase,
&vf_info_divtc,
- &vf_info_harddup,
- &vf_info_softskip,
#ifdef CONFIG_ASS
&vf_info_ass,
#endif
&vf_info_yadif,
- &vf_info_blackframe,
- &vf_info_ow,
- &vf_info_fixpts,
&vf_info_stereo3d,
&vf_info_dlopen,
NULL
diff --git a/libmpcodecs/vf_1bpp.c b/libmpcodecs/vf_1bpp.c
deleted file mode 100644
index 8d13735942..0000000000
--- a/libmpcodecs/vf_1bpp.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * 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.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
-
-#include "config.h"
-#include "mp_msg.h"
-
-#include "img_format.h"
-#include "mp_image.h"
-#include "vf.h"
-
-//===========================================================================//
-
-static const unsigned int bgr_list[]={
- IMGFMT_Y800,
- IMGFMT_Y8,
- IMGFMT_BGR8,
- IMGFMT_RGB8,
-
- IMGFMT_YVU9,
- IMGFMT_411P,
- IMGFMT_YV12,
- IMGFMT_I420,
- IMGFMT_IYUV,
- IMGFMT_422P,
- IMGFMT_444P,
-
- IMGFMT_YUY2,
- IMGFMT_BGR12,
- IMGFMT_RGB12,
- IMGFMT_BGR15,
- IMGFMT_RGB15,
- IMGFMT_BGR16,
- IMGFMT_RGB16,
-
- IMGFMT_BGR32,
- IMGFMT_RGB32,
-
-// IMGFMT_BGR24,
-// IMGFMT_RGB24,
- 0
-};
-
-static unsigned int find_best(struct vf_instance *vf){
- unsigned int best=0;
- int ret;
- const unsigned int* p=bgr_list;
- while(*p){
- ret=vf->next->query_format(vf->next,*p);
- mp_msg(MSGT_VFILTER,MSGL_V,"[%s] query(%s) -> %d\n",vf->info->name,vo_format_name(*p),ret&3);
- if(ret&VFCAP_CSP_SUPPORTED_BY_HW){ best=*p; break;} // no conversion -> bingo!
- if(ret&VFCAP_CSP_SUPPORTED && !best) best=*p; // best with conversion
- ++p;
- }
- return best;
-}
-
-//===========================================================================//
-
-struct vf_priv_s {
- unsigned int fmt;
-};
-
-static int config(struct vf_instance *vf,
- int width, int height, int d_width, int d_height,
- unsigned int flags, unsigned int outfmt){
- if (!vf->priv->fmt)
- vf->priv->fmt=find_best(vf);
- if(!vf->priv->fmt){
- // no matching fmt, so force one...
- if(outfmt==IMGFMT_RGB8) vf->priv->fmt=IMGFMT_RGB32;
- else if(outfmt==IMGFMT_BGR8) vf->priv->fmt=IMGFMT_BGR32;
- else return 0;
- }
- return vf_next_config(vf,width,height,d_width,d_height,flags,vf->priv->fmt);
-}
-
-static const int bittab[8]={128,64,32,16,8,4,2,1};
-
-static void convert(mp_image_t *mpi, mp_image_t *dmpi, int value0, int value1,int bpp){
- int y;
- for(y=0;y<mpi->h;y++){
- unsigned char* src=mpi->planes[0]+mpi->stride[0]*y;
- switch(bpp){
- case 1: {
- unsigned char* dst=dmpi->planes[0]+dmpi->stride[0]*y;
- int x;
- for(x=0;x<mpi->w;x++)
- dst[x]=(src[x>>3]&bittab[x&7]) ? value1 : value0;
- break; }
- case 2: {
- uint16_t* dst=(uint16_t*)(dmpi->planes[0]+dmpi->stride[0]*y);
- int x;
- for(x=0;x<mpi->w;x++)
- dst[x]=(src[x>>3]&bittab[x&7]) ? value1 : value0;
- break; }
- case 4: {
- uint32_t* dst=(uint32_t*)(dmpi->planes[0]+dmpi->stride[0]*y);
- int x;
- for(x=0;x<mpi->w;x++)
- dst[x]=(src[x>>3]&bittab[x&7]) ? value1 : value0;
- break; }
- }
- }
-}
-
-static int put_image(struct vf_instance *vf, mp_image_t *mpi, double pts){
- mp_image_t *dmpi;
-
- // hope we'll get DR buffer:
- dmpi=vf_get_image(vf->next,vf->priv->fmt,
- MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
- mpi->w, mpi->h);
-
- switch(dmpi->imgfmt){
- case IMGFMT_Y800:
- case IMGFMT_Y8:
- case IMGFMT_BGR8:
- case IMGFMT_RGB8:
- convert(mpi,dmpi,0,255,1);
- break;
- case IMGFMT_YVU9:
- case IMGFMT_411P:
- case IMGFMT_YV12:
- case IMGFMT_I420:
- case IMGFMT_IYUV:
- case IMGFMT_422P:
- case IMGFMT_444P:
- convert(mpi,dmpi,0,255,1);
- memset(dmpi->planes[1],128,dmpi->stride[1]*dmpi->chroma_height);
- memset(dmpi->planes[2],128,dmpi->stride[2]*dmpi->chroma_height);
- break;