Mercurial > mplayer.hg
annotate libmpcodecs/vd_libmpeg2.c @ 31278:2d75e55e74bc
Print media start time with -identify.
author | reimar |
---|---|
date | Mon, 07 Jun 2010 17:52:28 +0000 |
parents | cc27da5d7286 |
children | 2dead2f28eac |
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 |
4998 | 19 #include <stdio.h> |
20 #include <stdlib.h> | |
21 | |
22 #include "config.h" | |
8026
b465ba5897a3
usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents:
7957
diff
changeset
|
23 |
4998 | 24 #include "mp_msg.h" |
25 | |
26 #include "vd_internal.h" | |
27 | |
9859 | 28 //#undef MPEG12_POSTPROC |
29 | |
30504
cc27da5d7286
Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents:
30421
diff
changeset
|
30 static const vd_info_t info = |
4998 | 31 { |
27500
84723050e997
Remove version information from libmpeg2 vd_info_t struct.
diego
parents:
26594
diff
changeset
|
32 "libmpeg2 MPEG 1/2 Video decoder", |
4998 | 33 "libmpeg2", |
9859 | 34 "A'rpi & Fabian Franz", |
4998 | 35 "Aaron & Walken", |
36 "native" | |
37 }; | |
38 | |
39 LIBVD_EXTERN(libmpeg2) | |
40 | |
9859 | 41 //#include "libvo/video_out.h" // FIXME!!! |
5465 | 42 |
4998 | 43 #include "libmpeg2/mpeg2.h" |
12932 | 44 #include "libmpeg2/attributes.h" |
4998 | 45 #include "libmpeg2/mpeg2_internal.h" |
46 | |
17012 | 47 #include "cpudetect.h" |
5465 | 48 |
18301 | 49 typedef struct { |
50 mpeg2dec_t *mpeg2dec; | |
51 int quant_store_idx; | |
52 char *quant_store[3]; | |
25977
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
53 int imgfmt; |
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
54 int width; |
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
55 int height; |
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
56 double aspect; |
18301 | 57 } vd_libmpeg2_ctx_t; |
58 | |
4998 | 59 // to set/get/query special features/parameters |
60 static int control(sh_video_t *sh,int cmd,void* arg,...){ | |
18301 | 61 vd_libmpeg2_ctx_t *context = sh->context; |
62 mpeg2dec_t * mpeg2dec = context->mpeg2dec; | |
14012 | 63 const mpeg2_info_t * info = mpeg2_info (mpeg2dec); |
13995 | 64 |
65 switch(cmd) { | |
66 case VDCTRL_QUERY_FORMAT: | |
14012 | 67 if (info->sequence->width >> 1 == info->sequence->chroma_width && |
68 info->sequence->height >> 1 == info->sequence->chroma_height && | |
69 (*((int*)arg)) == IMGFMT_YV12) | |
13995 | 70 return CONTROL_TRUE; |
14012 | 71 if (info->sequence->width >> 1 == info->sequence->chroma_width && |
72 info->sequence->height == info->sequence->chroma_height && | |
73 (*((int*)arg)) == IMGFMT_422P) | |
13995 | 74 return CONTROL_TRUE; |
75 return CONTROL_FALSE; | |
76 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29059
diff
changeset
|
77 |
4998 | 78 return CONTROL_UNKNOWN; |
79 } | |
80 | |
81 // init driver | |
82 static int init(sh_video_t *sh){ | |
18301 | 83 vd_libmpeg2_ctx_t *context; |
9859 | 84 mpeg2dec_t * mpeg2dec; |
13995 | 85 // const mpeg2_info_t * info; |
9859 | 86 int accel; |
5465 | 87 |
9859 | 88 accel = 0; |
89 if(gCpuCaps.hasMMX) | |
90 accel |= MPEG2_ACCEL_X86_MMX; | |
91 if(gCpuCaps.hasMMX2) | |
92 accel |= MPEG2_ACCEL_X86_MMXEXT; | |
93 if(gCpuCaps.has3DNow) | |
94 accel |= MPEG2_ACCEL_X86_3DNOW; | |
26393
2506f1b0bdbe
Backport SSE2-optimized IDCT routines from upstream libmpeg2.
diego
parents:
25977
diff
changeset
|
95 if(gCpuCaps.hasSSE2) |
2506f1b0bdbe
Backport SSE2-optimized IDCT routines from upstream libmpeg2.
diego
parents:
25977
diff
changeset
|
96 accel |= MPEG2_ACCEL_X86_SSE2; |
10267
d953763cc555
libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents:
10250
diff
changeset
|
97 if(gCpuCaps.hasAltiVec) |
d953763cc555
libmpeg2-altivec patch by Magnus Damm <damm@opensource.se>:
arpi
parents:
10250
diff
changeset
|
98 accel |= MPEG2_ACCEL_PPC_ALTIVEC; |
28290 | 99 #if ARCH_ALPHA |
26594 | 100 accel |= MPEG2_ACCEL_ALPHA; |
101 #elif ARCH_ARM | |
102 accel |= MPEG2_ACCEL_ARM; | |
103 #endif | |
28290 | 104 #if HAVE_MVI |
26594 | 105 accel |= MPEG2_ACCEL_ALPHA_MVI; |
106 #elif HAVE_VIS | |
13117 | 107 accel |= MPEG2_ACCEL_SPARC_VIS; |
9859 | 108 #endif |
109 mpeg2_accel(accel); | |
5465 | 110 |
9859 | 111 mpeg2dec = mpeg2_init (); |
112 | |
113 if(!mpeg2dec) return 0; | |
114 | |
115 mpeg2_custom_fbuf(mpeg2dec,1); // enable DR1 | |
18301 | 116 |
117 context = calloc(1, sizeof(vd_libmpeg2_ctx_t)); | |
118 context->mpeg2dec = mpeg2dec; | |
119 sh->context = context; | |
9859 | 120 |
13112 | 121 mpeg2dec->pending_buffer = 0; |
122 mpeg2dec->pending_length = 0; | |
123 | |
9859 | 124 return 1; |
4998 | 125 } |
126 | |
127 // uninit driver | |
128 static void uninit(sh_video_t *sh){ | |
18301 | 129 int i; |
130 vd_libmpeg2_ctx_t *context = sh->context; | |
131 mpeg2dec_t * mpeg2dec = context->mpeg2dec; | |
13112 | 132 if (mpeg2dec->pending_buffer) free(mpeg2dec->pending_buffer); |
14012 | 133 mpeg2dec->decoder.convert=NULL; |
134 mpeg2dec->decoder.convert_id=NULL; | |
9859 | 135 mpeg2_close (mpeg2dec); |
18301 | 136 for (i=0; i < 3; i++) |
137 free(context->quant_store[i]); | |
138 free(sh->context); | |
4998 | 139 } |
140 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29059
diff
changeset
|
141 static void draw_slice (void * _sh, uint8_t * const * src, unsigned int y){ |
9859 | 142 sh_video_t* sh = (sh_video_t*) _sh; |
18301 | 143 vd_libmpeg2_ctx_t *context = sh->context; |
144 mpeg2dec_t* mpeg2dec = context->mpeg2dec; | |
9859 | 145 const mpeg2_info_t * info = mpeg2_info (mpeg2dec); |
29059
48ba0e64e754
Use MP_MAX_PLANES as size of arrays passed to mpcodecs_draw_slice.
reimar
parents:
28290
diff
changeset
|
146 int stride[MP_MAX_PLANES] = {mpeg2dec->decoder.stride, mpeg2dec->decoder.uv_stride, mpeg2dec->decoder.uv_stride}; |
48ba0e64e754
Use MP_MAX_PLANES as size of arrays passed to mpcodecs_draw_slice.
reimar
parents:
28290
diff
changeset
|
147 uint8_t *srcs[MP_MAX_PLANES] = {src[0], src[1], src[2]}; |
5465 | 148 |
13112 | 149 // printf("draw_slice() y=%d \n",y); |
5465 | 150 |
29059
48ba0e64e754
Use MP_MAX_PLANES as size of arrays passed to mpcodecs_draw_slice.
reimar
parents:
28290
diff
changeset
|
151 mpcodecs_draw_slice(sh, srcs, |
12572
7d681d8ebab8
display height may be a lot smaller or larger than picture height, sample provided by winnicki
iive
parents:
11080
diff
changeset
|
152 stride, info->sequence->picture_width, |
7d681d8ebab8
display height may be a lot smaller or larger than picture height, sample provided by winnicki
iive
parents:
11080
diff
changeset
|
153 (y+16<=info->sequence->picture_height) ? 16 : |
7d681d8ebab8
display height may be a lot smaller or larger than picture height, sample provided by winnicki
iive
parents:
11080
diff
changeset
|
154 info->sequence->picture_height-y, |
9859 | 155 0, y); |
4998 | 156 } |
157 | |
5465 | 158 // decode a frame |
159 static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ | |
18301 | 160 vd_libmpeg2_ctx_t *context = sh->context; |
161 mpeg2dec_t * mpeg2dec = context->mpeg2dec; | |
9859 | 162 const mpeg2_info_t * info = mpeg2_info (mpeg2dec); |
163 int drop_frame, framedrop=flags&3; | |
164 | |
13995 | 165 // MPlayer registers its own draw_slice callback, prevent libmpeg2 from freeing the context |
14012 | 166 mpeg2dec->decoder.convert=NULL; |
167 mpeg2dec->decoder.convert_id=NULL; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29059
diff
changeset
|
168 |
11080
26f1b3ad4a77
skip null frames in mpeg files, patch by Zoltan Hidvegi <mplayer@hzoli.2y.net>
attila
parents:
10663
diff
changeset
|
169 if(len<=0) return NULL; // skipped null frame |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29059
diff
changeset
|
170 |
9859 | 171 // append extra 'end of frame' code: |
172 ((char*)data+len)[0]=0; | |
173 ((char*)data+len)[1]=0; | |
174 ((char*)data+len)[2]=1; | |
175 ((char*)data+len)[3]=0xff; | |
176 len+=4; | |
5465 | 177 |
13112 | 178 if (mpeg2dec->pending_length) { |
179 mpeg2_buffer (mpeg2dec, mpeg2dec->pending_buffer, mpeg2dec->pending_buffer + mpeg2dec->pending_length); | |
180 } else { | |
23916 | 181 mpeg2_buffer (mpeg2dec, data, (uint8_t *)data+len); |
13112 | 182 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29059
diff
changeset
|
183 |
9859 | 184 while(1){ |
185 int state=mpeg2_parse (mpeg2dec); | |
13995 | 186 int type, use_callback; |
187 mp_image_t* mpi_new; | |
18428
22805699b7b1
moved code to set aspect ratio for mpeg12 away from video.c and into decoder files; A/R changes work correctly with -vc mpeg12
nicodvb
parents:
18301
diff
changeset
|
188 unsigned long pw, ph; |
25977
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
189 int imgfmt; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29059
diff
changeset
|
190 |
9859 | 191 switch(state){ |
12932 | 192 case STATE_BUFFER: |
13112 | 193 if (mpeg2dec->pending_length) { |
13152 | 194 // just finished the pending data, continue with processing of the passed buffer |
13112 | 195 mpeg2dec->pending_length = 0; |
23916 | 196 mpeg2_buffer (mpeg2dec, data, (uint8_t *)data+len); |
13112 | 197 } else { |
198 // parsing of the passed buffer finished, return. | |
199 return 0; | |
200 } | |
201 break; | |
9859 | 202 case STATE_SEQUENCE: |
18428
22805699b7b1
moved code to set aspect ratio for mpeg12 away from video.c and into decoder files; A/R changes work correctly with -vc mpeg12
nicodvb
parents:
18301
diff
changeset
|
203 pw = info->sequence->display_width * info->sequence->pixel_width; |
22805699b7b1
moved code to set aspect ratio for mpeg12 away from video.c and into decoder files; A/R changes work correctly with -vc mpeg12
nicodvb
parents:
18301
diff
changeset
|
204 ph = info->sequence->display_height * info->sequence->pixel_height; |
22805699b7b1
moved code to set aspect ratio for mpeg12 away from video.c and into decoder files; A/R changes work correctly with -vc mpeg12
nicodvb
parents:
18301
diff
changeset
|
205 if(ph) sh->aspect = (float) pw / (float) ph; |
25962 | 206 // video parameters initialized/changed, (re)init libvo: |
13995 | 207 if (info->sequence->width >> 1 == info->sequence->chroma_width && |
208 info->sequence->height >> 1 == info->sequence->chroma_height) { | |
25977
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
209 imgfmt = IMGFMT_YV12; |
13995 | 210 } else if (info->sequence->width >> 1 == info->sequence->chroma_width && |
211 info->sequence->height == info->sequence->chroma_height) { | |
25977
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
212 imgfmt = IMGFMT_422P; |
13995 | 213 } else return 0; |
25977
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
214 if (imgfmt == context->imgfmt && |
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
215 info->sequence->picture_width == context->width && |
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
216 info->sequence->picture_height == context->height && |
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
217 sh->aspect == context->aspect) |
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
218 break; |
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
219 if(!mpcodecs_config_vo(sh, |
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
220 info->sequence->picture_width, |
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
221 info->sequence->picture_height, imgfmt)) |
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
222 return 0; |
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
223 context->imgfmt = imgfmt; |
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
224 context->width = info->sequence->picture_width; |
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
225 context->height = info->sequence->picture_height; |
e3be2de66969
Avoid reinit of vo with the exactly same parameters over and over.
reimar
parents:
25962
diff
changeset
|
226 context->aspect = sh->aspect; |
9859 | 227 break; |
13995 | 228 case STATE_PICTURE: |
229 type=info->current_picture->flags&PIC_MASK_CODING_TYPE; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29059
diff
changeset
|
230 |
9859 | 231 drop_frame = framedrop && (mpeg2dec->decoder.coding_type == B_TYPE); |
232 drop_frame |= framedrop>=2; // hard drop | |
233 if (drop_frame) { | |
234 mpeg2_skip(mpeg2dec, 1); | |
235 //printf("Dropping Frame ...\n"); | |
236 break; | |
237 } | |
238 mpeg2_skip(mpeg2dec, 0); //mpeg2skip skips frames until set again to 0 | |
239 | |
14012 | 240 use_callback = (!framedrop && vd_use_slices && |
241 (info->current_picture->flags&PIC_FLAG_PROGRESSIVE_FRAME)) ? | |
242 MP_IMGFLAG_DRAW_CALLBACK:0; | |
13995 | 243 |
9859 | 244 // get_buffer "callback": |
13995 | 245 mpi_new=mpcodecs_get_image(sh,MP_IMGTYPE_IPB, |
14012 | 246 (type==PIC_FLAG_CODING_TYPE_B) ? |
247 use_callback : (MP_IMGFLAG_PRESERVE|MP_IMGFLAG_READABLE), | |
14075 | 248 info->sequence->width, |
249 info->sequence->height); | |
13995 | 250 |
13112 | 251 if(!mpi_new) return 0; // VO ERROR!!!!!!!! |
252 mpeg2_set_buf(mpeg2dec, mpi_new->planes, mpi_new); | |
20591
ca1d5d9fe51c
Set mpi stride, mostly fixes http://samples.mplayerhq.hu/MPEG2/res_change_ffmpeg_aspect.ts
reimar
parents:
18771
diff
changeset
|
253 mpi_new->stride[0] = info->sequence->width; |
ca1d5d9fe51c
Set mpi stride, mostly fixes http://samples.mplayerhq.hu/MPEG2/res_change_ffmpeg_aspect.ts
reimar
parents:
18771
diff
changeset
|
254 mpi_new->stride[1] = info->sequence->chroma_width; |
ca1d5d9fe51c
Set mpi stride, mostly fixes http://samples.mplayerhq.hu/MPEG2/res_change_ffmpeg_aspect.ts
reimar
parents:
18771
diff
changeset
|
255 mpi_new->stride[2] = info->sequence->chroma_width; |
10510
73b3e4336cd4
Add mpeg2_flags to mp_image_t, copy flags in vd_libmpeg2.c,
ranma
parents:
10267
diff
changeset
|
256 if (info->current_picture->flags&PIC_FLAG_TOP_FIELD_FIRST) |
13112 | 257 mpi_new->fields |= MP_IMGFIELD_TOP_FIRST; |
258 else mpi_new->fields &= ~MP_IMGFIELD_TOP_FIRST; | |
10510
73b3e4336cd4
Add mpeg2_flags to mp_image_t, copy flags in vd_libmpeg2.c,
ranma
parents:
10267
diff
changeset
|
259 if (info->current_picture->flags&PIC_FLAG_REPEAT_FIRST_FIELD) |
13112 | 260 mpi_new->fields |= MP_IMGFIELD_REPEAT_FIRST; |
261 else mpi_new->fields &= ~MP_IMGFIELD_REPEAT_FIRST; | |
262 mpi_new->fields |= MP_IMGFIELD_ORDERED; | |
20639 | 263 if (!(info->current_picture->flags&PIC_FLAG_PROGRESSIVE_FRAME)) |
264 mpi_new->fields |= MP_IMGFIELD_INTERLACED; | |
9859 | 265 |
12935 | 266 #ifdef MPEG12_POSTPROC |
18301 | 267 mpi_new->qstride=info->sequence->width>>4; |
268 { | |
269 char **p = &context->quant_store[type==PIC_FLAG_CODING_TYPE_B ? | |
270 2 : (context->quant_store_idx ^= 1)]; | |
271 *p = realloc(*p, mpi_new->qstride*(info->sequence->height>>4)); | |
272 mpi_new->qscale = *p; | |
12935 | 273 } |
13112 | 274 mpeg2dec->decoder.quant_store=mpi_new->qscale; |
275 mpeg2dec->decoder.quant_stride=mpi_new->qstride; | |
276 mpi_new->pict_type=type; // 1->I, 2->P, 3->B | |
277 mpi_new->qscale_type= 1; | |
12935 | 278 #endif |
279 | |
14012 | 280 if (mpi_new->flags&MP_IMGFLAG_DRAW_CALLBACK |
281 && !(mpi_new->flags&MP_IMGFLAG_DIRECT)) { | |
282 // nice, filter/vo likes draw_callback :) | |
283 mpeg2dec->decoder.convert=draw_slice; | |
284 mpeg2dec->decoder.convert_id=sh; | |
285 } else { | |
286 mpeg2dec->decoder.convert=NULL; | |
287 mpeg2dec->decoder.convert_id=NULL; | |
13995 | 288 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
29059
diff
changeset
|
289 |
9859 | 290 break; |
291 case STATE_SLICE: | |
292 case STATE_END: | |
12932 | 293 case STATE_INVALID_END: |
9859 | 294 // decoding done: |
13112 | 295 if(info->display_fbuf) { |
13152 | 296 mp_image_t* mpi = info->display_fbuf->id; |
297 if (mpeg2dec->pending_length == 0) { | |
13995 | 298 mpeg2dec->pending_length = mpeg2dec->buf_end - mpeg2dec->buf_start; |
299 mpeg2dec->pending_buffer = realloc(mpeg2dec->pending_buffer, mpeg2dec->pending_length); | |
300 memcpy(mpeg2dec->pending_buffer, mpeg2dec->buf_start, mpeg2dec->pending_length); | |
13152 | 301 } else { |
302 // still some data in the pending buffer, shouldn't happen | |
303 mpeg2dec->pending_length = mpeg2dec->buf_end - mpeg2dec->buf_start; | |
304 memmove(mpeg2dec->pending_buffer, mpeg2dec->buf_start, mpeg2dec->pending_length); | |
305 mpeg2dec->pending_buffer = realloc(mpeg2dec->pending_buffer, mpeg2dec->pending_length + len); | |
306 memcpy(mpeg2dec->pending_buffer+mpeg2dec->pending_length, data, len); | |
307 mpeg2dec->pending_length += len; | |
308 } | |
309 // fprintf(stderr, "pending = %d\n", mpeg2dec->pending_length); | |
13112 | 310 return mpi; |
311 } | |
7957
31fd09cc9ba2
passing picture_type (might be usefull for postprocessing)
michael
parents:
7756
diff
changeset
|
312 } |
31fd09cc9ba2
passing picture_type (might be usefull for postprocessing)
michael
parents:
7756
diff
changeset
|
313 } |
5465 | 314 } |