gl_common: minor cleanup/refactor
[mplayer.git] / libmpcodecs / vd_mpegpes.c
blob22060bfc6093edacc68394a398a3599997521bd0
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include <stdio.h>
20 #include <stdlib.h>
22 #include "config.h"
23 #include "mp_msg.h"
24 #include "libmpdemux/mpeg_hdr.h"
26 #include "vd_internal.h"
28 static const vd_info_t info =
30 "MPEG 1/2 Video passthrough",
31 "mpegpes",
32 "A'rpi",
33 "A'rpi",
34 "for hw decoders"
37 LIBVD_EXTERN(mpegpes)
39 //#include "libmpdemux/parse_es.h"
41 #include "libvo/video_out.h"
43 // to set/get/query special features/parameters
44 static int control(sh_video_t *sh,int cmd,void* arg,...){
45 return CONTROL_UNKNOWN;
48 // init driver
49 static int init(sh_video_t *sh){
50 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_MPEGPES);
53 // uninit driver
54 static void uninit(sh_video_t *sh){
57 // decode a frame
58 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
59 mp_image_t* mpi;
60 static vo_mpegpes_t packet;
61 mp_mpeg_header_t picture;
62 const unsigned char *d = data;
64 if(len>10 && !d[0] && !d[1] && d[2]==1 && d[3]==0xB3) {
65 float old_aspect = sh->aspect;
66 int oldw = sh->disp_w, oldh = sh->disp_h;
67 mp_header_process_sequence_header(&picture, &d[4]);
68 sh->aspect = mpeg12_aspect_info(&picture);
69 sh->disp_w = picture.display_picture_width;
70 sh->disp_h = picture.display_picture_height;
71 if(sh->aspect != old_aspect || sh->disp_w != oldw || sh->disp_h != oldh) {
72 if(!mpcodecs_config_vo(sh, sh->disp_w,sh->disp_h,IMGFMT_MPEGPES))
73 return 0;
77 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, sh->disp_w, sh->disp_h);
78 packet.data=data;
79 packet.size=len;
80 packet.timestamp=sh->timer*90000.0;
81 packet.id=0x1E0; //+sh_video->ds->id;
82 mpi->planes[0]=(uint8_t*)(&packet);
83 return mpi;