annotate libmpcodecs/vd_mpegpes.c @ 35410:1c991ec0e6da

Change declaration to use proper type to avoid a ridiculous number of casts.
author reimar
date Wed, 28 Nov 2012 19:43:03 +0000
parents d32f75f79517
children 139f2b064ef9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
5 * it under the terms of the GNU General Public License as published by
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
14 * You should have received a copy of the GNU General Public License along
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
17 */
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 29263
diff changeset
18
5476
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
19 #include <stdio.h>
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
20 #include <stdlib.h>
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
21
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
22 #include "config.h"
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
23 #include "mp_msg.h"
20115
9dbe188e65ad reinit codec chain when aspect ratio and/or resolution change
nicodvb
parents: 7464
diff changeset
24 #include "libmpdemux/mpeg_hdr.h"
5476
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
25
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
26 #include "vd_internal.h"
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
27
30504
cc27da5d7286 Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents: 30421
diff changeset
28 static const vd_info_t info =
5476
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
29 {
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
30 "MPEG 1/2 Video passthrough",
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
31 "mpegpes",
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
32 "A'rpi",
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
33 "A'rpi",
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
34 "for hw decoders"
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
35 };
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
36
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
37 LIBVD_EXTERN(mpegpes)
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
38
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
39 //#include "libmpdemux/parse_es.h"
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
40
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
41 #include "libvo/video_out.h"
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
42
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
43 // to set/get/query special features/parameters
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
44 static int control(sh_video_t *sh,int cmd,void* arg,...){
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
45 return CONTROL_UNKNOWN;
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
46 }
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
47
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
48 // init driver
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
49 static int init(sh_video_t *sh){
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
50 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_MPEGPES);
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
51 }
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
52
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
53 // uninit driver
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
54 static void uninit(sh_video_t *sh){
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
55 }
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
56
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
57 // decode a frame
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
58 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
59 mp_image_t* mpi;
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
60 static vo_mpegpes_t packet;
20115
9dbe188e65ad reinit codec chain when aspect ratio and/or resolution change
nicodvb
parents: 7464
diff changeset
61 mp_mpeg_header_t picture;
9dbe188e65ad reinit codec chain when aspect ratio and/or resolution change
nicodvb
parents: 7464
diff changeset
62 const unsigned char *d = data;
9dbe188e65ad reinit codec chain when aspect ratio and/or resolution change
nicodvb
parents: 7464
diff changeset
63
34772
d32f75f79517 Decode last frames for codecs with delay.
reimar
parents: 30504
diff changeset
64 if (len <= 0 && !data) return NULL; // delay flush
d32f75f79517 Decode last frames for codecs with delay.
reimar
parents: 30504
diff changeset
65
20115
9dbe188e65ad reinit codec chain when aspect ratio and/or resolution change
nicodvb
parents: 7464
diff changeset
66 if(len>10 && !d[0] && !d[1] && d[2]==1 && d[3]==0xB3) {
9dbe188e65ad reinit codec chain when aspect ratio and/or resolution change
nicodvb
parents: 7464
diff changeset
67 float old_aspect = sh->aspect;
9dbe188e65ad reinit codec chain when aspect ratio and/or resolution change
nicodvb
parents: 7464
diff changeset
68 int oldw = sh->disp_w, oldh = sh->disp_h;
9dbe188e65ad reinit codec chain when aspect ratio and/or resolution change
nicodvb
parents: 7464
diff changeset
69 mp_header_process_sequence_header(&picture, &d[4]);
9dbe188e65ad reinit codec chain when aspect ratio and/or resolution change
nicodvb
parents: 7464
diff changeset
70 sh->aspect = mpeg12_aspect_info(&picture);
9dbe188e65ad reinit codec chain when aspect ratio and/or resolution change
nicodvb
parents: 7464
diff changeset
71 sh->disp_w = picture.display_picture_width;
9dbe188e65ad reinit codec chain when aspect ratio and/or resolution change
nicodvb
parents: 7464
diff changeset
72 sh->disp_h = picture.display_picture_height;
9dbe188e65ad reinit codec chain when aspect ratio and/or resolution change
nicodvb
parents: 7464
diff changeset
73 if(sh->aspect != old_aspect || sh->disp_w != oldw || sh->disp_h != oldh) {
9dbe188e65ad reinit codec chain when aspect ratio and/or resolution change
nicodvb
parents: 7464
diff changeset
74 if(!mpcodecs_config_vo(sh, sh->disp_w,sh->disp_h,IMGFMT_MPEGPES))
9dbe188e65ad reinit codec chain when aspect ratio and/or resolution change
nicodvb
parents: 7464
diff changeset
75 return 0;
9dbe188e65ad reinit codec chain when aspect ratio and/or resolution change
nicodvb
parents: 7464
diff changeset
76 }
9dbe188e65ad reinit codec chain when aspect ratio and/or resolution change
nicodvb
parents: 7464
diff changeset
77 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 20115
diff changeset
78
5476
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
79 mpi=mpcodecs_get_image(sh, MP_IMGTYPE_EXPORT, 0, sh->disp_w, sh->disp_h);
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
80 packet.data=data;
7464
baac3cd44794 we don't need the 0x1FF hack any more
arpi
parents: 7180
diff changeset
81 packet.size=len;
5476
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
82 packet.timestamp=sh->timer*90000.0;
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
83 packet.id=0x1E0; //+sh_video->ds->id;
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
84 mpi->planes[0]=(uint8_t*)(&packet);
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
85 return mpi;
ac09ea252466 vd_mpegpes added
arpi
parents:
diff changeset
86 }