From f910f3d94140ea17acc55d84420b58a05c712b98 Mon Sep 17 00:00:00 2001 From: arpi Date: Wed, 18 Jun 2003 00:34:35 +0000 Subject: [PATCH] HM12 & NV12 "decoder" (specially interleaved YUV formats, used by Hauppauge's PVR cards) based on patch by Alex git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10306 b3059339-0415-0410-9bf9-f77b7e298cf2 --- etc/codecs.conf | 18 +++++ libmpcodecs/Makefile | 2 +- libmpcodecs/img_format.c | 1 + libmpcodecs/img_format.h | 1 + libmpcodecs/vd.c | 2 + libmpcodecs/vd_hmblck.c | 138 ++++++++++++++++++++++++++++++++++++ libmpdemux/demux_rawvideo.c | 4 ++ 7 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 libmpcodecs/vd_hmblck.c diff --git a/etc/codecs.conf b/etc/codecs.conf index 964237f2d3..e9a64aa68d 100644 --- a/etc/codecs.conf +++ b/etc/codecs.conf @@ -1455,6 +1455,24 @@ videocodec rawyv12 fourcc yv12,YV12 out YV12 +videocodec rawnv12 + info "RAW NV12" + status working + driver hmblck + format 0x0 0x3231564E + format 0x20776172 + fourcc nv12,NV12 + out YV12 + +videocodec rawhm12 + info "RAW HM12" + status working + driver hmblck + format 0x0 0x32314D48 + format 0x20776172 + fourcc hm12,HM12 + out YV12 + videocodec rawi420 info "RAW I420" status working diff --git a/libmpcodecs/Makefile b/libmpcodecs/Makefile index b0b5800770..2d5772d441 100644 --- a/libmpcodecs/Makefile +++ b/libmpcodecs/Makefile @@ -10,7 +10,7 @@ AUDIO_SRCS_OPT=ad_acm.c ad_dshow.c ad_dmo.c ad_qtaudio.c ad_ffmpeg.c ad_faad.c a AUDIO_SRCS=dec_audio.c ad.c $(AUDIO_SRCS_LIB) $(AUDIO_SRCS_NAT) $(AUDIO_SRCS_OPT) VIDEO_SRCS_LIB=vd_libmpeg2.c vd_nuv.c vd_lzo.c -VIDEO_SRCS_NAT=vd_null.c vd_cinepak.c vd_qtrpza.c vd_raw.c vd_msvidc.c vd_fli.c vd_qtrle.c vd_qtsmc.c vd_roqvideo.c vd_cyuv.c vd_msrle.c vd_huffyuv.c vd_mpegpes.c vd_svq1.c vd_lcl.c vd_mtga.c vd_sgi.c +VIDEO_SRCS_NAT=vd_null.c vd_cinepak.c vd_qtrpza.c vd_raw.c vd_hmblck.c vd_msvidc.c vd_fli.c vd_qtrle.c vd_qtsmc.c vd_roqvideo.c vd_cyuv.c vd_msrle.c vd_huffyuv.c vd_mpegpes.c vd_svq1.c vd_lcl.c vd_mtga.c vd_sgi.c VIDEO_SRCS_OPT=vd_realvid.c vd_ffmpeg.c vd_dshow.c vd_dmo.c vd_vfw.c vd_vfwex.c vd_odivx.c vd_divx4.c vd_xanim.c vd_xvid.c vd_libdv.c vd_qtvideo.c vd_theora.c VIDEO_SRCS=dec_video.c vd.c $(VIDEO_SRCS_NAT) $(VIDEO_SRCS_LIB) $(VIDEO_SRCS_OPT) diff --git a/libmpcodecs/img_format.c b/libmpcodecs/img_format.c index df6325505e..2afc2904fa 100644 --- a/libmpcodecs/img_format.c +++ b/libmpcodecs/img_format.c @@ -32,6 +32,7 @@ char *vo_format_name(int format) case IMGFMT_422P: return("Planar 422P"); case IMGFMT_411P: return("Planar 411P"); case IMGFMT_NV12: return("Planar NV12"); + case IMGFMT_HM12: return("Planar NV12 Macroblock"); case IMGFMT_IUYV: return("Packed IUYV"); case IMGFMT_IY41: return("Packed IY41"); case IMGFMT_IYU1: return("Packed IYU1"); diff --git a/libmpcodecs/img_format.h b/libmpcodecs/img_format.h index 5619eb624f..c197501219 100644 --- a/libmpcodecs/img_format.h +++ b/libmpcodecs/img_format.h @@ -49,6 +49,7 @@ #define IMGFMT_444P 0x50343434 #define IMGFMT_422P 0x50323234 #define IMGFMT_411P 0x50313134 +#define IMGFMT_HM12 0x32314D48 /* Packed YUV Formats */ diff --git a/libmpcodecs/vd.c b/libmpcodecs/vd.c index 3646ce07c6..d5c159c705 100644 --- a/libmpcodecs/vd.c +++ b/libmpcodecs/vd.c @@ -39,6 +39,7 @@ extern vd_functions_t mpcodecs_vd_vfwex; extern vd_functions_t mpcodecs_vd_odivx; extern vd_functions_t mpcodecs_vd_divx4; extern vd_functions_t mpcodecs_vd_raw; +extern vd_functions_t mpcodecs_vd_hmblck; extern vd_functions_t mpcodecs_vd_xanim; extern vd_functions_t mpcodecs_vd_msrle; extern vd_functions_t mpcodecs_vd_msvidc; @@ -89,6 +90,7 @@ vd_functions_t* mpcodecs_vd_drivers[] = { #endif &mpcodecs_vd_lzo, &mpcodecs_vd_raw, + &mpcodecs_vd_hmblck, &mpcodecs_vd_msrle, &mpcodecs_vd_msvidc, &mpcodecs_vd_fli, diff --git a/libmpcodecs/vd_hmblck.c b/libmpcodecs/vd_hmblck.c new file mode 100644 index 0000000000..bbecf4a6f8 --- /dev/null +++ b/libmpcodecs/vd_hmblck.c @@ -0,0 +1,138 @@ +#include +#include + +#include "config.h" +#include "mp_msg.h" + +#include "vd_internal.h" + +#define TEMP_BUF_SIZE (720*576) + +static vd_info_t info = { + "Hauppauge Macroblock/NV12 Decoder", + "hmblck", + "Alex , A'rpi", + "Alex ", + "uncompressed" +}; + +LIBVD_EXTERN(hmblck) + +static void de_macro_y(unsigned char* dst,unsigned char* src,int dstride,int w,int h){ + unsigned int y; + // descramble Y plane + for (y=0; ywidth * mpi->height; + unsigned int UV_size = mpi->chroma_width * mpi->chroma_height; + unsigned int idx; + unsigned char *dst_Y = mpi->planes[0]; + unsigned char *dst_U = mpi->planes[1]; + unsigned char *dst_V = mpi->planes[2]; + unsigned char *src = data + Y_size; + + // sanity check raw stream + if ( (len != (Y_size + (UV_size<<1))) ) { + mp_msg(MSGT_DECVIDEO, MSGL_ERR, + "hmblck: Image size inconsistent with data size.\n"); + return 0; + } + if ( (mpi->width > 720) || (mpi->height > 576) ) { + mp_msg(MSGT_DECVIDEO,MSGL_ERR, + "hmblck: Image size is too big.\n"); + return 0; + } + if (mpi->num_planes != 3) { + mp_msg(MSGT_DECVIDEO,MSGL_ERR, + "hmblck: Incorrect number of image planes.\n"); + return 0; + } + + // luma data is easy, just copy it + memcpy(dst_Y, data, Y_size); + + // chroma data is interlaced UVUV... so deinterlace it + for(idx=0; idxdisp_w,sh->disp_h,sh->format); +} +/************************************************************************* + * 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; + + if(len<=0) return NULL; // skipped frame + + mpi=mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE, + sh->disp_w, sh->disp_h); + if(!mpi) return NULL; + + if(sh->format == IMGFMT_HM12) { + //if(!de_macro(sh, data, len, flags, mpi)) return NULL; + de_macro_y(mpi->planes[0],data,mpi->stride[0],mpi->w,mpi->h); + de_macro_uv(mpi->planes[1],mpi->planes[2],data+mpi->w*mpi->h,mpi->stride[1],mpi->w/2,mpi->h/2); + } else { + if(!nv12_to_yv12(data, len, mpi)) return NULL; + } + + return mpi; +} +/*************************************************************************/ diff --git a/libmpdemux/demux_rawvideo.c b/libmpdemux/demux_rawvideo.c index 82714be038..e99b52d9ba 100644 --- a/libmpdemux/demux_rawvideo.c +++ b/libmpdemux/demux_rawvideo.c @@ -40,6 +40,8 @@ config_t demux_rawvideo_opts[] = { { "format", &format, CONF_TYPE_INT, 0, 0 , 0, NULL }, { "y420", &format, CONF_TYPE_FLAG, 0, 0 , IMGFMT_I420, NULL }, { "yv12", &format, CONF_TYPE_FLAG, 0, 0 , IMGFMT_YV12, NULL }, + { "nv12", &format, CONF_TYPE_FLAG, 0, 0 , IMGFMT_NV12, NULL }, + { "hm12", &format, CONF_TYPE_FLAG, 0, 0 , IMGFMT_HM12, NULL }, { "yuy2", &format, CONF_TYPE_FLAG, 0, 0 , IMGFMT_YUY2, NULL }, { "uyvy", &format, CONF_TYPE_FLAG, 0, 0 , IMGFMT_UYVY, NULL }, { "y8", &format, CONF_TYPE_FLAG, 0, 0 , IMGFMT_Y8, NULL }, @@ -73,6 +75,8 @@ int demux_rawvideo_open(demuxer_t* demuxer) { switch(format){ case IMGFMT_I420: case IMGFMT_IYUV: + case IMGFMT_NV12: + case IMGFMT_HM12: case IMGFMT_YV12: imgsize=width*height+2*(width>>1)*(height>>1);break; case IMGFMT_YUY2: imgsize=width*height*2;break; case IMGFMT_UYVY: imgsize=width*height*2;break;