mirror of https://github.com/mpv-player/mpv
native DV audio/video decoders using libdv
based on patch by Alexander Neundorf <neundorf@kde.org> git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6928 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
54646d462b
commit
19704bb73a
|
@ -104,8 +104,8 @@
|
||||||
{"nosound", &has_audio, CONF_TYPE_FLAG, 0, 1, 0, NULL},
|
{"nosound", &has_audio, CONF_TYPE_FLAG, 0, 1, 0, NULL},
|
||||||
|
|
||||||
// select audio/video codec (by name) or codec family (by number):
|
// select audio/video codec (by name) or codec family (by number):
|
||||||
{"afm", &audio_family, CONF_TYPE_INT, CONF_MIN, 0, 16, NULL}, // keep ranges in sync
|
{"afm", &audio_family, CONF_TYPE_INT, CONF_MIN, 0, 22, NULL}, // keep ranges in sync
|
||||||
{"vfm", &video_family, CONF_TYPE_INT, CONF_MIN, 0, 14, NULL}, // with codec-cfg.c
|
{"vfm", &video_family, CONF_TYPE_INT, CONF_MIN, 0, 29, NULL}, // with codec-cfg.c
|
||||||
{"ac", &audio_codec, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
{"ac", &audio_codec, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
||||||
{"vc", &video_codec, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
{"vc", &video_codec, CONF_TYPE_STRING, 0, 0, 0, NULL},
|
||||||
|
|
||||||
|
|
|
@ -235,6 +235,7 @@ static short get_driver(char *s,int audioflag)
|
||||||
"roqaudio",
|
"roqaudio",
|
||||||
"faad",
|
"faad",
|
||||||
"realaud",
|
"realaud",
|
||||||
|
"libdv",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
static char *videodrv[] = {
|
static char *videodrv[] = {
|
||||||
|
@ -267,6 +268,7 @@ static short get_driver(char *s,int audioflag)
|
||||||
"realvid",
|
"realvid",
|
||||||
"svq1",
|
"svq1",
|
||||||
"xvid",
|
"xvid",
|
||||||
|
"libdv",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
char **drv=audioflag?audiodrv:videodrv;
|
char **drv=audioflag?audiodrv:videodrv;
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
#define AFM_ROQAUDIO 19
|
#define AFM_ROQAUDIO 19
|
||||||
#define AFM_AAC 20
|
#define AFM_AAC 20
|
||||||
#define AFM_REAL 21
|
#define AFM_REAL 21
|
||||||
|
#define AFM_LIBDV 22
|
||||||
|
|
||||||
#define VFM_MPEG 1
|
#define VFM_MPEG 1
|
||||||
#define VFM_VFW 2
|
#define VFM_VFW 2
|
||||||
|
@ -77,6 +78,7 @@
|
||||||
#define VFM_REAL 26
|
#define VFM_REAL 26
|
||||||
#define VFM_SVQ1 27
|
#define VFM_SVQ1 27
|
||||||
#define VFM_XVID 28
|
#define VFM_XVID 28
|
||||||
|
#define VFM_LIBDV 29
|
||||||
|
|
||||||
#ifndef GUID_TYPE
|
#ifndef GUID_TYPE
|
||||||
#define GUID_TYPE
|
#define GUID_TYPE
|
||||||
|
|
|
@ -4182,9 +4182,9 @@ ARCH_LIB = $_ld_arch $_ld_iconv
|
||||||
DIVX4LINUX = $_divx4linux
|
DIVX4LINUX = $_divx4linux
|
||||||
XVID = $_xvid
|
XVID = $_xvid
|
||||||
XVID_LIB = $_ld_xvid
|
XVID_LIB = $_ld_xvid
|
||||||
DECORE_LIB = $_ld_decore
|
DECORE_LIB = $_ld_decore $_ld_libdv
|
||||||
MENCODER = $_mencoder
|
MENCODER = $_mencoder
|
||||||
ENCORE_LIB = $_ld_encore $_ld_mp3lame $_ld_libdv
|
ENCORE_LIB = $_ld_encore $_ld_mp3lame
|
||||||
DIRECTFB_INC = $_inc_directfb
|
DIRECTFB_INC = $_inc_directfb
|
||||||
DIRECTFB_LIB = $_ld_directfb
|
DIRECTFB_LIB = $_ld_directfb
|
||||||
NEW_INPUT_LIB = $_ld_new_input
|
NEW_INPUT_LIB = $_ld_new_input
|
||||||
|
|
|
@ -4,8 +4,8 @@ include ../config.mak
|
||||||
LIBNAME = libmpcodecs.a
|
LIBNAME = libmpcodecs.a
|
||||||
LIBNAME2 = libmpencoders.a
|
LIBNAME2 = libmpencoders.a
|
||||||
|
|
||||||
AUDIO_SRCS=dec_audio.c ad.c ad_a52.c ad_acm.c ad_alaw.c ad_dk3adpcm.c ad_dshow.c ad_dvdpcm.c ad_ffmpeg.c ad_hwac3.c ad_imaadpcm.c ad_mp3.c ad_msadpcm.c ad_pcm.c ad_roqaudio.c ad_msgsm.c ad_faad.c ad_vorbis.c ad_libmad.c ad_real.c
|
AUDIO_SRCS=dec_audio.c ad.c ad_a52.c ad_acm.c ad_alaw.c ad_dk3adpcm.c ad_dshow.c ad_dvdpcm.c ad_ffmpeg.c ad_hwac3.c ad_imaadpcm.c ad_mp3.c ad_msadpcm.c ad_pcm.c ad_roqaudio.c ad_msgsm.c ad_faad.c ad_vorbis.c ad_libmad.c ad_real.c ad_libdv.c
|
||||||
VIDEO_SRCS=dec_video.c vd.c vd_null.c vd_real.c vd_cinepak.c vd_qtrpza.c vd_ffmpeg.c vd_dshow.c vd_vfw.c vd_odivx.c vd_divx4.c vd_raw.c vd_xanim.c vd_msvidc.c vd_fli.c vd_qtrle.c vd_qtsmc.c vd_roqvideo.c vd_cyuv.c vd_nuv.c vd_libmpeg2.c vd_msrle.c vd_huffyuv.c vd_zlib.c vd_mpegpes.c vd_svq1.c vd_xvid.c
|
VIDEO_SRCS=dec_video.c vd.c vd_null.c vd_real.c vd_cinepak.c vd_qtrpza.c vd_ffmpeg.c vd_dshow.c vd_vfw.c vd_odivx.c vd_divx4.c vd_raw.c vd_xanim.c vd_msvidc.c vd_fli.c vd_qtrle.c vd_qtsmc.c vd_roqvideo.c vd_cyuv.c vd_nuv.c vd_libmpeg2.c vd_msrle.c vd_huffyuv.c vd_zlib.c vd_mpegpes.c vd_svq1.c vd_xvid.c vd_libdv.c
|
||||||
VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_pp.c vf_scale.c vf_format.c vf_yuy2.c vf_flip.c vf_rgb2bgr.c vf_rotate.c vf_mirror.c vf_palette.c vf_lavc.c vf_dvbscale.c vf_cropdetect.c vf_test.c vf_noise.c vf_yvu9.c vf_rectangle.c vf_lavcdeint.c
|
VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_pp.c vf_scale.c vf_format.c vf_yuy2.c vf_flip.c vf_rgb2bgr.c vf_rotate.c vf_mirror.c vf_palette.c vf_lavc.c vf_dvbscale.c vf_cropdetect.c vf_test.c vf_noise.c vf_yvu9.c vf_rectangle.c vf_lavcdeint.c
|
||||||
ENCODER_SRCS=ve.c ve_divx4.c ve_lavc.c ve_vfw.c ve_rawrgb.c ve_libdv.c
|
ENCODER_SRCS=ve.c ve_divx4.c ve_lavc.c ve_vfw.c ve_rawrgb.c ve_libdv.c
|
||||||
NATIVE_SRCS=native/RTjpegN.c native/cinepak.c native/cyuv.c native/fli.c native/minilzo.c native/msvidc.c native/nuppelvideo.c native/qtrle.c native/qtrpza.c native/qtsmc.c native/roqav.c native/xa_gsm.c native/svq1.c
|
NATIVE_SRCS=native/RTjpegN.c native/cinepak.c native/cyuv.c native/fli.c native/minilzo.c native/msvidc.c native/nuppelvideo.c native/qtrle.c native/qtrpza.c native/qtsmc.c native/roqav.c native/xa_gsm.c native/svq1.c
|
||||||
|
|
|
@ -35,6 +35,7 @@ extern ad_functions_t mpcodecs_ad_faad;
|
||||||
extern ad_functions_t mpcodecs_ad_vorbis;
|
extern ad_functions_t mpcodecs_ad_vorbis;
|
||||||
extern ad_functions_t mpcodecs_ad_libmad;
|
extern ad_functions_t mpcodecs_ad_libmad;
|
||||||
extern ad_functions_t mpcodecs_ad_real;
|
extern ad_functions_t mpcodecs_ad_real;
|
||||||
|
extern ad_functions_t mpcodecs_ad_libdv;
|
||||||
|
|
||||||
ad_functions_t* mpcodecs_ad_drivers[] =
|
ad_functions_t* mpcodecs_ad_drivers[] =
|
||||||
{
|
{
|
||||||
|
@ -70,6 +71,9 @@ ad_functions_t* mpcodecs_ad_drivers[] =
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_REALCODECS
|
#ifdef USE_REALCODECS
|
||||||
&mpcodecs_ad_real,
|
&mpcodecs_ad_real,
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_LIBDV095
|
||||||
|
&mpcodecs_ad_libdv,
|
||||||
#endif
|
#endif
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,115 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBDV095
|
||||||
|
|
||||||
|
#include "img_format.h"
|
||||||
|
|
||||||
|
#include <libdv/dv.h>
|
||||||
|
#include <libdv/dv_types.h>
|
||||||
|
|
||||||
|
#include "stream.h"
|
||||||
|
#include "demuxer.h"
|
||||||
|
#include "stheader.h"
|
||||||
|
|
||||||
|
#include "ad_internal.h"
|
||||||
|
|
||||||
|
static ad_info_t info =
|
||||||
|
{
|
||||||
|
"Raw DV Audio Decoder",
|
||||||
|
"libdv",
|
||||||
|
AFM_LIBDV,
|
||||||
|
"Alexander Neundorf <neundorf@kde.org>",
|
||||||
|
"http://libdv.sf.net",
|
||||||
|
""
|
||||||
|
};
|
||||||
|
|
||||||
|
LIBAD_EXTERN(libdv)
|
||||||
|
|
||||||
|
// defined in vd_libdv.c:
|
||||||
|
dv_decoder_t* init_global_rawdv_decoder();
|
||||||
|
|
||||||
|
static int preinit(sh_audio_t *sh_audio)
|
||||||
|
{
|
||||||
|
sh_audio->audio_out_minsize=4*DV_AUDIO_MAX_SAMPLES*2;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int16_t *audioBuffers[4]={NULL,NULL,NULL,NULL};
|
||||||
|
|
||||||
|
static int init(sh_audio_t *sh)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
WAVEFORMATEX *h=sh->wf;
|
||||||
|
|
||||||
|
if(!h) return 0;
|
||||||
|
|
||||||
|
sh->i_bps=h->nAvgBytesPerSec;
|
||||||
|
sh->channels=h->nChannels;
|
||||||
|
sh->samplerate=h->nSamplesPerSec;
|
||||||
|
sh->samplesize=(h->wBitsPerSample+7)/8;
|
||||||
|
|
||||||
|
sh->context=init_global_rawdv_decoder();
|
||||||
|
|
||||||
|
for (i=0; i < 4; i++)
|
||||||
|
audioBuffers[i] = malloc(2*DV_AUDIO_MAX_SAMPLES);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void uninit(sh_audio_t *sh_audio)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i=0; i < 4; i++)
|
||||||
|
free(audioBuffers[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int control(sh_audio_t *sh,int cmd,void* arg, ...)
|
||||||
|
{
|
||||||
|
// TODO!!!
|
||||||
|
return CONTROL_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int decode_audio(sh_audio_t *audio, unsigned char *buf, int minlen, int maxlen)
|
||||||
|
{
|
||||||
|
int len=0;
|
||||||
|
dv_decoder_t* decoder=audio->context; //global_rawdv_decoder;
|
||||||
|
unsigned char* dv_audio_frame=NULL;
|
||||||
|
int xx=ds_get_packet(audio->ds,&dv_audio_frame);
|
||||||
|
if(xx<=0 || !dv_audio_frame) return 0; // EOF?
|
||||||
|
|
||||||
|
dv_parse_header(decoder, dv_audio_frame);
|
||||||
|
|
||||||
|
if(xx!=decoder->frame_size)
|
||||||
|
printf("warning! audio framesize differs! read=%d hdr=%d \n",
|
||||||
|
xx, decoder->frame_size);
|
||||||
|
|
||||||
|
if (dv_decode_full_audio(decoder, dv_audio_frame,(int16_t**) audioBuffers))
|
||||||
|
{
|
||||||
|
/* Interleave the audio into a single buffer */
|
||||||
|
int i=0;
|
||||||
|
int16_t *bufP=(int16_t*)buf;
|
||||||
|
|
||||||
|
// printf("samples=%d/%d chans=%d mem=%d \n",decoder->audio->samples_this_frame,DV_AUDIO_MAX_SAMPLES,
|
||||||
|
// decoder->audio->num_channels, decoder->audio->samples_this_frame*decoder->audio->num_channels*2);
|
||||||
|
|
||||||
|
// return (44100/30)*4;
|
||||||
|
|
||||||
|
for (i=0; i < decoder->audio->samples_this_frame; i++)
|
||||||
|
{
|
||||||
|
int ch;
|
||||||
|
for (ch=0; ch < decoder->audio->num_channels; ch++)
|
||||||
|
bufP[len++] = audioBuffers[ch][i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return len*2;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -53,6 +53,7 @@ extern vd_functions_t mpcodecs_vd_mpegpes;
|
||||||
extern vd_functions_t mpcodecs_vd_real;
|
extern vd_functions_t mpcodecs_vd_real;
|
||||||
extern vd_functions_t mpcodecs_vd_svq1;
|
extern vd_functions_t mpcodecs_vd_svq1;
|
||||||
extern vd_functions_t mpcodecs_vd_xvid;
|
extern vd_functions_t mpcodecs_vd_xvid;
|
||||||
|
extern vd_functions_t mpcodecs_vd_libdv;
|
||||||
|
|
||||||
vd_functions_t* mpcodecs_vd_drivers[] = {
|
vd_functions_t* mpcodecs_vd_drivers[] = {
|
||||||
&mpcodecs_vd_null,
|
&mpcodecs_vd_null,
|
||||||
|
@ -104,6 +105,9 @@ vd_functions_t* mpcodecs_vd_drivers[] = {
|
||||||
&mpcodecs_vd_svq1,
|
&mpcodecs_vd_svq1,
|
||||||
#ifdef HAVE_XVID
|
#ifdef HAVE_XVID
|
||||||
&mpcodecs_vd_xvid,
|
&mpcodecs_vd_xvid,
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_LIBDV095
|
||||||
|
&mpcodecs_vd_libdv,
|
||||||
#endif
|
#endif
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,88 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBDV095
|
||||||
|
|
||||||
|
#include "img_format.h"
|
||||||
|
|
||||||
|
#include <libdv/dv.h>
|
||||||
|
#include <libdv/dv_types.h>
|
||||||
|
|
||||||
|
#include "stream.h"
|
||||||
|
#include "demuxer.h"
|
||||||
|
#include "stheader.h"
|
||||||
|
|
||||||
|
#include "vd_internal.h"
|
||||||
|
|
||||||
|
static vd_info_t info =
|
||||||
|
{
|
||||||
|
"Raw DV Video Decoder",
|
||||||
|
"libdv",
|
||||||
|
VFM_LIBDV,
|
||||||
|
"Alexander Neundorf <neundorf@kde.org>",
|
||||||
|
"http://libdv.sf.net",
|
||||||
|
""
|
||||||
|
};
|
||||||
|
|
||||||
|
LIBVD_EXTERN(libdv)
|
||||||
|
|
||||||
|
// to set/get/query special features/parameters
|
||||||
|
static int control(sh_video_t *sh,int cmd,void* arg,...){
|
||||||
|
return CONTROL_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
static dv_decoder_t* global_rawdv_decoder=NULL;
|
||||||
|
|
||||||
|
dv_decoder_t* init_global_rawdv_decoder()
|
||||||
|
{
|
||||||
|
if(!global_rawdv_decoder){
|
||||||
|
global_rawdv_decoder=dv_decoder_new(TRUE,TRUE,FALSE);
|
||||||
|
global_rawdv_decoder->quality=DV_QUALITY_BEST;
|
||||||
|
global_rawdv_decoder->prev_frame_decoded = 0;
|
||||||
|
}
|
||||||
|
return global_rawdv_decoder;
|
||||||
|
}
|
||||||
|
|
||||||
|
// init driver
|
||||||
|
static int init(sh_video_t *sh)
|
||||||
|
{
|
||||||
|
sh->context = (void *)init_global_rawdv_decoder();
|
||||||
|
return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YUY2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
mp_image_t* mpi;
|
||||||
|
dv_decoder_t *decoder=sh->context;
|
||||||
|
|
||||||
|
if(len<=0 || (flags&3)){
|
||||||
|
// fprintf(stderr,"decode() (rawdv) SKIPPED\n");
|
||||||
|
return NULL; // skipped frame
|
||||||
|
}
|
||||||
|
|
||||||
|
dv_parse_header(decoder, data);
|
||||||
|
|
||||||
|
mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, sh->disp_w, sh->disp_h);
|
||||||
|
|
||||||
|
if(!mpi){ // temporary!
|
||||||
|
fprintf(stderr,"couldn't allocate image for stderr codec\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
dv_decode_full_frame(decoder, data, e_dv_color_yuv, mpi->planes, mpi->stride);
|
||||||
|
|
||||||
|
return mpi;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue