mirror of
https://github.com/mpv-player/mpv
synced 2025-08-04 16:28:10 +02:00
DOCS
TOOLS
debian
drivers
etc
ffmpeg_files
help
input
liba52
libaf
libao2
libdvdcss
libfaad2
libmenu
libmpcodecs
native
ad.c
ad.h
ad_acm.c
ad_alaw.c
ad_dk3adpcm.c
ad_dmo.c
ad_dshow.c
ad_dvdpcm.c
ad_faad.c
ad_ffmpeg.c
ad_hwac3.c
ad_hwmpa.c
ad_imaadpcm.c
ad_internal.h
ad_liba52.c
ad_libdca.c
ad_libdv.c
ad_libmad.c
ad_libvorbis.c
ad_mp3lib.c
ad_mpc.c
ad_msadpcm.c
ad_msgsm.c
ad_pcm.c
ad_qtaudio.c
ad_realaud.c
ad_sample.c
ad_speex.c
ad_twin.c
ae.c
ae.h
ae_faac.c
ae_faac.h
ae_lame.c
ae_lame.h
ae_lavc.c
ae_lavc.h
ae_pcm.c
ae_pcm.h
ae_toolame.c
ae_toolame.h
ae_twolame.c
ae_twolame.h
cmmx.h
dec_audio.c
dec_audio.h
dec_video.c
dec_video.h
img_format.c
img_format.h
mp_image.c
mp_image.h
mpc_info.h
pullup.c
pullup.h
vd.c
vd.h
vd_dmo.c
vd_dshow.c
vd_ffmpeg.c
vd_hmblck.c
vd_ijpg.c
vd_internal.h
vd_libdv.c
vd_libmpeg2.c
vd_lzo.c
vd_mpegpes.c
vd_mpng.c
vd_mtga.c
vd_null.c
vd_qtvideo.c
vd_raw.c
vd_realvid.c
vd_sgi.c
vd_theora.c
vd_vfw.c
vd_vfwex.c
vd_xanim.c
vd_xvid4.c
vd_zrmjpeg.c
ve.c
ve_lavc.c
ve_libdv.c
ve_nuv.c
ve_qtvideo.c
ve_raw.c
ve_vfw.c
ve_x264.c
ve_xvid4.c
vf.c
vf.h
vf_1bpp.c
vf_2xsai.c
vf_ass.c
vf_blackframe.c
vf_bmovl.c
vf_boxblur.c
vf_crop.c
vf_cropdetect.c
vf_decimate.c
vf_delogo.c
vf_denoise3d.c
vf_detc.c
vf_dint.c
vf_divtc.c
vf_down3dright.c
vf_dsize.c
vf_dvbscale.c
vf_eq.c
vf_eq2.c
vf_expand.c
vf_field.c
vf_fil.c
vf_filmdint.c
vf_flip.c
vf_format.c
vf_framestep.c
vf_fspp.c
vf_geq.c
vf_gradfun.c
vf_halfpack.c
vf_harddup.c
vf_hqdn3d.c
vf_hue.c
vf_il.c
vf_ilpack.c
vf_ivtc.c
vf_kerndeint.c
vf_lavc.c
vf_lavcdeint.c
vf_mcdeint.c
vf_mirror.c
vf_noformat.c
vf_noise.c
vf_ow.c
vf_palette.c
vf_perspective.c
vf_phase.c
vf_pp.c
vf_pp7.c
vf_pullup.c
vf_qp.c
vf_rectangle.c
vf_remove_logo.c
vf_rgb2bgr.c
vf_rgbtest.c
vf_rotate.c
vf_sab.c
vf_scale.c
vf_scale.h
vf_screenshot.c
vf_smartblur.c
vf_softpulldown.c
vf_softskip.c
vf_spp.c
vf_swapuv.c
vf_telecine.c
vf_test.c
vf_tfields.c
vf_tile.c
vf_tinterlace.c
vf_unsharp.c
vf_uspp.c
vf_vo.c
vf_yadif.c
vf_yuvcsp.c
vf_yuy2.c
vf_yvu9.c
vf_zrmjpeg.c
vfcap.h
vqf.h
libmpdemux
libmpeg2
libvo
loader
mp3lib
osdep
rpm
stream
tremor
vidix
.gitignore
AUTHORS
Changelog
Copyright
LICENSE
Makefile
README
access_mpcontext.h
ass_mp.c
ass_mp.h
asxparser.c
asxparser.h
av_opts.c
av_opts.h
cfg-common-opts.h
cfg-common.h
cfg-mencoder.h
cfg-mplayer-def.h
cfg-mplayer.h
codec-cfg.c
codec-cfg.h
command.c
command.h
configure
cpudetect.c
cpudetect.h
cpuinfo.c
defaultopts.c
defaultopts.h
edl.c
edl.h
find_sub.c
fmt-conversion.c
fmt-conversion.h
get_path.c
get_path.h
m_config.c
m_config.h
m_option.c
m_option.h
m_property.c
m_property.h
m_struct.c
m_struct.h
mangle.h
mencoder.c
metadata.h
mixer.c
mixer.h
mp_core.h
mp_fifo.c
mp_fifo.h
mp_msg-mencoder.c
mp_msg.c
mp_msg.h
mp_osd.h
mpbswap.h
mpcommon.c
mpcommon.h
mplayer.c
mplayer.h
options.h
parser-cfg.c
parser-cfg.h
parser-mecmd.c
parser-mecmd.h
parser-mpcmd.c
parser-mpcmd.h
playtree.c
playtree.h
playtreeparser.c
playtreeparser.h
spudec.c
spudec.h
sub_cc.c
sub_cc.h
subopt-helper.c
subopt-helper.h
subreader.c
subreader.h
talloc.c
talloc.h
unrar_exec.c
unrar_exec.h
version.sh
vobsub.c
vobsub.h
xvid_vbr.c
xvid_vbr.h
181 lines
4.1 KiB
C
181 lines
4.1 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdarg.h>
|
|
#include <assert.h>
|
|
|
|
#include "config.h"
|
|
#include "mp_msg.h"
|
|
#include "help_mp.h"
|
|
|
|
#include "vd_internal.h"
|
|
|
|
static const vd_info_t info = {
|
|
"Theora/VP3",
|
|
"theora",
|
|
"David Kuehling",
|
|
"www.theora.org",
|
|
"Theora project's VP3 codec"
|
|
};
|
|
|
|
LIBVD_EXTERN(theora)
|
|
|
|
#include <theora/theora.h>
|
|
|
|
#define THEORA_NUM_HEADER_PACKETS 3
|
|
|
|
// to set/get/query special features/parameters
|
|
static int control(sh_video_t *sh,int cmd,void* arg,...){
|
|
switch(cmd) {
|
|
case VDCTRL_QUERY_FORMAT:
|
|
if ((*((int*)arg)) == IMGFMT_YV12)
|
|
return CONTROL_TRUE;
|
|
return CONTROL_FALSE;
|
|
}
|
|
|
|
return CONTROL_UNKNOWN;
|
|
}
|
|
|
|
typedef struct theora_struct_st {
|
|
theora_state st;
|
|
theora_comment cc;
|
|
theora_info inf;
|
|
} theora_struct_t;
|
|
|
|
/*
|
|
* init driver
|
|
*/
|
|
static int init(sh_video_t *sh){
|
|
theora_struct_t *context = NULL;
|
|
int failed = 1;
|
|
int errorCode = 0;
|
|
ogg_packet op;
|
|
int i;
|
|
|
|
/* check whether video output format is supported */
|
|
switch(sh->codec->outfmt[sh->outfmtidx])
|
|
{
|
|
case IMGFMT_YV12: /* well, this should work... */ break;
|
|
default:
|
|
mp_msg (MSGT_DECVIDEO,MSGL_ERR,"Unsupported out_fmt: 0x%X\n",
|
|
sh->codec->outfmt[sh->outfmtidx]);
|
|
return 0;
|
|
}
|
|
|
|
/* this is not a loop, just a context, from which we can break on error */
|
|
do
|
|
{
|
|
context = calloc (sizeof (theora_struct_t), 1);
|
|
sh->context = context;
|
|
if (!context)
|
|
break;
|
|
|
|
theora_info_init(&context->inf);
|
|
theora_comment_init(&context->cc);
|
|
|
|
/* Read all header packets, pass them to theora_decode_header. */
|
|
for (i = 0; i < THEORA_NUM_HEADER_PACKETS; i++)
|
|
{
|
|
op.bytes = ds_get_packet (sh->ds, &op.packet);
|
|
op.b_o_s = 1;
|
|
if ( (errorCode = theora_decode_header (&context->inf, &context->cc, &op)) )
|
|
{
|
|
mp_msg(MSGT_DECAUDIO, MSGL_ERR, "Broken Theora header; errorCode=%i!\n", errorCode);
|
|
break;
|
|
}
|
|
}
|
|
if (errorCode)
|
|
break;
|
|
|
|
/* now init codec */
|
|
errorCode = theora_decode_init (&context->st, &context->inf);
|
|
if (errorCode)
|
|
{
|
|
mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Theora decode init failed: %i \n",
|
|
errorCode);
|
|
break;
|
|
}
|
|
failed = 0;
|
|
} while (0);
|
|
|
|
if (failed)
|
|
{
|
|
if (context)
|
|
{
|
|
free (context);
|
|
sh->context = NULL;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
if(sh->aspect==0.0 && context->inf.aspect_denominator!=0)
|
|
{
|
|
sh->aspect = (float)(context->inf.aspect_numerator * context->inf.frame_width)/
|
|
(context->inf.aspect_denominator * context->inf.frame_height);
|
|
}
|
|
|
|
mp_msg(MSGT_DECVIDEO,MSGL_V,"INFO: Theora video init ok!\n");
|
|
|
|
return mpcodecs_config_vo (sh,context->inf.frame_width,context->inf.frame_height,IMGFMT_YV12);
|
|
}
|
|
|
|
/*
|
|
* uninit driver
|
|
*/
|
|
static void uninit(sh_video_t *sh)
|
|
{
|
|
theora_struct_t *context = (theora_struct_t *)sh->context;
|
|
|
|
if (context)
|
|
{
|
|
theora_info_clear(&context->inf);
|
|
theora_comment_clear(&context->cc);
|
|
theora_clear (&context->st);
|
|
free (context);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* decode frame
|
|
*/
|
|
static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags)
|
|
{
|
|
theora_struct_t *context = (theora_struct_t *)sh->context;
|
|
int errorCode = 0;
|
|
ogg_packet op;
|
|
yuv_buffer yuv;
|
|
mp_image_t* mpi;
|
|
|
|
memset (&op, 0, sizeof (op));
|
|
op.bytes = len;
|
|
op.packet = data;
|
|
op.granulepos = -1;
|
|
|
|
errorCode = theora_decode_packetin (&context->st, &op);
|
|
if (errorCode)
|
|
{
|
|
mp_msg(MSGT_DECVIDEO,MSGL_ERR,"Theora decode packetin failed: %i \n",
|
|
errorCode);
|
|
return NULL;
|
|
}
|
|
|
|
errorCode = theora_decode_YUVout (&context->st, &yuv);
|
|
if (errorCode)
|
|
{
|
|
mp_msg(MSGT_DEMUX,MSGL_ERR,"Theora decode YUVout failed: %i \n",
|
|
errorCode);
|
|
return 0;
|
|
}
|
|
|
|
mpi = mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, yuv.y_width, yuv.y_height);
|
|
if(!mpi) return NULL;
|
|
|
|
mpi->planes[0]=yuv.y;
|
|
mpi->stride[0]=yuv.y_stride;
|
|
mpi->planes[1]=yuv.u;
|
|
mpi->stride[1]=yuv.uv_stride;
|
|
mpi->planes[2]=yuv.v;
|
|
mpi->stride[2]=yuv.uv_stride;
|
|
|
|
return mpi;
|
|
}
|