7 #include "vd_internal.h"
9 #ifdef USE_LIBAVUTIL_SO
10 #include <ffmpeg/lzo.h>
12 #include "libavutil/lzo.h"
15 #define MOD_NAME "DecLZO"
17 static vd_info_t info
= {
18 "LZO compressed Video",
21 "Transcode development team <http://www.theorie.physik.uni-goettingen.de/~ostreich/transcode/>",
22 "based on liblzo: http://www.oberhumer.com/opensource/lzo/"
33 // to set/get/query special features/parameters
34 static int control (sh_video_t
*sh
, int cmd
, void* arg
, ...)
36 lzo_context_t
*priv
= sh
->context
;
38 case VDCTRL_QUERY_FORMAT
:
39 if (*(int *)arg
== priv
->codec
) return CONTROL_TRUE
;
42 return CONTROL_UNKNOWN
;
47 static int init(sh_video_t
*sh
)
51 if (sh
->bih
->biSizeImage
<= 0) {
52 mp_msg (MSGT_DECVIDEO
, MSGL_ERR
, "[%s] Invalid frame size\n", MOD_NAME
);
56 priv
= malloc(sizeof(lzo_context_t
));
59 mp_msg (MSGT_DECVIDEO
, MSGL_ERR
, "[%s] memory allocation failed\n", MOD_NAME
);
62 priv
->bufsz
= sh
->bih
->biSizeImage
;
63 priv
->buffer
= malloc(priv
->bufsz
+ LZO_OUTPUT_PADDING
);
71 static void uninit(sh_video_t
*sh
)
73 lzo_context_t
*priv
= sh
->context
;
85 static mp_image_t
* decode(sh_video_t
*sh
,void* data
,int len
,int flags
)
89 lzo_context_t
*priv
= sh
->context
;
93 return NULL
; // skipped frame
96 r
= lzo1x_decode(priv
->buffer
, &w
, data
, &len
);
98 /* this should NEVER happen */
99 mp_msg (MSGT_DECVIDEO
, MSGL_ERR
,
100 "[%s] internal error - decompression failed: %d\n", MOD_NAME
, r
);
104 if (priv
->codec
== -1) {
105 // detect RGB24 vs. YV12 via decoded size
106 mp_msg (MSGT_DECVIDEO
, MSGL_V
, "[%s] 2 depth %d, format %d data %p len (%d) (%d)\n",
107 MOD_NAME
, sh
->bih
->biBitCount
, sh
->format
, data
, len
, sh
->bih
->biSizeImage
111 priv
->codec
= IMGFMT_BGR24
;
112 mp_msg (MSGT_DECVIDEO
, MSGL_V
, "[%s] codec choosen is BGR24\n", MOD_NAME
);
113 } else if (w
== (sh
->bih
->biSizeImage
)/2) {
114 priv
->codec
= IMGFMT_YV12
;
115 mp_msg (MSGT_DECVIDEO
, MSGL_V
, "[%s] codec choosen is YV12\n", MOD_NAME
);
118 mp_msg(MSGT_DECVIDEO
,MSGL_ERR
,"[%s] Unsupported out_fmt\n", MOD_NAME
);
122 if(!mpcodecs_config_vo(sh
,sh
->disp_w
,sh
->disp_h
,priv
->codec
)) {
128 mpi
= mpcodecs_get_image(sh
, MP_IMGTYPE_EXPORT
, 0,
129 sh
->disp_w
, sh
->disp_h
);
133 mp_msg (MSGT_DECVIDEO
, MSGL_ERR
, "[%s] mpcodecs_get_image failed\n", MOD_NAME
);
137 mpi
->planes
[0] = priv
->buffer
;
138 if (priv
->codec
== IMGFMT_BGR24
)
139 mpi
->stride
[0] = 3 * sh
->disp_w
;
141 mpi
->stride
[0] = sh
->disp_w
;
142 mpi
->planes
[2] = priv
->buffer
+ sh
->disp_w
*sh
->disp_h
;
143 mpi
->stride
[2] = sh
->disp_w
/ 2;
144 mpi
->planes
[1] = priv
->buffer
+ sh
->disp_w
*sh
->disp_h
*5/4;
145 mpi
->stride
[1] = sh
->disp_w
/ 2;
148 mp_msg (MSGT_DECVIDEO
, MSGL_DBG2
,
149 "[%s] decompressed %lu bytes into %lu bytes\n", MOD_NAME
,
150 (long) len
, (long)w
);