#include #include #include "config.h" #include "mp_msg.h" #include "vd_internal.h" #define TEMP_BUF_SIZE (720*576) static const vd_info_t info = { "Hauppauge Macroblock/NV12/NV21 Decoder", "hmblck", "Alex , A'rpi, Alex Beregszaszi", "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], (unsigned char *)data+mpi->w*mpi->h,mpi->stride[1], mpi->w/2,mpi->h/2); } else { if(!nv12_to_yv12(data, len, mpi,(sh->format == IMGFMT_NV21))) return NULL; } return mpi; } /*************************************************************************/