Add support for VDPAU video out, including hardware decoding.
[mplayer/glamo.git] / libmpcodecs / vd_mpegpes.c
blob033df36fa6d4ee33f89e7635edcac211cf673d4f
1 #include <stdio.h>
2 #include <stdlib.h>
4 #include "config.h"
5 #include "mp_msg.h"
6 #include "libmpdemux/mpeg_hdr.h"
8 #include "vd_internal.h"
10 static vd_info_t info =
12 "MPEG 1/2 Video passthrough",
13 "mpegpes",
14 "A'rpi",
15 "A'rpi",
16 "for hw decoders"
19 LIBVD_EXTERN(mpegpes)
21 //#include "libmpdemux/parse_es.h"
23 #include "libvo/video_out.h"
25 // to set/get/query special features/parameters
26 static int control(sh_video_t *sh,int cmd,void* arg,...){
27 return CONTROL_UNKNOWN;
30 // init driver
31 static int init(sh_video_t *sh){
32 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_MPEGPES);
35 // uninit driver
36 static void uninit(sh_video_t *sh){
39 // decode a frame
40 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
41 mp_image_t* mpi;
42 static vo_mpegpes_t packet;
43 mp_mpeg_header_t picture;
44 const unsigned char *d = data;
46 if(len>10 && !d[0] && !d[1] && d[2]==1 && d[3]==0xB3) {
47 float old_aspect = sh->aspect;
48 int oldw = sh->disp_w, oldh = sh->disp_h;
49 mp_header_process_sequence_header(&picture, &d[4]);
50 sh->aspect = mpeg12_aspect_info(&picture);
51 sh->disp_w = picture.display_picture_width;
52 sh->disp_h = picture.display_picture_height;
53 if(sh->aspect != old_aspect || sh->disp_w != oldw || sh->disp_h != oldh) {
54 if(!mpcodecs_config_vo(sh, sh->disp_w,sh->disp_h,IMGFMT_MPEGPES))
55 return 0;
59 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, sh->disp_w, sh->disp_h);
60 packet.data=data;
61 packet.size=len;
62 packet.timestamp=sh->timer*90000.0;
63 packet.id=0x1E0; //+sh_video->ds->id;
64 mpi->planes[0]=(uint8_t*)(&packet);
65 return mpi;