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