annotate libmpcodecs/vd_libmpeg2.c @ 8854:b3afe83fc6cc

Update radeon pci ids patch by James Stembridge <jstembridge@gmx.net>
author arpi
date Thu, 09 Jan 2003 18:23:30 +0000
parents b465ba5897a3
children 16a7d1f4da38
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
1 #include <stdio.h>
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
2 #include <stdlib.h>
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
3
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
4 #include "config.h"
8026
b465ba5897a3 usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents: 7957
diff changeset
5 #ifdef USE_LIBMPEG2
b465ba5897a3 usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents: 7957
diff changeset
6
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
7 #include "mp_msg.h"
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
8
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
9 #include "vd_internal.h"
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
10
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
11 static vd_info_t info =
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
12 {
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
13 "MPEG 1/2 Video decoder v2.0",
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
14 "libmpeg2",
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
15 "A'rpi",
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
16 "Aaron & Walken",
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
17 "native"
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
18 };
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
19
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
20 LIBVD_EXTERN(libmpeg2)
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
21
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
22 #define USE_SIGJMP_TRICK
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
23
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
24 #ifdef USE_SIGJMP_TRICK
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
25 #include <signal.h>
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
26 #include <setjmp.h>
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
27 #endif
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
28
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
29 //#include "libmpdemux/parse_es.h"
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
30
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
31 #include "libvo/video_out.h" // FIXME!!!
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
32
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
33 #include "libmpeg2/mpeg2.h"
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
34 #include "libmpeg2/mpeg2_internal.h"
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
35 #include "libmpeg2/mm_accel.h"
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
36
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
37 #include "../cpudetect.h"
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
38
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
39 mpeg2_config_t config; // FIXME!!!
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
40 static picture_t *picture=NULL; // exported from libmpeg2/decode.c
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
41
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
42 static int table_init_state=0;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
43
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
44 // to set/get/query special features/parameters
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
45 static int control(sh_video_t *sh,int cmd,void* arg,...){
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
46 return CONTROL_UNKNOWN;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
47 }
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
48
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
49 static vo_frame_t frames[3];
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
50
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
51 // init driver
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
52 static int init(sh_video_t *sh){
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
53
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
54 config.flags = 0;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
55 if(gCpuCaps.hasMMX)
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
56 config.flags |= MM_ACCEL_X86_MMX;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
57 if(gCpuCaps.hasMMX2)
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
58 config.flags |= MM_ACCEL_X86_MMXEXT;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
59 if(gCpuCaps.has3DNow)
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
60 config.flags |= MM_ACCEL_X86_3DNOW;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
61 #ifdef HAVE_MLIB
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
62 config.flags |= MM_ACCEL_MLIB;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
63 #endif
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
64
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
65 picture=malloc(sizeof(picture_t)); // !!! NEW HACK :) !!!
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
66 memset(picture,0,sizeof(picture_t));
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
67 header_state_init (picture);
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
68
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
69 if(!table_init_state){
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
70 idct_init ();
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
71 motion_comp_init ();
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
72 table_init_state=1;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
73 }
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
74
5003
88481d4b9e0e divx_quality and equalizer support done
arpi
parents: 4998
diff changeset
75 picture->pp_options=divx_quality;
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
76
5675
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
77 memset(frames,0,3*sizeof(vo_frame_t));
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
78
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
79 picture->forward_reference_frame=&frames[0];
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
80 picture->backward_reference_frame=&frames[1];
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
81 picture->temp_frame=&frames[2];
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
82 picture->current_frame=NULL;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
83
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
84 // send seq header to the decoder: *** HACK ***
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
85 // mpeg2_decode_data(NULL,videobuffer,videobuffer+videobuf_len,0);
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
86 // mpeg2_allocate_image_buffers (picture);
5124
3dcbf67c0de0 handle error from mpcodecs_config_vo()
arpi
parents: 5073
diff changeset
87 return mpcodecs_config_vo(sh,sh->disp_w,sh->disp_h,IMGFMT_YV12);
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
88 }
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
89
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
90 // uninit driver
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
91 static void uninit(sh_video_t *sh){
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
92 // mpeg2_free_image_buffers (picture);
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
93 }
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
94
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
95 static void draw_slice (vo_frame_t * frame, uint8_t ** src){
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
96 int stride[3];
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
97 int y=picture->slice<<4;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
98
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
99 stride[0]=picture->coded_picture_width;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
100 stride[1]=stride[2]=stride[0]/2;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
101
7756
77076fb29637 10l. use mpcodecs_draw_slice, instead of libvo directly
arpi
parents: 7464
diff changeset
102 mpcodecs_draw_slice(frame->vo, src,
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
103 stride, picture->display_picture_width,
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
104 (y+16<=picture->display_picture_height) ? 16 :
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
105 picture->display_picture_height-y,
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
106 0, y);
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
107
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
108 ++picture->slice;
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
109 }
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
110
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
111 static int in_slice_flag=0; // FIXME! move to picture struct
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
112 static int drop_frame=0; // FIXME! move to picture struct
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
113
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
114 static mp_image_t* parse_chunk (sh_video_t* sh, int code, uint8_t * buffer, int framedrop){
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
115 mp_image_t* mpi=NULL;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
116
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
117 // stats_header (code, buffer);
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
118
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
119 if (in_slice_flag && ((!code) || (code >= 0xb0))) {
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
120 // ok, we've completed decoding a frame/field!
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
121 in_slice_flag = 0;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
122 mpi=picture->display_frame->mpi;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
123 if(picture->picture_structure!=FRAME_PICTURE && !picture->second_field)
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
124 mpi=NULL; // we don't draw first fields!
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
125 }
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
126
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
127 switch (code) {
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
128 case 0x00: /* picture_start_code */
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
129 if (header_process_picture_header (picture, buffer)) {
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
130 printf ("bad picture header\n");
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
131 }
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
132 drop_frame = framedrop && (picture->picture_coding_type == B_TYPE);
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
133 drop_frame |= framedrop>=2; // hard drop
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
134 break;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
135
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
136 case 0xb3: /* sequence_header_code */
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
137 if (header_process_sequence_header (picture, buffer)) {
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
138 printf ("bad sequence header\n");
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
139 }
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
140 break;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
141
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
142 case 0xb5: /* extension_start_code */
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
143 if (header_process_extension (picture, buffer)) {
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
144 printf ("bad extension\n");
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
145 }
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
146 break;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
147
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
148 default:
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
149 if (code >= 0xb0) break;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
150
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
151 if (!in_slice_flag) {
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
152 in_slice_flag = 1;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
153
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
154 // set current_frame pointer:
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
155 if (!picture->second_field){
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
156 mp_image_t* mpi;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
157 int flags;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
158 if (picture->picture_coding_type == B_TYPE){
5675
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
159 flags=(!framedrop && vd_use_slices &&
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
160 picture->picture_structure==FRAME_PICTURE) ?
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
161 MP_IMGFLAG_DRAW_CALLBACK:0;
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
162 picture->display_frame=
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
163 picture->current_frame = picture->temp_frame;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
164 } else {
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
165 flags=MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
166 picture->current_frame = picture->forward_reference_frame;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
167 picture->display_frame=
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
168 picture->forward_reference_frame = picture->backward_reference_frame;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
169 picture->backward_reference_frame = picture->current_frame;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
170 }
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
171 mpi=mpcodecs_get_image(sh,MP_IMGTYPE_IPB, flags,
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
172 picture->coded_picture_width,
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
173 picture->coded_picture_height);
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
174 // ok, lets see what did we get:
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
175 if(mpi->flags&MP_IMGFLAG_DRAW_CALLBACK &&
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
176 !(mpi->flags&MP_IMGFLAG_DIRECT)){
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
177 // nice, filter/vo likes draw_callback :)
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
178 picture->current_frame->copy=draw_slice;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
179 } else
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
180 picture->current_frame->copy=NULL;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
181 // let's, setup pointers!
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
182 picture->current_frame->base[0]=mpi->planes[0];
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
183 picture->current_frame->base[1]=mpi->planes[1];
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
184 picture->current_frame->base[2]=mpi->planes[2];
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
185 picture->current_frame->mpi=mpi; // tricky!
5675
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
186 #if 1
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
187 if(!picture->forward_reference_frame->base[0]){
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
188 // workaround for sig11
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
189 picture->forward_reference_frame->base[0]=mpi->planes[0];
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
190 picture->forward_reference_frame->base[1]=mpi->planes[1];
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
191 picture->forward_reference_frame->base[2]=mpi->planes[2];
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
192 }
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
193 if(!picture->backward_reference_frame->base[0]){
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
194 // workaround for sig11
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
195 picture->backward_reference_frame->base[0]=mpi->planes[0];
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
196 picture->backward_reference_frame->base[1]=mpi->planes[1];
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
197 picture->backward_reference_frame->base[2]=mpi->planes[2];
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
198 }
0ff1b9ab7afc slices+field pictures fixed, initial sig11 workaround
arpi
parents: 5613
diff changeset
199 #endif
5516
113ed5725b47 missing #ifdfe - 0.1l
arpi
parents: 5515
diff changeset
200 #ifdef MPEG12_POSTPROC
5515
0cdc1388f02f quant_store moved to frame struct
arpi
parents: 5485
diff changeset
201 mpi->qscale=&picture->current_frame->quant_store[1][1];
0cdc1388f02f quant_store moved to frame struct
arpi
parents: 5485
diff changeset
202 mpi->qstride=(MPEG2_MBC+1);
5516
113ed5725b47 missing #ifdfe - 0.1l
arpi
parents: 5515
diff changeset
203 #endif
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
204 mp_msg(MSGT_DECVIDEO,MSGL_DBG2,"mpeg2: [%c] %p %s \n",
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
205 (picture->picture_coding_type == B_TYPE) ? 'B':'P',
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
206 mpi, (mpi->flags&MP_IMGFLAG_DIRECT)?"DR!":"");
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
207 }
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
208
7756
77076fb29637 10l. use mpcodecs_draw_slice, instead of libvo directly
arpi
parents: 7464
diff changeset
209 picture->current_frame->vo=sh;
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
210 picture->slice=0;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
211
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
212 }
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
213
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
214 if (!drop_frame) {
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
215 slice_process (picture, code, buffer);
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
216 #ifdef ARCH_X86
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
217 if (config.flags & MM_ACCEL_X86_MMX) __asm__ __volatile__ ("emms");
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
218 #endif
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
219 }
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
220
5145
109377795585 mpegpes support
arpi
parents: 5124
diff changeset
221 }
4998
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
222 return mpi;
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
223 }
c32191b02a66 mpng, libmpeg2 added, none of them finished :(
arpi
parents:
diff changeset
224
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
225 #ifdef USE_SIGJMP_TRICK
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
226
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
227 static jmp_buf mpeg2_jmp_buf;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
228
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
229 static void mpeg2_sighandler(int sig){
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
230 longjmp(mpeg2_jmp_buf,1);
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
231 }
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
232 #endif
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
233
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
234 // decode a frame
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
235 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
236 static uint32_t code;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
237 static uint8_t* pos;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
238 static uint8_t* current;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
239 uint8_t* end=data+len;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
240 static mp_image_t* mpi;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
241 mp_image_t* ret=NULL;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
242 int framedrop=flags&3;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
243 void* old_sigh;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
244
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
245 // Note: static is REQUIRED because of longjmp() may destroy stack!
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
246 pos=NULL;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
247 current=data;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
248 mpi=NULL;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
249
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
250 #ifdef USE_SIGJMP_TRICK
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
251 old_sigh=signal(SIGSEGV,mpeg2_sighandler);
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
252 #endif
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
253
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
254 while(current<end){
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
255 // FIND NEXT HEAD:
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
256 static unsigned int head;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
257 static uint8_t c;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
258 head=-1;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
259 //--------------------
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
260 while(current<end){
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
261 c=current[0];
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
262 ++current;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
263 head<<=8;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
264 if(head==0x100) break; // synced
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
265 head|=c;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
266 }
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
267 //--------------------
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
268 if(pos){
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
269 #ifdef USE_SIGJMP_TRICK
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
270 if(setjmp(mpeg2_jmp_buf)){
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
271 #ifdef ARCH_X86
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
272 if (config.flags & MM_ACCEL_X86_MMX) __asm__ __volatile__ ("emms");
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
273 #endif
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
274 printf("@@@ libmpeg2 returned from sig11... (bad file?) @@@\n");
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
275 } else
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
276 #endif
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
277 {
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
278 ret=parse_chunk(sh, code&0xFF, pos, framedrop);
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
279 if(ret) mpi=ret;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
280 }
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
281 }
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
282 //--------------------
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
283 pos=current;code=head|c;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
284 }
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
285
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
286 #ifdef USE_SIGJMP_TRICK
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
287 signal(SIGSEGV,old_sigh); // restore sighandler
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
288 #endif
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
289
7464
baac3cd44794 we don't need the 0x1FF hack any more
arpi
parents: 7180
diff changeset
290 // if(code==0x1FF){
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
291 ret=parse_chunk(sh, 0xFF, NULL, framedrop); // send 'end of frame'
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
292 if(ret) mpi=ret;
7464
baac3cd44794 we don't need the 0x1FF hack any more
arpi
parents: 7180
diff changeset
293 // }
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
294
7957
31fd09cc9ba2 passing picture_type (might be usefull for postprocessing)
michael
parents: 7756
diff changeset
295 if(mpi){
31fd09cc9ba2 passing picture_type (might be usefull for postprocessing)
michael
parents: 7756
diff changeset
296 static int last_non_b_type= 0;
31fd09cc9ba2 passing picture_type (might be usefull for postprocessing)
michael
parents: 7756
diff changeset
297
31fd09cc9ba2 passing picture_type (might be usefull for postprocessing)
michael
parents: 7756
diff changeset
298 if(picture->picture_coding_type == B_TYPE)
31fd09cc9ba2 passing picture_type (might be usefull for postprocessing)
michael
parents: 7756
diff changeset
299 mpi->pict_type= B_TYPE;
31fd09cc9ba2 passing picture_type (might be usefull for postprocessing)
michael
parents: 7756
diff changeset
300 else{
31fd09cc9ba2 passing picture_type (might be usefull for postprocessing)
michael
parents: 7756
diff changeset
301 mpi->pict_type= last_non_b_type;
31fd09cc9ba2 passing picture_type (might be usefull for postprocessing)
michael
parents: 7756
diff changeset
302 last_non_b_type= picture->picture_coding_type;
31fd09cc9ba2 passing picture_type (might be usefull for postprocessing)
michael
parents: 7756
diff changeset
303 }
31fd09cc9ba2 passing picture_type (might be usefull for postprocessing)
michael
parents: 7756
diff changeset
304 }
31fd09cc9ba2 passing picture_type (might be usefull for postprocessing)
michael
parents: 7756
diff changeset
305
5465
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
306 return mpi;
1f9c8301a7f2 rewritten - it replaces libmpeg2/decode.c now
arpi
parents: 5360
diff changeset
307 }
8026
b465ba5897a3 usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents: 7957
diff changeset
308 #endif