mirror of
https://github.com/mpv-player/mpv
synced 2025-02-17 04:58:06 +00:00
Use export type mpi, everything else is a fragile hack.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@22096 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
d5a69f4655
commit
d13c0ddf30
@ -28,6 +28,8 @@ LIBVD_EXTERN(lzo)
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
lzo_byte *wrkmem;
|
lzo_byte *wrkmem;
|
||||||
|
uint8_t *buffer;
|
||||||
|
int bufsz;
|
||||||
int codec;
|
int codec;
|
||||||
} lzo_context_t;
|
} lzo_context_t;
|
||||||
|
|
||||||
@ -60,6 +62,8 @@ static int init(sh_video_t *sh)
|
|||||||
mp_msg (MSGT_DECVIDEO, MSGL_ERR, "[%s] memory allocation failed\n", MOD_NAME);
|
mp_msg (MSGT_DECVIDEO, MSGL_ERR, "[%s] memory allocation failed\n", MOD_NAME);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
priv->bufsz = sh->bih->biSizeImage;
|
||||||
|
priv->buffer = malloc(priv->bufsz);
|
||||||
priv->codec = -1;
|
priv->codec = -1;
|
||||||
sh->context = priv;
|
sh->context = priv;
|
||||||
|
|
||||||
@ -82,6 +86,7 @@ static void uninit(sh_video_t *sh)
|
|||||||
{
|
{
|
||||||
if (priv->wrkmem)
|
if (priv->wrkmem)
|
||||||
lzo_free(priv->wrkmem);
|
lzo_free(priv->wrkmem);
|
||||||
|
free(priv->buffer);
|
||||||
free(priv);
|
free(priv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,35 +98,27 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags)
|
|||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
mp_image_t* mpi;
|
mp_image_t* mpi;
|
||||||
int w;
|
|
||||||
lzo_context_t *priv = sh->context;
|
lzo_context_t *priv = sh->context;
|
||||||
|
int w = priv->bufsz;
|
||||||
|
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
return NULL; // skipped frame
|
return NULL; // skipped frame
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r = lzo1x_decompress_safe (data, len, priv->buffer, &w, priv->wrkmem);
|
||||||
|
if (r != LZO_E_OK) {
|
||||||
|
/* this should NEVER happen */
|
||||||
|
mp_msg (MSGT_DECVIDEO, MSGL_ERR,
|
||||||
|
"[%s] internal error - decompression failed: %d\n", MOD_NAME, r);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (priv->codec == -1) {
|
if (priv->codec == -1) {
|
||||||
lzo_byte *tmp = lzo_malloc(sh->bih->biSizeImage);
|
// detect RGB24 vs. YV12 via decoded size
|
||||||
|
|
||||||
// decompress one frame to see if its
|
|
||||||
// either YV12 or RGB24
|
|
||||||
mp_msg (MSGT_DECVIDEO, MSGL_V, "[%s] 2 depth %d, format %d data %p len (%d) (%d)\n",
|
mp_msg (MSGT_DECVIDEO, MSGL_V, "[%s] 2 depth %d, format %d data %p len (%d) (%d)\n",
|
||||||
MOD_NAME, sh->bih->biBitCount, sh->format, data, len, sh->bih->biSizeImage
|
MOD_NAME, sh->bih->biBitCount, sh->format, data, len, sh->bih->biSizeImage
|
||||||
);
|
);
|
||||||
|
|
||||||
/* decompress the frame */
|
|
||||||
w = sh->bih->biSizeImage;
|
|
||||||
r = lzo1x_decompress_safe (data, len, tmp, &w, priv->wrkmem);
|
|
||||||
free(tmp);
|
|
||||||
|
|
||||||
if (r != LZO_E_OK) {
|
|
||||||
/* this should NEVER happen */
|
|
||||||
mp_msg (MSGT_DECVIDEO, MSGL_ERR,
|
|
||||||
"[%s] internal error - decompression failed: %d\n", MOD_NAME, r);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (w == (sh->bih->biSizeImage)) {
|
if (w == (sh->bih->biSizeImage)) {
|
||||||
priv->codec = IMGFMT_BGR24;
|
priv->codec = IMGFMT_BGR24;
|
||||||
mp_msg (MSGT_DECVIDEO, MSGL_V, "[%s] codec choosen is BGR24\n", MOD_NAME);
|
mp_msg (MSGT_DECVIDEO, MSGL_V, "[%s] codec choosen is BGR24\n", MOD_NAME);
|
||||||
@ -140,7 +137,7 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mpi = mpcodecs_get_image(sh, MP_IMGTYPE_TEMP, 0,
|
mpi = mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0,
|
||||||
sh->disp_w, sh->disp_h);
|
sh->disp_w, sh->disp_h);
|
||||||
|
|
||||||
|
|
||||||
@ -149,13 +146,15 @@ static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
w = (mpi->w * mpi->h * mpi->bpp) / 8;
|
mpi->planes[0] = priv->buffer;
|
||||||
r = lzo1x_decompress_safe (data, len, mpi->planes[0], &w, priv->wrkmem);
|
if (priv->codec == IMGFMT_BGR24)
|
||||||
if (r != LZO_E_OK) {
|
mpi->stride[0] = 3 * sh->disp_w;
|
||||||
/* this should NEVER happen */
|
else {
|
||||||
mp_msg (MSGT_DECVIDEO, MSGL_ERR,
|
mpi->stride[0] = sh->disp_w;
|
||||||
"[%s] internal error - decompression failed: %d\n", MOD_NAME, r);
|
mpi->planes[2] = priv->buffer + sh->disp_w*sh->disp_h;
|
||||||
return NULL;
|
mpi->stride[2] = sh->disp_w / 2;
|
||||||
|
mpi->planes[1] = priv->buffer + sh->disp_w*sh->disp_h*5/4;
|
||||||
|
mpi->stride[1] = sh->disp_w / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
mp_msg (MSGT_DECVIDEO, MSGL_DBG2,
|
mp_msg (MSGT_DECVIDEO, MSGL_DBG2,
|
||||||
|
Loading…
Reference in New Issue
Block a user