Mercurial > libavcodec.hg
annotate h263dec.c @ 532:d2147d9704ce libavcodec
returning the number of consumed bytes (2nd try)
author | michaelni |
---|---|
date | Wed, 10 Jul 2002 20:21:00 +0000 |
parents | cd170daf9e4c |
children | 8f8f4885d874 |
rev | line source |
---|---|
0 | 1 /* |
2 * H263 decoder | |
429 | 3 * Copyright (c) 2001 Fabrice Bellard. |
0 | 4 * |
429 | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Lesser General Public | |
7 * License as published by the Free Software Foundation; either | |
8 * version 2 of the License, or (at your option) any later version. | |
0 | 9 * |
429 | 10 * This library is distributed in the hope that it will be useful, |
0 | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
429 | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Lesser General Public License for more details. | |
0 | 14 * |
429 | 15 * You should have received a copy of the GNU Lesser General Public |
16 * License along with this library; if not, write to the Free Software | |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
0 | 18 */ |
396
fce0a2520551
removed useless header includes - use av memory functions
glantau
parents:
384
diff
changeset
|
19 #include "avcodec.h" |
0 | 20 #include "dsputil.h" |
21 #include "mpegvideo.h" | |
22 | |
23 //#define DEBUG | |
384 | 24 //#define PRINT_FRAME_TIME |
25 #ifdef PRINT_FRAME_TIME | |
26 static inline long long rdtsc() | |
27 { | |
28 long long l; | |
29 asm volatile( "rdtsc\n\t" | |
30 : "=A" (l) | |
31 ); | |
32 // printf("%d\n", int(l/1000)); | |
33 return l; | |
34 } | |
35 #endif | |
0 | 36 |
37 static int h263_decode_init(AVCodecContext *avctx) | |
38 { | |
39 MpegEncContext *s = avctx->priv_data; | |
60 | 40 |
67 | 41 s->avctx = avctx; |
0 | 42 s->out_format = FMT_H263; |
43 | |
44 s->width = avctx->width; | |
45 s->height = avctx->height; | |
411
5c8b3a717929
workaround dc_scale bug in old ffmpeg msmpeg4v3 encoder (set workaround_bugs=1 for this)
michaelni
parents:
396
diff
changeset
|
46 s->workaround_bugs= avctx->workaround_bugs; |
0 | 47 |
48 /* select sub codec */ | |
49 switch(avctx->codec->id) { | |
50 case CODEC_ID_H263: | |
154
f914f710b8d0
- Fixed a bug on H.263 MV prediction for MB on GOBs limits.
pulento
parents:
144
diff
changeset
|
51 s->gob_number = 0; |
454 | 52 s->first_slice_line = 0; |
0 | 53 break; |
67 | 54 case CODEC_ID_MPEG4: |
0 | 55 s->time_increment_bits = 4; /* default value for broken headers */ |
56 s->h263_pred = 1; | |
336 | 57 s->has_b_frames = 1; //default, might be overriden in the vol header during header parsing |
0 | 58 break; |
307 | 59 case CODEC_ID_MSMPEG4V1: |
0 | 60 s->h263_msmpeg4 = 1; |
61 s->h263_pred = 1; | |
307 | 62 s->msmpeg4_version=1; |
63 break; | |
64 case CODEC_ID_MSMPEG4V2: | |
65 s->h263_msmpeg4 = 1; | |
66 s->h263_pred = 1; | |
67 s->msmpeg4_version=2; | |
68 break; | |
69 case CODEC_ID_MSMPEG4V3: | |
70 s->h263_msmpeg4 = 1; | |
71 s->h263_pred = 1; | |
72 s->msmpeg4_version=3; | |
0 | 73 break; |
311 | 74 case CODEC_ID_WMV1: |
75 s->h263_msmpeg4 = 1; | |
76 s->h263_pred = 1; | |
77 s->msmpeg4_version=4; | |
78 break; | |
498 | 79 case CODEC_ID_WMV2: |
80 s->h263_msmpeg4 = 1; | |
81 s->h263_pred = 1; | |
82 s->msmpeg4_version=5; | |
83 break; | |
0 | 84 case CODEC_ID_H263I: |
85 s->h263_intel = 1; | |
86 break; | |
87 default: | |
88 return -1; | |
89 } | |
344 | 90 s->codec_id= avctx->codec->id; |
345 | 91 avctx->mbskip_table= s->mbskip_table; |
344 | 92 |
0 | 93 /* for h263, we allocate the images after having read the header */ |
274
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
94 if (avctx->codec->id != CODEC_ID_H263 && avctx->codec->id != CODEC_ID_MPEG4) |
144 | 95 if (MPV_common_init(s) < 0) |
96 return -1; | |
0 | 97 |
98 if (s->h263_msmpeg4) | |
498 | 99 ff_msmpeg4_decode_init(s); |
0 | 100 else |
101 h263_decode_init_vlc(s); | |
102 | |
103 return 0; | |
104 } | |
105 | |
106 static int h263_decode_end(AVCodecContext *avctx) | |
107 { | |
108 MpegEncContext *s = avctx->priv_data; | |
109 | |
110 MPV_common_end(s); | |
111 return 0; | |
112 } | |
113 | |
114 static int h263_decode_frame(AVCodecContext *avctx, | |
115 void *data, int *data_size, | |
116 UINT8 *buf, int buf_size) | |
117 { | |
118 MpegEncContext *s = avctx->priv_data; | |
119 int ret; | |
120 AVPicture *pict = data; | |
384 | 121 #ifdef PRINT_FRAME_TIME |
122 uint64_t time= rdtsc(); | |
123 #endif | |
0 | 124 #ifdef DEBUG |
125 printf("*****frame %d size=%d\n", avctx->frame_number, buf_size); | |
126 printf("bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]); | |
127 #endif | |
345 | 128 |
129 s->hurry_up= avctx->hurry_up; | |
454 | 130 s->error_resilience= avctx->error_resilience; |
131 s->workaround_bugs= avctx->workaround_bugs; | |
485 | 132 s->flags= avctx->flags; |
454 | 133 |
0 | 134 /* no supplementary picture */ |
135 if (buf_size == 0) { | |
136 *data_size = 0; | |
137 return 0; | |
138 } | |
139 | |
465 | 140 if(s->bitstream_buffer_size && buf_size<20){ //divx 5.01+ frame reorder |
333 | 141 init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size); |
353 | 142 }else |
333 | 143 init_get_bits(&s->gb, buf, buf_size); |
465 | 144 s->bitstream_buffer_size=0; |
0 | 145 |
146 /* let's go :-) */ | |
147 if (s->h263_msmpeg4) { | |
148 ret = msmpeg4_decode_picture_header(s); | |
149 } else if (s->h263_pred) { | |
150 ret = mpeg4_decode_picture_header(s); | |
336 | 151 s->has_b_frames= !s->low_delay; |
0 | 152 } else if (s->h263_intel) { |
153 ret = intel_h263_decode_picture_header(s); | |
154 } else { | |
155 ret = h263_decode_picture_header(s); | |
274
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
156 } |
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
157 |
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
158 /* After H263 & mpeg4 header decode we have the height, width,*/ |
160 | 159 /* and other parameters. So then we could init the picture */ |
160 /* FIXME: By the way H263 decoder is evolving it should have */ | |
161 /* an H263EncContext */ | |
274
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
162 if (!s->context_initialized) { |
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
163 avctx->width = s->width; |
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
164 avctx->height = s->height; |
281
1fc96b02142e
mpeg4 aspect_ratio_info in AVCodecContext (requested by alex)
michaelni
parents:
274
diff
changeset
|
165 avctx->aspect_ratio_info= s->aspect_ratio_info; |
274
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
166 if (MPV_common_init(s) < 0) |
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
167 return -1; |
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
168 } else if (s->width != avctx->width || s->height != avctx->height) { |
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
169 /* H.263 could change picture size any time */ |
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
170 MPV_common_end(s); |
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
171 if (MPV_common_init(s) < 0) |
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
172 return -1; |
0 | 173 } |
274
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
174 |
526
cd170daf9e4c
return the number of consumed bytes instead of 0 or buf_size
michaelni
parents:
498
diff
changeset
|
175 if(ret==FRAME_SKIPED) return (get_bits_count(&s->gb)+7)>>3; |
454 | 176 /* skip if the header was thrashed */ |
498 | 177 if (ret < 0){ |
178 fprintf(stderr, "header damaged\n"); | |
0 | 179 return -1; |
498 | 180 } |
341 | 181 /* skip b frames if we dont have reference frames */ |
526
cd170daf9e4c
return the number of consumed bytes instead of 0 or buf_size
michaelni
parents:
498
diff
changeset
|
182 if(s->num_available_buffers<2 && s->pict_type==B_TYPE) return buf_size; |
345 | 183 /* skip b frames if we are in a hurry */ |
526
cd170daf9e4c
return the number of consumed bytes instead of 0 or buf_size
michaelni
parents:
498
diff
changeset
|
184 if(s->hurry_up && s->pict_type==B_TYPE) return buf_size; |
454 | 185 |
186 if(s->next_p_frame_damaged){ | |
187 if(s->pict_type==B_TYPE) | |
526
cd170daf9e4c
return the number of consumed bytes instead of 0 or buf_size
michaelni
parents:
498
diff
changeset
|
188 return buf_size; |
454 | 189 else |
190 s->next_p_frame_damaged=0; | |
191 } | |
192 | |
0 | 193 MPV_frame_start(s); |
194 | |
195 #ifdef DEBUG | |
196 printf("qscale=%d\n", s->qscale); | |
197 #endif | |
198 | |
454 | 199 /* init resync/ error resilience specific variables */ |
200 s->next_resync_qscale= s->qscale; | |
201 s->next_resync_gb= s->gb; | |
202 if(s->resync_marker) s->mb_num_left= 0; | |
203 else s->mb_num_left= s->mb_num; | |
204 | |
0 | 205 /* decode each macroblock */ |
266 | 206 s->block_wrap[0]= |
207 s->block_wrap[1]= | |
208 s->block_wrap[2]= | |
209 s->block_wrap[3]= s->mb_width*2 + 2; | |
210 s->block_wrap[4]= | |
211 s->block_wrap[5]= s->mb_width + 2; | |
0 | 212 for(s->mb_y=0; s->mb_y < s->mb_height; s->mb_y++) { |
162 | 213 /* Check for GOB headers on H.263 */ |
214 /* FIXME: In the future H.263+ will have intra prediction */ | |
215 /* and we are gonna need another way to detect MPEG4 */ | |
216 if (s->mb_y && !s->h263_pred) { | |
454 | 217 s->first_slice_line = h263_decode_gob_header(s); |
218 } | |
219 | |
220 if(s->msmpeg4_version==1){ | |
221 s->last_dc[0]= | |
222 s->last_dc[1]= | |
223 s->last_dc[2]= 128; | |
162 | 224 } |
296 | 225 |
498 | 226 s->y_dc_scale= s->y_dc_scale_table[ s->qscale ]; |
227 s->c_dc_scale= s->c_dc_scale_table[ s->qscale ]; | |
228 | |
266 | 229 s->block_index[0]= s->block_wrap[0]*(s->mb_y*2 + 1) - 1; |
230 s->block_index[1]= s->block_wrap[0]*(s->mb_y*2 + 1); | |
231 s->block_index[2]= s->block_wrap[0]*(s->mb_y*2 + 2) - 1; | |
232 s->block_index[3]= s->block_wrap[0]*(s->mb_y*2 + 2); | |
233 s->block_index[4]= s->block_wrap[4]*(s->mb_y + 1) + s->block_wrap[0]*(s->mb_height*2 + 2); | |
234 s->block_index[5]= s->block_wrap[4]*(s->mb_y + 1 + s->mb_height + 2) + s->block_wrap[0]*(s->mb_height*2 + 2); | |
0 | 235 for(s->mb_x=0; s->mb_x < s->mb_width; s->mb_x++) { |
266 | 236 s->block_index[0]+=2; |
237 s->block_index[1]+=2; | |
238 s->block_index[2]+=2; | |
239 s->block_index[3]+=2; | |
240 s->block_index[4]++; | |
241 s->block_index[5]++; | |
0 | 242 #ifdef DEBUG |
243 printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y); | |
244 #endif | |
454 | 245 |
246 if(s->resync_marker){ | |
247 if(s->mb_num_left<=0){ | |
248 /* except the first block */ | |
249 if(s->mb_x!=0 || s->mb_y!=0){ | |
250 /* did we miss the next resync marker without noticing an error yet */ | |
251 if(((get_bits_count(&s->gb)+8)&(~7)) != s->next_resync_pos && s->decoding_error==0){ | |
252 fprintf(stderr, "slice end missmatch x:%d y:%d %d %d\n", | |
253 s->mb_x, s->mb_y, get_bits_count(&s->gb), s->next_resync_pos); | |
254 ff_conceal_past_errors(s, 1); | |
255 } | |
256 } | |
257 s->qscale= s->next_resync_qscale; | |
498 | 258 s->y_dc_scale= s->y_dc_scale_table[ s->qscale ]; |
259 s->c_dc_scale= s->c_dc_scale_table[ s->qscale ]; | |
260 | |
454 | 261 s->gb= s->next_resync_gb; |
262 s->resync_mb_x= s->mb_x; //we know that the marker is here cuz mb_num_left was the distance to it | |
263 s->resync_mb_y= s->mb_y; | |
264 s->first_slice_line=1; | |
265 | |
266 if(s->codec_id==CODEC_ID_MPEG4){ | |
267 ff_mpeg4_clean_buffers(s); | |
268 ff_mpeg4_resync(s); | |
269 } | |
270 } | |
271 | |
272 if( s->resync_mb_x==s->mb_x | |
273 && s->resync_mb_y==s->mb_y && s->decoding_error!=0){ | |
274 fprintf(stderr, "resynced at %d %d\n", s->mb_x, s->mb_y); | |
275 s->decoding_error= 0; | |
276 } | |
277 } | |
278 | |
144 | 279 //fprintf(stderr,"\nFrame: %d\tMB: %d",avctx->frame_number, (s->mb_y * s->mb_width) + s->mb_x); |
0 | 280 /* DCT & quantize */ |
454 | 281 if(s->decoding_error!=DECODING_DESYNC){ |
282 int last_error= s->decoding_error; | |
283 clear_blocks(s->block[0]); | |
296 | 284 |
454 | 285 s->mv_dir = MV_DIR_FORWARD; |
286 s->mv_type = MV_TYPE_16X16; | |
287 if (s->h263_msmpeg4) { | |
288 if (msmpeg4_decode_mb(s, s->block) < 0) { | |
289 fprintf(stderr,"Error at MB: %d\n", (s->mb_y * s->mb_width) + s->mb_x); | |
290 s->decoding_error=DECODING_DESYNC; | |
291 } | |
292 } else { | |
293 if (h263_decode_mb(s, s->block) < 0) { | |
294 fprintf(stderr,"Error at MB: %d\n", (s->mb_y * s->mb_width) + s->mb_x); | |
295 s->decoding_error=DECODING_DESYNC; | |
296 } | |
297 } | |
298 | |
299 if(s->decoding_error!=last_error){ | |
300 ff_conceal_past_errors(s, 0); | |
161 | 301 } |
0 | 302 } |
454 | 303 |
304 /* conceal errors */ | |
305 if( s->decoding_error==DECODING_DESYNC | |
306 || (s->decoding_error==DECODING_ACDC_LOST && s->mb_intra)){ | |
307 s->mv_dir = MV_DIR_FORWARD; | |
308 s->mv_type = MV_TYPE_16X16; | |
309 s->mb_skiped=0; | |
310 s->mb_intra=0; | |
311 s->mv[0][0][0]=0; //FIXME this is not optimal | |
312 s->mv[0][0][1]=0; | |
313 clear_blocks(s->block[0]); | |
314 }else if(s->decoding_error && !s->mb_intra){ | |
315 clear_blocks(s->block[0]); | |
316 } | |
317 //FIXME remove AC for intra | |
318 | |
12
4d50c7d89e0f
use block[] in structure to have it aligned on 8 bytes for mmx optimizations
glantau
parents:
0
diff
changeset
|
319 MPV_decode_mb(s, s->block); |
454 | 320 |
321 s->mb_num_left--; | |
0 | 322 } |
341 | 323 if ( avctx->draw_horiz_band |
324 && (s->num_available_buffers>=1 || (!s->has_b_frames)) ) { | |
67 | 325 UINT8 *src_ptr[3]; |
326 int y, h, offset; | |
327 y = s->mb_y * 16; | |
328 h = s->height - y; | |
329 if (h > 16) | |
330 h = 16; | |
331 offset = y * s->linesize; | |
308 | 332 if(s->pict_type==B_TYPE || (!s->has_b_frames)){ |
333 src_ptr[0] = s->current_picture[0] + offset; | |
334 src_ptr[1] = s->current_picture[1] + (offset >> 2); | |
335 src_ptr[2] = s->current_picture[2] + (offset >> 2); | |
336 } else { | |
337 src_ptr[0] = s->last_picture[0] + offset; | |
338 src_ptr[1] = s->last_picture[1] + (offset >> 2); | |
339 src_ptr[2] = s->last_picture[2] + (offset >> 2); | |
340 } | |
67 | 341 avctx->draw_horiz_band(avctx, src_ptr, s->linesize, |
342 y, s->width, h); | |
343 } | |
0 | 344 } |
208 | 345 |
311 | 346 if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==I_TYPE) |
208 | 347 if(msmpeg4_decode_ext_header(s, buf_size) < 0) return -1; |
333 | 348 |
349 /* divx 5.01+ bistream reorder stuff */ | |
344 | 350 if(s->codec_id==CODEC_ID_MPEG4 && s->bitstream_buffer_size==0){ |
454 | 351 int current_pos= get_bits_count(&s->gb)>>3; |
352 | |
333 | 353 if( buf_size - current_pos > 5 |
354 && buf_size - current_pos < BITSTREAM_BUFFER_SIZE){ | |
454 | 355 int i; |
356 int startcode_found=0; | |
357 for(i=current_pos; i<buf_size; i++){ | |
358 if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1 && buf[i+3]==0xB6){ | |
359 startcode_found=1; | |
360 break; | |
361 } | |
362 } | |
363 if(startcode_found){ | |
364 memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos); | |
365 s->bitstream_buffer_size= buf_size - current_pos; | |
366 } | |
367 } | |
368 } | |
369 | |
370 if(s->bitstream_buffer_size==0 && s->error_resilience>0){ | |
371 int left= s->gb.size*8 - get_bits_count(&s->gb); | |
372 int max_extra=8; | |
373 | |
374 if(s->codec_id==CODEC_ID_MPEG4) max_extra+=32; | |
375 | |
376 if(left>max_extra){ | |
377 fprintf(stderr, "discarding %d junk bits at end, next would be %X\n", left, show_bits(&s->gb, 24)); | |
378 if(s->decoding_error==0) | |
379 ff_conceal_past_errors(s, 1); | |
380 } | |
381 if(left<0){ | |
382 fprintf(stderr, "overreading %d bits\n", -left); | |
383 if(s->decoding_error==0) | |
384 ff_conceal_past_errors(s, 1); | |
333 | 385 } |
353 | 386 } |
333 | 387 |
0 | 388 MPV_frame_end(s); |
361 | 389 #if 0 //dirty show MVs, we should export the MV tables and write a filter to show them |
390 { | |
391 int mb_y; | |
392 s->has_b_frames=1; | |
393 for(mb_y=0; mb_y<s->mb_height; mb_y++){ | |
394 int mb_x; | |
411
5c8b3a717929
workaround dc_scale bug in old ffmpeg msmpeg4v3 encoder (set workaround_bugs=1 for this)
michaelni
parents:
396
diff
changeset
|
395 int y= mb_y*16 + 8; |
361 | 396 for(mb_x=0; mb_x<s->mb_width; mb_x++){ |
411
5c8b3a717929
workaround dc_scale bug in old ffmpeg msmpeg4v3 encoder (set workaround_bugs=1 for this)
michaelni
parents:
396
diff
changeset
|
397 int x= mb_x*16 + 8; |
361 | 398 uint8_t *ptr= s->last_picture[0]; |
399 int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2); | |
400 int mx= (s->motion_val[xy][0]>>1) + x; | |
401 int my= (s->motion_val[xy][1]>>1) + y; | |
402 int i; | |
403 int max; | |
404 | |
405 if(mx<0) mx=0; | |
406 if(my<0) my=0; | |
407 if(mx>=s->width) mx= s->width -1; | |
408 if(my>=s->height) my= s->height-1; | |
409 max= ABS(mx-x); | |
410 if(ABS(my-y) > max) max= ABS(my-y); | |
411 /* the ugliest linedrawing routine ... */ | |
412 for(i=0; i<max; i++){ | |
413 int x1= x + (mx-x)*i/max; | |
414 int y1= y + (my-y)*i/max; | |
415 ptr[y1*s->linesize + x1]+=100; | |
416 } | |
411
5c8b3a717929
workaround dc_scale bug in old ffmpeg msmpeg4v3 encoder (set workaround_bugs=1 for this)
michaelni
parents:
396
diff
changeset
|
417 ptr[y*s->linesize + x]+=100; |
361 | 418 s->mbskip_table[mb_x + mb_y*s->mb_width]=0; |
419 } | |
420 } | |
421 | |
422 } | |
423 #endif | |
273
34f40a0fc840
msmpeg4 bugfix (wrong frame displayed if some frames are skipped)
michaelni
parents:
266
diff
changeset
|
424 if(s->pict_type==B_TYPE || (!s->has_b_frames)){ |
262 | 425 pict->data[0] = s->current_picture[0]; |
426 pict->data[1] = s->current_picture[1]; | |
427 pict->data[2] = s->current_picture[2]; | |
428 } else { | |
429 pict->data[0] = s->last_picture[0]; | |
430 pict->data[1] = s->last_picture[1]; | |
431 pict->data[2] = s->last_picture[2]; | |
432 } | |
0 | 433 pict->linesize[0] = s->linesize; |
434 pict->linesize[1] = s->linesize / 2; | |
435 pict->linesize[2] = s->linesize / 2; | |
436 | |
437 avctx->quality = s->qscale; | |
231 | 438 |
439 /* Return the Picture timestamp as the frame number */ | |
440 /* we substract 1 because it is added on utils.c */ | |
441 avctx->frame_number = s->picture_number - 1; | |
442 | |
341 | 443 /* dont output the last pic after seeking |
444 note we allready added +1 for the current pix in MPV_frame_end(s) */ | |
445 if(s->num_available_buffers>=2 || (!s->has_b_frames)) | |
446 *data_size = sizeof(AVPicture); | |
384 | 447 #ifdef PRINT_FRAME_TIME |
448 printf("%Ld\n", rdtsc()-time); | |
449 #endif | |
532 | 450 if(s->gb.size != buf_size) |
451 return buf_size; //divx5 b frame reorder | |
452 else | |
453 return ((get_bits_count(&s->gb)+7)>>3) + s->bitstream_buffer_size; | |
0 | 454 } |
455 | |
67 | 456 AVCodec mpeg4_decoder = { |
457 "mpeg4", | |
0 | 458 CODEC_TYPE_VIDEO, |
67 | 459 CODEC_ID_MPEG4, |
0 | 460 sizeof(MpegEncContext), |
461 h263_decode_init, | |
462 NULL, | |
463 h263_decode_end, | |
464 h263_decode_frame, | |
67 | 465 CODEC_CAP_DRAW_HORIZ_BAND, |
0 | 466 }; |
467 | |
468 AVCodec h263_decoder = { | |
469 "h263", | |
470 CODEC_TYPE_VIDEO, | |
471 CODEC_ID_H263, | |
472 sizeof(MpegEncContext), | |
473 h263_decode_init, | |
474 NULL, | |
475 h263_decode_end, | |
476 h263_decode_frame, | |
67 | 477 CODEC_CAP_DRAW_HORIZ_BAND, |
0 | 478 }; |
479 | |
307 | 480 AVCodec msmpeg4v1_decoder = { |
481 "msmpeg4v1", | |
482 CODEC_TYPE_VIDEO, | |
483 CODEC_ID_MSMPEG4V1, | |
484 sizeof(MpegEncContext), | |
485 h263_decode_init, | |
486 NULL, | |
487 h263_decode_end, | |
488 h263_decode_frame, | |
489 CODEC_CAP_DRAW_HORIZ_BAND, | |
490 }; | |
491 | |
492 AVCodec msmpeg4v2_decoder = { | |
493 "msmpeg4v2", | |
494 CODEC_TYPE_VIDEO, | |
495 CODEC_ID_MSMPEG4V2, | |
496 sizeof(MpegEncContext), | |
497 h263_decode_init, | |
498 NULL, | |
499 h263_decode_end, | |
500 h263_decode_frame, | |
501 CODEC_CAP_DRAW_HORIZ_BAND, | |
502 }; | |
503 | |
504 AVCodec msmpeg4v3_decoder = { | |
0 | 505 "msmpeg4", |
506 CODEC_TYPE_VIDEO, | |
307 | 507 CODEC_ID_MSMPEG4V3, |
0 | 508 sizeof(MpegEncContext), |
509 h263_decode_init, | |
510 NULL, | |
511 h263_decode_end, | |
512 h263_decode_frame, | |
67 | 513 CODEC_CAP_DRAW_HORIZ_BAND, |
0 | 514 }; |
515 | |
311 | 516 AVCodec wmv1_decoder = { |
517 "wmv1", | |
518 CODEC_TYPE_VIDEO, | |
519 CODEC_ID_WMV1, | |
520 sizeof(MpegEncContext), | |
521 h263_decode_init, | |
522 NULL, | |
523 h263_decode_end, | |
524 h263_decode_frame, | |
525 CODEC_CAP_DRAW_HORIZ_BAND, | |
526 }; | |
527 | |
498 | 528 AVCodec wmv2_decoder = { |
529 "wmv2", | |
530 CODEC_TYPE_VIDEO, | |
531 CODEC_ID_WMV2, | |
532 sizeof(MpegEncContext), | |
533 h263_decode_init, | |
534 NULL, | |
535 h263_decode_end, | |
536 h263_decode_frame, | |
537 CODEC_CAP_DRAW_HORIZ_BAND, | |
538 }; | |
539 | |
0 | 540 AVCodec h263i_decoder = { |
541 "h263i", | |
542 CODEC_TYPE_VIDEO, | |
543 CODEC_ID_H263I, | |
544 sizeof(MpegEncContext), | |
545 h263_decode_init, | |
546 NULL, | |
547 h263_decode_end, | |
548 h263_decode_frame, | |
67 | 549 CODEC_CAP_DRAW_HORIZ_BAND, |
0 | 550 }; |
551 |