Mercurial > libavcodec.hg
comparison dv.c @ 738:044307862b4b libavcodec
support buffers containing more than one frame
author | bellard |
---|---|
date | Wed, 09 Oct 2002 12:35:22 +0000 |
parents | 248a752a4c0e |
children | 9cec9eab681f |
comparison
equal
deleted
inserted
replaced
737:248a752a4c0e | 738:044307862b4b |
---|---|
492 static int dvvideo_decode_frame(AVCodecContext *avctx, | 492 static int dvvideo_decode_frame(AVCodecContext *avctx, |
493 void *data, int *data_size, | 493 void *data, int *data_size, |
494 UINT8 *buf, int buf_size) | 494 UINT8 *buf, int buf_size) |
495 { | 495 { |
496 DVVideoDecodeContext *s = avctx->priv_data; | 496 DVVideoDecodeContext *s = avctx->priv_data; |
497 int sct, dsf, apt, ds, nb_dif_segs, vs, size, width, height, i; | 497 int sct, dsf, apt, ds, nb_dif_segs, vs, size, width, height, i, packet_size; |
498 UINT8 *buf_ptr; | 498 UINT8 *buf_ptr; |
499 const UINT16 *mb_pos_ptr; | 499 const UINT16 *mb_pos_ptr; |
500 AVPicture *picture; | 500 AVPicture *picture; |
501 | 501 |
502 /* parse id */ | 502 /* parse id */ |
529 get_bits(&s->gb, 3); /* ap3 */ | 529 get_bits(&s->gb, 3); /* ap3 */ |
530 | 530 |
531 /* init size */ | 531 /* init size */ |
532 width = 720; | 532 width = 720; |
533 if (dsf) { | 533 if (dsf) { |
534 if (buf_size != PAL_FRAME_SIZE) | 534 packet_size = PAL_FRAME_SIZE; |
535 return -1; | |
536 height = 576; | 535 height = 576; |
537 nb_dif_segs = 12; | 536 nb_dif_segs = 12; |
538 } else { | 537 } else { |
539 if (buf_size != NTSC_FRAME_SIZE) | 538 packet_size = NTSC_FRAME_SIZE; |
540 return -1; | |
541 height = 480; | 539 height = 480; |
542 nb_dif_segs = 10; | 540 nb_dif_segs = 10; |
543 } | 541 } |
544 | 542 /* NOTE: we only accept several full frames */ |
543 if (buf_size < packet_size) | |
544 return -1; | |
545 | |
545 /* XXX: is it correct to assume that 420 is always used in PAL | 546 /* XXX: is it correct to assume that 420 is always used in PAL |
546 mode ? */ | 547 mode ? */ |
547 s->sampling_411 = !dsf; | 548 s->sampling_411 = !dsf; |
548 if (s->sampling_411) | 549 if (s->sampling_411) |
549 mb_pos_ptr = dv_place_411; | 550 mb_pos_ptr = dv_place_411; |
602 picture = data; | 603 picture = data; |
603 for(i=0;i<3;i++) { | 604 for(i=0;i<3;i++) { |
604 picture->data[i] = s->current_picture[i]; | 605 picture->data[i] = s->current_picture[i]; |
605 picture->linesize[i] = s->linesize[i]; | 606 picture->linesize[i] = s->linesize[i]; |
606 } | 607 } |
607 | 608 return packet_size; |
608 return buf_size; | |
609 } | 609 } |
610 | 610 |
611 static int dvvideo_decode_end(AVCodecContext *avctx) | 611 static int dvvideo_decode_end(AVCodecContext *avctx) |
612 { | 612 { |
613 DVVideoDecodeContext *s = avctx->priv_data; | 613 DVVideoDecodeContext *s = avctx->priv_data; |