Originally committed as revision 988 to svn://svn.ffmpeg.org/ffmpeg/trunk
Michael Niedermayer authored on 2002/10/02 04:29:10... | ... |
@@ -591,12 +591,9 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap) |
591 | 591 |
h263_hack_version = get_be32(pb); |
592 | 592 |
switch(h263_hack_version) { |
593 | 593 |
case 0x10000000: |
594 |
- st->codec.sub_id = 0; |
|
595 |
- st->codec.codec_id = CODEC_ID_RV10; |
|
596 |
- break; |
|
597 | 594 |
case 0x10003000: |
598 | 595 |
case 0x10003001: |
599 |
- st->codec.sub_id = 3; |
|
596 |
+ st->codec.sub_id = h263_hack_version; |
|
600 | 597 |
st->codec.codec_id = CODEC_ID_RV10; |
601 | 598 |
break; |
602 | 599 |
default: |
... | ... |
@@ -681,7 +678,6 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) |
681 | 681 |
goto redo; |
682 | 682 |
} |
683 | 683 |
|
684 |
-#if 0 // XXX/FIXME this is done in the codec currently, but should be done here ... |
|
685 | 684 |
if (st->codec.codec_type == CODEC_TYPE_VIDEO) { |
686 | 685 |
int full_frame, h, pic_num; |
687 | 686 |
|
... | ... |
@@ -705,15 +701,11 @@ static int rm_read_packet(AVFormatContext *s, AVPacket *pkt) |
705 | 705 |
/* picture number */ |
706 | 706 |
pic_num= get_byte(pb); |
707 | 707 |
|
708 |
- av_new_packet(pkt, len+1); |
|
709 |
- pkt->stream_index = i; |
|
710 |
- |
|
711 |
- //XXX/FIXME: is this a good idea? |
|
712 |
- pkt->data[0]= h; //store header, its needed for decoding |
|
713 |
- |
|
714 |
- get_buffer(pb, pkt->data+1, len); |
|
708 |
+ //XXX/FIXME/HACK, demuxer should be fixed to send complete frames ... |
|
709 |
+ if(st->codec.slice_offset==NULL) st->codec.slice_offset= (int*)malloc(sizeof(int)); |
|
710 |
+ st->codec.slice_count= full_frame; |
|
711 |
+ st->codec.slice_offset[0]= 0; |
|
715 | 712 |
} |
716 |
-#endif |
|
717 | 713 |
|
718 | 714 |
av_new_packet(pkt, len); |
719 | 715 |
pkt->stream_index = i; |
... | ... |
@@ -5,8 +5,8 @@ |
5 | 5 |
|
6 | 6 |
#define LIBAVCODEC_VERSION_INT 0x000406 |
7 | 7 |
#define LIBAVCODEC_VERSION "0.4.6" |
8 |
-#define LIBAVCODEC_BUILD 4629 |
|
9 |
-#define LIBAVCODEC_BUILD_STR "4629" |
|
8 |
+#define LIBAVCODEC_BUILD 4630 |
|
9 |
+#define LIBAVCODEC_BUILD_STR "4630" |
|
10 | 10 |
|
11 | 11 |
enum CodecID { |
12 | 12 |
CODEC_ID_NONE, |
... | ... |
@@ -699,6 +699,19 @@ typedef struct AVCodecContext { |
699 | 699 |
#define FF_IDCT_MLIB 6 |
700 | 700 |
#define FF_IDCT_ARM 7 |
701 | 701 |
|
702 |
+ /** |
|
703 |
+ * slice count |
|
704 |
+ * encoding: set by lavc |
|
705 |
+ * decoding: set by user (or 0) |
|
706 |
+ */ |
|
707 |
+ int slice_count; |
|
708 |
+ /** |
|
709 |
+ * slice offsets in the frame in bytes |
|
710 |
+ * encoding: set/allocated by lavc |
|
711 |
+ * decoding: set/allocated by user (or NULL) |
|
712 |
+ */ |
|
713 |
+ int *slice_offset; |
|
714 |
+ |
|
702 | 715 |
//FIXME this should be reordered after kabis API is finished ... |
703 | 716 |
//TODO kill kabi |
704 | 717 |
/* |
... | ... |
@@ -265,36 +265,17 @@ static int get_num(GetBitContext *gb) |
265 | 265 |
/* read RV 1.0 compatible frame header */ |
266 | 266 |
static int rv10_decode_picture_header(MpegEncContext *s) |
267 | 267 |
{ |
268 |
- int mb_count, pb_frame, marker, h, full_frame; |
|
269 |
- int pic_num, unk; |
|
268 |
+ int mb_count, pb_frame, marker, full_frame, unk; |
|
270 | 269 |
|
271 |
- //XXX/FIXME this should be done in the demuxer not here |
|
272 |
- /* skip packet header */ |
|
273 |
- h = get_bits(&s->gb, 8); |
|
274 |
- if ((h & 0xc0) == 0xc0) { |
|
275 |
- int len, pos; |
|
276 |
- full_frame = 1; |
|
277 |
- len = get_num(&s->gb); |
|
278 |
- pos = get_num(&s->gb); |
|
279 |
-//printf("pos:%d\n",len); |
|
280 |
- } else { |
|
281 |
- int seq, frame_size, pos; |
|
282 |
- full_frame = 0; |
|
283 |
- seq = get_bits(&s->gb, 8); |
|
284 |
- frame_size = get_num(&s->gb); |
|
285 |
- pos = get_num(&s->gb); |
|
286 |
-//printf("seq:%d, size:%d, pos:%d\n",seq,frame_size,pos); |
|
287 |
- } |
|
288 |
- /* picture number */ |
|
289 |
- pic_num= get_bits(&s->gb, 8); |
|
290 |
- |
|
270 |
+ full_frame= s->avctx->slice_count==1; |
|
271 |
+//printf("ff:%d\n", full_frame); |
|
291 | 272 |
marker = get_bits(&s->gb, 1); |
292 | 273 |
|
293 | 274 |
if (get_bits(&s->gb, 1)) |
294 | 275 |
s->pict_type = P_TYPE; |
295 | 276 |
else |
296 | 277 |
s->pict_type = I_TYPE; |
297 |
-//printf("h:%d ver:%d\n",h,s->rv10_version); |
|
278 |
+//printf("h:%X ver:%d\n",h,s->rv10_version); |
|
298 | 279 |
if(!marker) printf("marker missing\n"); |
299 | 280 |
pb_frame = get_bits(&s->gb, 1); |
300 | 281 |
|
... | ... |
@@ -329,7 +310,7 @@ static int rv10_decode_picture_header(MpegEncContext *s) |
329 | 329 |
} |
330 | 330 |
/* if multiple packets per frame are sent, the position at which |
331 | 331 |
to display the macro blocks is coded here */ |
332 |
- if (!full_frame) { |
|
332 |
+ if ((!full_frame) || show_bits(&s->gb, 12)==0) { |
|
333 | 333 |
s->mb_x = get_bits(&s->gb, 6); /* mb_x */ |
334 | 334 |
s->mb_y = get_bits(&s->gb, 6); /* mb_y */ |
335 | 335 |
mb_count = get_bits(&s->gb, 12); |
... | ... |
@@ -358,28 +339,23 @@ static int rv10_decode_init(AVCodecContext *avctx) |
358 | 358 |
s->height = avctx->height; |
359 | 359 |
|
360 | 360 |
s->h263_rv10 = 1; |
361 |
- if(avctx->extradata_size >= 8){ |
|
362 |
- switch(((uint32_t*)avctx->extradata)[1]){ |
|
363 |
- case 0x10000000: |
|
364 |
- s->rv10_version= 0; |
|
365 |
- s->h263_long_vectors=0; |
|
366 |
- break; |
|
367 |
- case 0x10003000: |
|
368 |
- s->rv10_version= 3; |
|
369 |
- s->h263_long_vectors=1; |
|
370 |
- break; |
|
371 |
- case 0x10003001: |
|
372 |
- s->rv10_version= 3; |
|
373 |
- s->h263_long_vectors=0; |
|
374 |
- break; |
|
375 |
- default: |
|
376 |
- fprintf(stderr, "unknown header %X\n", ((uint32_t*)avctx->extradata)[1]); |
|
377 |
- } |
|
378 |
- }else{ |
|
379 |
- // for backward compatibility |
|
380 |
- s->rv10_version= avctx->sub_id; |
|
361 |
+ switch(avctx->sub_id){ |
|
362 |
+ case 0x10000000: |
|
363 |
+ s->rv10_version= 0; |
|
364 |
+ s->h263_long_vectors=0; |
|
365 |
+ break; |
|
366 |
+ case 0x10003000: |
|
367 |
+ s->rv10_version= 3; |
|
368 |
+ s->h263_long_vectors=1; |
|
369 |
+ break; |
|
370 |
+ case 0x10003001: |
|
371 |
+ s->rv10_version= 3; |
|
372 |
+ s->h263_long_vectors=0; |
|
373 |
+ break; |
|
374 |
+ default: |
|
375 |
+ fprintf(stderr, "unknown header %X\n", avctx->sub_id); |
|
381 | 376 |
} |
382 |
- |
|
377 |
+//printf("ver:%X\n", avctx->sub_id); |
|
383 | 378 |
s->flags= avctx->flags; |
384 | 379 |
|
385 | 380 |
if (MPV_common_init(s) < 0) |
... | ... |
@@ -412,27 +388,15 @@ static int rv10_decode_end(AVCodecContext *avctx) |
412 | 412 |
return 0; |
413 | 413 |
} |
414 | 414 |
|
415 |
-static int rv10_decode_frame(AVCodecContext *avctx, |
|
416 |
- void *data, int *data_size, |
|
415 |
+static int rv10_decode_packet(AVCodecContext *avctx, |
|
417 | 416 |
UINT8 *buf, int buf_size) |
418 | 417 |
{ |
419 | 418 |
MpegEncContext *s = avctx->priv_data; |
420 | 419 |
int i, mb_count, mb_pos, left; |
421 | 420 |
DCTELEM block[6][64]; |
422 |
- AVPicture *pict = data; |
|
423 |
- |
|
424 |
-#ifdef DEBUG |
|
425 |
- printf("*****frame %d size=%d\n", avctx->frame_number, buf_size); |
|
426 |
-#endif |
|
427 |
- |
|
428 |
- /* no supplementary picture */ |
|
429 |
- if (buf_size == 0) { |
|
430 |
- *data_size = 0; |
|
431 |
- return 0; |
|
432 |
- } |
|
433 | 421 |
|
434 | 422 |
init_get_bits(&s->gb, buf, buf_size); |
435 |
- |
|
423 |
+ |
|
436 | 424 |
mb_count = rv10_decode_picture_header(s); |
437 | 425 |
if (mb_count < 0) { |
438 | 426 |
fprintf(stderr, "HEADER ERROR\n"); |
... | ... |
@@ -510,8 +474,46 @@ static int rv10_decode_frame(AVCodecContext *avctx, |
510 | 510 |
} |
511 | 511 |
} |
512 | 512 |
|
513 |
- if (s->mb_x == 0 && |
|
514 |
- s->mb_y == s->mb_height) { |
|
513 |
+ return buf_size; |
|
514 |
+} |
|
515 |
+ |
|
516 |
+static int rv10_decode_frame(AVCodecContext *avctx, |
|
517 |
+ void *data, int *data_size, |
|
518 |
+ UINT8 *buf, int buf_size) |
|
519 |
+{ |
|
520 |
+ MpegEncContext *s = avctx->priv_data; |
|
521 |
+ int i; |
|
522 |
+ AVPicture *pict = data; |
|
523 |
+ |
|
524 |
+#ifdef DEBUG |
|
525 |
+ printf("*****frame %d size=%d\n", avctx->frame_number, buf_size); |
|
526 |
+#endif |
|
527 |
+ |
|
528 |
+ /* no supplementary picture */ |
|
529 |
+ if (buf_size == 0) { |
|
530 |
+ *data_size = 0; |
|
531 |
+ return 0; |
|
532 |
+ } |
|
533 |
+ |
|
534 |
+ if(avctx->slice_count){ |
|
535 |
+ for(i=0; i<avctx->slice_count; i++){ |
|
536 |
+ int offset= avctx->slice_offset[i]; |
|
537 |
+ int size; |
|
538 |
+ |
|
539 |
+ if(i+1 == avctx->slice_count) |
|
540 |
+ size= buf_size - offset; |
|
541 |
+ else |
|
542 |
+ size= avctx->slice_offset[i+1] - offset; |
|
543 |
+ |
|
544 |
+ if( rv10_decode_packet(avctx, buf+offset, size) < 0 ) |
|
545 |
+ return -1; |
|
546 |
+ } |
|
547 |
+ }else{ |
|
548 |
+ if( rv10_decode_packet(avctx, buf, buf_size) < 0 ) |
|
549 |
+ return -1; |
|
550 |
+ } |
|
551 |
+ |
|
552 |
+ if(s->mb_y>=s->mb_height){ |
|
515 | 553 |
MPV_frame_end(s); |
516 | 554 |
|
517 | 555 |
pict->data[0] = s->current_picture[0]; |
... | ... |
@@ -520,12 +522,13 @@ static int rv10_decode_frame(AVCodecContext *avctx, |
520 | 520 |
pict->linesize[0] = s->linesize; |
521 | 521 |
pict->linesize[1] = s->uvlinesize; |
522 | 522 |
pict->linesize[2] = s->uvlinesize; |
523 |
- |
|
523 |
+ |
|
524 | 524 |
avctx->quality = s->qscale; |
525 | 525 |
*data_size = sizeof(AVPicture); |
526 |
- } else { |
|
526 |
+ }else{ |
|
527 | 527 |
*data_size = 0; |
528 | 528 |
} |
529 |
+ |
|
529 | 530 |
return buf_size; |
530 | 531 |
} |
531 | 532 |
|