Mercurial > libavcodec.hg
annotate h263dec.c @ 485:20108840b0e5 libavcodec
grayscale only decoding
author | michaelni |
---|---|
date | Sun, 09 Jun 2002 13:35:56 +0000 |
parents | 76c8afc9c1eb |
children | 0b4450c15067 |
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; | |
0 | 79 case CODEC_ID_H263I: |
80 s->h263_intel = 1; | |
81 break; | |
82 default: | |
83 return -1; | |
84 } | |
344 | 85 s->codec_id= avctx->codec->id; |
345 | 86 avctx->mbskip_table= s->mbskip_table; |
344 | 87 |
0 | 88 /* 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
|
89 if (avctx->codec->id != CODEC_ID_H263 && avctx->codec->id != CODEC_ID_MPEG4) |
144 | 90 if (MPV_common_init(s) < 0) |
91 return -1; | |
0 | 92 |
93 if (s->h263_msmpeg4) | |
94 msmpeg4_decode_init_vlc(s); | |
95 else | |
96 h263_decode_init_vlc(s); | |
97 | |
98 return 0; | |
99 } | |
100 | |
101 static int h263_decode_end(AVCodecContext *avctx) | |
102 { | |
103 MpegEncContext *s = avctx->priv_data; | |
104 | |
105 MPV_common_end(s); | |
106 return 0; | |
107 } | |
108 | |
109 static int h263_decode_frame(AVCodecContext *avctx, | |
110 void *data, int *data_size, | |
111 UINT8 *buf, int buf_size) | |
112 { | |
113 MpegEncContext *s = avctx->priv_data; | |
114 int ret; | |
115 AVPicture *pict = data; | |
384 | 116 #ifdef PRINT_FRAME_TIME |
117 uint64_t time= rdtsc(); | |
118 #endif | |
0 | 119 #ifdef DEBUG |
120 printf("*****frame %d size=%d\n", avctx->frame_number, buf_size); | |
121 printf("bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]); | |
122 #endif | |
345 | 123 |
124 s->hurry_up= avctx->hurry_up; | |
454 | 125 s->error_resilience= avctx->error_resilience; |
126 s->workaround_bugs= avctx->workaround_bugs; | |
485 | 127 s->flags= avctx->flags; |
454 | 128 |
0 | 129 /* no supplementary picture */ |
130 if (buf_size == 0) { | |
131 *data_size = 0; | |
132 return 0; | |
133 } | |
134 | |
465 | 135 if(s->bitstream_buffer_size && buf_size<20){ //divx 5.01+ frame reorder |
333 | 136 init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size); |
353 | 137 }else |
333 | 138 init_get_bits(&s->gb, buf, buf_size); |
465 | 139 s->bitstream_buffer_size=0; |
0 | 140 |
141 /* let's go :-) */ | |
142 if (s->h263_msmpeg4) { | |
143 ret = msmpeg4_decode_picture_header(s); | |
144 } else if (s->h263_pred) { | |
145 ret = mpeg4_decode_picture_header(s); | |
336 | 146 s->has_b_frames= !s->low_delay; |
0 | 147 } else if (s->h263_intel) { |
148 ret = intel_h263_decode_picture_header(s); | |
149 } else { | |
150 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
|
151 } |
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
152 |
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
153 /* After H263 & mpeg4 header decode we have the height, width,*/ |
160 | 154 /* and other parameters. So then we could init the picture */ |
155 /* FIXME: By the way H263 decoder is evolving it should have */ | |
156 /* an H263EncContext */ | |
274
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
157 if (!s->context_initialized) { |
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
158 avctx->width = s->width; |
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
159 avctx->height = s->height; |
281
1fc96b02142e
mpeg4 aspect_ratio_info in AVCodecContext (requested by alex)
michaelni
parents:
274
diff
changeset
|
160 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
|
161 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
|
162 return -1; |
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
163 } 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
|
164 /* 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
|
165 MPV_common_end(s); |
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; |
0 | 168 } |
274
d0c186bcf075
use the width & height from the mpeg4 header ... in the case that its complete
michaelni
parents:
273
diff
changeset
|
169 |
341 | 170 if(ret==FRAME_SKIPED) return 0; |
454 | 171 /* skip if the header was thrashed */ |
0 | 172 if (ret < 0) |
173 return -1; | |
341 | 174 /* skip b frames if we dont have reference frames */ |
175 if(s->num_available_buffers<2 && s->pict_type==B_TYPE) return 0; | |
345 | 176 /* skip b frames if we are in a hurry */ |
177 if(s->hurry_up && s->pict_type==B_TYPE) return 0; | |
454 | 178 |
179 if(s->next_p_frame_damaged){ | |
180 if(s->pict_type==B_TYPE) | |
181 return 0; | |
182 else | |
183 s->next_p_frame_damaged=0; | |
184 } | |
185 | |
0 | 186 MPV_frame_start(s); |
187 | |
188 #ifdef DEBUG | |
189 printf("qscale=%d\n", s->qscale); | |
190 #endif | |
191 | |
454 | 192 /* init resync/ error resilience specific variables */ |
193 s->next_resync_qscale= s->qscale; | |
194 s->next_resync_gb= s->gb; | |
195 if(s->resync_marker) s->mb_num_left= 0; | |
196 else s->mb_num_left= s->mb_num; | |
197 | |
0 | 198 /* decode each macroblock */ |
266 | 199 s->block_wrap[0]= |
200 s->block_wrap[1]= | |
201 s->block_wrap[2]= | |
202 s->block_wrap[3]= s->mb_width*2 + 2; | |
203 s->block_wrap[4]= | |
204 s->block_wrap[5]= s->mb_width + 2; | |
0 | 205 for(s->mb_y=0; s->mb_y < s->mb_height; s->mb_y++) { |
162 | 206 /* Check for GOB headers on H.263 */ |
207 /* FIXME: In the future H.263+ will have intra prediction */ | |
208 /* and we are gonna need another way to detect MPEG4 */ | |
209 if (s->mb_y && !s->h263_pred) { | |
454 | 210 s->first_slice_line = h263_decode_gob_header(s); |
211 } | |
212 | |
213 if(s->msmpeg4_version==1){ | |
214 s->last_dc[0]= | |
215 s->last_dc[1]= | |
216 s->last_dc[2]= 128; | |
162 | 217 } |
296 | 218 |
266 | 219 s->block_index[0]= s->block_wrap[0]*(s->mb_y*2 + 1) - 1; |
220 s->block_index[1]= s->block_wrap[0]*(s->mb_y*2 + 1); | |
221 s->block_index[2]= s->block_wrap[0]*(s->mb_y*2 + 2) - 1; | |
222 s->block_index[3]= s->block_wrap[0]*(s->mb_y*2 + 2); | |
223 s->block_index[4]= s->block_wrap[4]*(s->mb_y + 1) + s->block_wrap[0]*(s->mb_height*2 + 2); | |
224 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 | 225 for(s->mb_x=0; s->mb_x < s->mb_width; s->mb_x++) { |
266 | 226 s->block_index[0]+=2; |
227 s->block_index[1]+=2; | |
228 s->block_index[2]+=2; | |
229 s->block_index[3]+=2; | |
230 s->block_index[4]++; | |
231 s->block_index[5]++; | |
0 | 232 #ifdef DEBUG |
233 printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y); | |
234 #endif | |
454 | 235 |
236 if(s->resync_marker){ | |
237 if(s->mb_num_left<=0){ | |
238 /* except the first block */ | |
239 if(s->mb_x!=0 || s->mb_y!=0){ | |
240 /* did we miss the next resync marker without noticing an error yet */ | |
241 if(((get_bits_count(&s->gb)+8)&(~7)) != s->next_resync_pos && s->decoding_error==0){ | |
242 fprintf(stderr, "slice end missmatch x:%d y:%d %d %d\n", | |
243 s->mb_x, s->mb_y, get_bits_count(&s->gb), s->next_resync_pos); | |
244 ff_conceal_past_errors(s, 1); | |
245 } | |
246 } | |
247 s->qscale= s->next_resync_qscale; | |
248 s->gb= s->next_resync_gb; | |
249 s->resync_mb_x= s->mb_x; //we know that the marker is here cuz mb_num_left was the distance to it | |
250 s->resync_mb_y= s->mb_y; | |
251 s->first_slice_line=1; | |
252 | |
253 if(s->codec_id==CODEC_ID_MPEG4){ | |
254 ff_mpeg4_clean_buffers(s); | |
255 ff_mpeg4_resync(s); | |
256 } | |
257 } | |
258 | |
259 if( s->resync_mb_x==s->mb_x | |
260 && s->resync_mb_y==s->mb_y && s->decoding_error!=0){ | |
261 fprintf(stderr, "resynced at %d %d\n", s->mb_x, s->mb_y); | |
262 s->decoding_error= 0; | |
263 } | |
264 } | |
265 | |
144 | 266 //fprintf(stderr,"\nFrame: %d\tMB: %d",avctx->frame_number, (s->mb_y * s->mb_width) + s->mb_x); |
0 | 267 /* DCT & quantize */ |
454 | 268 if (s->h263_pred && !(s->msmpeg4_version==1 || s->msmpeg4_version==2)) { |
411
5c8b3a717929
workaround dc_scale bug in old ffmpeg msmpeg4v3 encoder (set workaround_bugs=1 for this)
michaelni
parents:
396
diff
changeset
|
269 /* old ffmpeg encoded msmpeg4v3 workaround */ |
5c8b3a717929
workaround dc_scale bug in old ffmpeg msmpeg4v3 encoder (set workaround_bugs=1 for this)
michaelni
parents:
396
diff
changeset
|
270 if(s->workaround_bugs==1 && s->msmpeg4_version==3) |
5c8b3a717929
workaround dc_scale bug in old ffmpeg msmpeg4v3 encoder (set workaround_bugs=1 for this)
michaelni
parents:
396
diff
changeset
|
271 ff_old_msmpeg4_dc_scale(s); |
5c8b3a717929
workaround dc_scale bug in old ffmpeg msmpeg4v3 encoder (set workaround_bugs=1 for this)
michaelni
parents:
396
diff
changeset
|
272 else |
5c8b3a717929
workaround dc_scale bug in old ffmpeg msmpeg4v3 encoder (set workaround_bugs=1 for this)
michaelni
parents:
396
diff
changeset
|
273 h263_dc_scale(s); |
0 | 274 } else { |
275 /* default quantization values */ | |
276 s->y_dc_scale = 8; | |
277 s->c_dc_scale = 8; | |
278 } | |
454 | 279 |
280 if(s->decoding_error!=DECODING_DESYNC){ | |
281 int last_error= s->decoding_error; | |
282 clear_blocks(s->block[0]); | |
296 | 283 |
454 | 284 s->mv_dir = MV_DIR_FORWARD; |
285 s->mv_type = MV_TYPE_16X16; | |
286 if (s->h263_msmpeg4) { | |
287 if (msmpeg4_decode_mb(s, s->block) < 0) { | |
288 fprintf(stderr,"Error at MB: %d\n", (s->mb_y * s->mb_width) + s->mb_x); | |
289 s->decoding_error=DECODING_DESYNC; | |
290 } | |
291 } else { | |
292 if (h263_decode_mb(s, s->block) < 0) { | |
293 fprintf(stderr,"Error at MB: %d\n", (s->mb_y * s->mb_width) + s->mb_x); | |
294 s->decoding_error=DECODING_DESYNC; | |
295 } | |
296 } | |
297 | |
298 if(s->decoding_error!=last_error){ | |
299 ff_conceal_past_errors(s, 0); | |
161 | 300 } |
0 | 301 } |
454 | 302 |
303 /* conceal errors */ | |
304 if( s->decoding_error==DECODING_DESYNC | |
305 || (s->decoding_error==DECODING_ACDC_LOST && s->mb_intra)){ | |
306 s->mv_dir = MV_DIR_FORWARD; | |
307 s->mv_type = MV_TYPE_16X16; | |
308 s->mb_skiped=0; | |
309 s->mb_intra=0; | |
310 s->mv[0][0][0]=0; //FIXME this is not optimal | |
311 s->mv[0][0][1]=0; | |
312 clear_blocks(s->block[0]); | |
313 }else if(s->decoding_error && !s->mb_intra){ | |
314 clear_blocks(s->block[0]); | |
315 } | |
316 //FIXME remove AC for intra | |
317 | |
12
4d50c7d89e0f
use block[] in structure to have it aligned on 8 bytes for mmx optimizations
glantau
parents:
0
diff
changeset
|
318 MPV_decode_mb(s, s->block); |
454 | 319 |
320 s->mb_num_left--; | |
0 | 321 } |
341 | 322 if ( avctx->draw_horiz_band |
323 && (s->num_available_buffers>=1 || (!s->has_b_frames)) ) { | |
67 | 324 UINT8 *src_ptr[3]; |
325 int y, h, offset; | |
326 y = s->mb_y * 16; | |
327 h = s->height - y; | |
328 if (h > 16) | |
329 h = 16; | |
330 offset = y * s->linesize; | |
308 | 331 if(s->pict_type==B_TYPE || (!s->has_b_frames)){ |
332 src_ptr[0] = s->current_picture[0] + offset; | |
333 src_ptr[1] = s->current_picture[1] + (offset >> 2); | |
334 src_ptr[2] = s->current_picture[2] + (offset >> 2); | |
335 } else { | |
336 src_ptr[0] = s->last_picture[0] + offset; | |
337 src_ptr[1] = s->last_picture[1] + (offset >> 2); | |
338 src_ptr[2] = s->last_picture[2] + (offset >> 2); | |
339 } | |
67 | 340 avctx->draw_horiz_band(avctx, src_ptr, s->linesize, |
341 y, s->width, h); | |
342 } | |
0 | 343 } |
208 | 344 |
311 | 345 if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==I_TYPE) |
208 | 346 if(msmpeg4_decode_ext_header(s, buf_size) < 0) return -1; |
333 | 347 |
348 /* divx 5.01+ bistream reorder stuff */ | |
344 | 349 if(s->codec_id==CODEC_ID_MPEG4 && s->bitstream_buffer_size==0){ |
454 | 350 int current_pos= get_bits_count(&s->gb)>>3; |
351 | |
333 | 352 if( buf_size - current_pos > 5 |
353 && buf_size - current_pos < BITSTREAM_BUFFER_SIZE){ | |
454 | 354 int i; |
355 int startcode_found=0; | |
356 for(i=current_pos; i<buf_size; i++){ | |
357 if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1 && buf[i+3]==0xB6){ | |
358 startcode_found=1; | |
359 break; | |
360 } | |
361 } | |
362 if(startcode_found){ | |
363 memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos); | |
364 s->bitstream_buffer_size= buf_size - current_pos; | |
365 } | |
366 } | |
367 } | |
368 | |
369 if(s->bitstream_buffer_size==0 && s->error_resilience>0){ | |
370 int left= s->gb.size*8 - get_bits_count(&s->gb); | |
371 int max_extra=8; | |
372 | |
373 if(s->codec_id==CODEC_ID_MPEG4) max_extra+=32; | |
374 | |
375 if(left>max_extra){ | |
376 fprintf(stderr, "discarding %d junk bits at end, next would be %X\n", left, show_bits(&s->gb, 24)); | |
377 if(s->decoding_error==0) | |
378 ff_conceal_past_errors(s, 1); | |
379 } | |
380 if(left<0){ | |
381 fprintf(stderr, "overreading %d bits\n", -left); | |
382 if(s->decoding_error==0) | |
383 ff_conceal_past_errors(s, 1); | |
333 | 384 } |
353 | 385 } |
333 | 386 |
0 | 387 MPV_frame_end(s); |
361 | 388 #if 0 //dirty show MVs, we should export the MV tables and write a filter to show them |
389 { | |
390 int mb_y; | |
391 s->has_b_frames=1; | |
392 for(mb_y=0; mb_y<s->mb_height; mb_y++){ | |
393 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
|
394 int y= mb_y*16 + 8; |
361 | 395 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
|
396 int x= mb_x*16 + 8; |
361 | 397 uint8_t *ptr= s->last_picture[0]; |
398 int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2); | |
399 int mx= (s->motion_val[xy][0]>>1) + x; | |
400 int my= (s->motion_val[xy][1]>>1) + y; | |
401 int i; | |
402 int max; | |
403 | |
404 if(mx<0) mx=0; | |
405 if(my<0) my=0; | |
406 if(mx>=s->width) mx= s->width -1; | |
407 if(my>=s->height) my= s->height-1; | |
408 max= ABS(mx-x); | |
409 if(ABS(my-y) > max) max= ABS(my-y); | |
410 /* the ugliest linedrawing routine ... */ | |
411 for(i=0; i<max; i++){ | |
412 int x1= x + (mx-x)*i/max; | |
413 int y1= y + (my-y)*i/max; | |
414 ptr[y1*s->linesize + x1]+=100; | |
415 } | |
411
5c8b3a717929
workaround dc_scale bug in old ffmpeg msmpeg4v3 encoder (set workaround_bugs=1 for this)
michaelni
parents:
396
diff
changeset
|
416 ptr[y*s->linesize + x]+=100; |
361 | 417 s->mbskip_table[mb_x + mb_y*s->mb_width]=0; |
418 } | |
419 } | |
420 | |
421 } | |
422 #endif | |
273
34f40a0fc840
msmpeg4 bugfix (wrong frame displayed if some frames are skipped)
michaelni
parents:
266
diff
changeset
|
423 if(s->pict_type==B_TYPE || (!s->has_b_frames)){ |
262 | 424 pict->data[0] = s->current_picture[0]; |
425 pict->data[1] = s->current_picture[1]; | |
426 pict->data[2] = s->current_picture[2]; | |
427 } else { | |
428 pict->data[0] = s->last_picture[0]; | |
429 pict->data[1] = s->last_picture[1]; | |
430 pict->data[2] = s->last_picture[2]; | |
431 } | |
0 | 432 pict->linesize[0] = s->linesize; |
433 pict->linesize[1] = s->linesize / 2; | |
434 pict->linesize[2] = s->linesize / 2; | |
435 | |
436 avctx->quality = s->qscale; | |
231 | 437 |
438 /* Return the Picture timestamp as the frame number */ | |
439 /* we substract 1 because it is added on utils.c */ | |
440 avctx->frame_number = s->picture_number - 1; | |
441 | |
341 | 442 /* dont output the last pic after seeking |
443 note we allready added +1 for the current pix in MPV_frame_end(s) */ | |
444 if(s->num_available_buffers>=2 || (!s->has_b_frames)) | |
445 *data_size = sizeof(AVPicture); | |
384 | 446 #ifdef PRINT_FRAME_TIME |
447 printf("%Ld\n", rdtsc()-time); | |
448 #endif | |
0 | 449 return buf_size; |
450 } | |
451 | |
67 | 452 AVCodec mpeg4_decoder = { |
453 "mpeg4", | |
0 | 454 CODEC_TYPE_VIDEO, |
67 | 455 CODEC_ID_MPEG4, |
0 | 456 sizeof(MpegEncContext), |
457 h263_decode_init, | |
458 NULL, | |
459 h263_decode_end, | |
460 h263_decode_frame, | |
67 | 461 CODEC_CAP_DRAW_HORIZ_BAND, |
0 | 462 }; |
463 | |
464 AVCodec h263_decoder = { | |
465 "h263", | |
466 CODEC_TYPE_VIDEO, | |
467 CODEC_ID_H263, | |
468 sizeof(MpegEncContext), | |
469 h263_decode_init, | |
470 NULL, | |
471 h263_decode_end, | |
472 h263_decode_frame, | |
67 | 473 CODEC_CAP_DRAW_HORIZ_BAND, |
0 | 474 }; |
475 | |
307 | 476 AVCodec msmpeg4v1_decoder = { |
477 "msmpeg4v1", | |
478 CODEC_TYPE_VIDEO, | |
479 CODEC_ID_MSMPEG4V1, | |
480 sizeof(MpegEncContext), | |
481 h263_decode_init, | |
482 NULL, | |
483 h263_decode_end, | |
484 h263_decode_frame, | |
485 CODEC_CAP_DRAW_HORIZ_BAND, | |
486 }; | |
487 | |
488 AVCodec msmpeg4v2_decoder = { | |
489 "msmpeg4v2", | |
490 CODEC_TYPE_VIDEO, | |
491 CODEC_ID_MSMPEG4V2, | |
492 sizeof(MpegEncContext), | |
493 h263_decode_init, | |
494 NULL, | |
495 h263_decode_end, | |
496 h263_decode_frame, | |
497 CODEC_CAP_DRAW_HORIZ_BAND, | |
498 }; | |
499 | |
500 AVCodec msmpeg4v3_decoder = { | |
0 | 501 "msmpeg4", |
502 CODEC_TYPE_VIDEO, | |
307 | 503 CODEC_ID_MSMPEG4V3, |
0 | 504 sizeof(MpegEncContext), |
505 h263_decode_init, | |
506 NULL, | |
507 h263_decode_end, | |
508 h263_decode_frame, | |
67 | 509 CODEC_CAP_DRAW_HORIZ_BAND, |
0 | 510 }; |
511 | |
311 | 512 AVCodec wmv1_decoder = { |
513 "wmv1", | |
514 CODEC_TYPE_VIDEO, | |
515 CODEC_ID_WMV1, | |
516 sizeof(MpegEncContext), | |
517 h263_decode_init, | |
518 NULL, | |
519 h263_decode_end, | |
520 h263_decode_frame, | |
521 CODEC_CAP_DRAW_HORIZ_BAND, | |
522 }; | |
523 | |
0 | 524 AVCodec h263i_decoder = { |
525 "h263i", | |
526 CODEC_TYPE_VIDEO, | |
527 CODEC_ID_H263I, | |
528 sizeof(MpegEncContext), | |
529 h263_decode_init, | |
530 NULL, | |
531 h263_decode_end, | |
532 h263_decode_frame, | |
67 | 533 CODEC_CAP_DRAW_HORIZ_BAND, |
0 | 534 }; |
535 |