Mercurial > libavcodec.hg
comparison svq1dec.c @ 11960:670516285e58 libavcodec
svq1dec: replace VLA with malloc/free
author | mru |
---|---|
date | Sat, 26 Jun 2010 14:34:08 +0000 |
parents | 7dd2a45249a9 |
children |
comparison
equal
deleted
inserted
replaced
11959:447f1cd16355 | 11960:670516285e58 |
---|---|
648 int buf_size = avpkt->size; | 648 int buf_size = avpkt->size; |
649 MpegEncContext *s=avctx->priv_data; | 649 MpegEncContext *s=avctx->priv_data; |
650 uint8_t *current, *previous; | 650 uint8_t *current, *previous; |
651 int result, i, x, y, width, height; | 651 int result, i, x, y, width, height; |
652 AVFrame *pict = data; | 652 AVFrame *pict = data; |
653 svq1_pmv *pmv; | |
653 | 654 |
654 /* initialize bit buffer */ | 655 /* initialize bit buffer */ |
655 init_get_bits(&s->gb,buf,buf_size*8); | 656 init_get_bits(&s->gb,buf,buf_size*8); |
656 | 657 |
657 /* decode frame header */ | 658 /* decode frame header */ |
688 ||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=FF_I_TYPE) | 689 ||(avctx->skip_frame >= AVDISCARD_NONKEY && s->pict_type!=FF_I_TYPE) |
689 || avctx->skip_frame >= AVDISCARD_ALL) | 690 || avctx->skip_frame >= AVDISCARD_ALL) |
690 return buf_size; | 691 return buf_size; |
691 | 692 |
692 if(MPV_frame_start(s, avctx) < 0) | 693 if(MPV_frame_start(s, avctx) < 0) |
694 return -1; | |
695 | |
696 pmv = av_malloc((FFALIGN(s->width, 16)/8 + 3) * sizeof(*pmv)); | |
697 if (!pmv) | |
693 return -1; | 698 return -1; |
694 | 699 |
695 /* decode y, u and v components */ | 700 /* decode y, u and v components */ |
696 for (i=0; i < 3; i++) { | 701 for (i=0; i < 3; i++) { |
697 int linesize; | 702 int linesize; |
722 if (result != 0) | 727 if (result != 0) |
723 { | 728 { |
724 //#ifdef DEBUG_SVQ1 | 729 //#ifdef DEBUG_SVQ1 |
725 av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_block %i (keyframe)\n",result); | 730 av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_block %i (keyframe)\n",result); |
726 //#endif | 731 //#endif |
727 return result; | 732 goto err; |
728 } | 733 } |
729 } | 734 } |
730 current += 16*linesize; | 735 current += 16*linesize; |
731 } | 736 } |
732 } else { | 737 } else { |
733 svq1_pmv pmv[width/8+3]; | |
734 /* delta frame */ | 738 /* delta frame */ |
735 memset (pmv, 0, ((width / 8) + 3) * sizeof(svq1_pmv)); | 739 memset (pmv, 0, ((width / 8) + 3) * sizeof(svq1_pmv)); |
736 | 740 |
737 for (y=0; y < height; y+=16) { | 741 for (y=0; y < height; y+=16) { |
738 for (x=0; x < width; x+=16) { | 742 for (x=0; x < width; x+=16) { |
741 if (result != 0) | 745 if (result != 0) |
742 { | 746 { |
743 #ifdef DEBUG_SVQ1 | 747 #ifdef DEBUG_SVQ1 |
744 av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_delta_block %i\n",result); | 748 av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_delta_block %i\n",result); |
745 #endif | 749 #endif |
746 return result; | 750 goto err; |
747 } | 751 } |
748 } | 752 } |
749 | 753 |
750 pmv[0].x = | 754 pmv[0].x = |
751 pmv[0].y = 0; | 755 pmv[0].y = 0; |
759 | 763 |
760 | 764 |
761 MPV_frame_end(s); | 765 MPV_frame_end(s); |
762 | 766 |
763 *data_size=sizeof(AVFrame); | 767 *data_size=sizeof(AVFrame); |
764 return buf_size; | 768 result = buf_size; |
769 err: | |
770 av_free(pmv); | |
771 return result; | |
765 } | 772 } |
766 | 773 |
767 static av_cold int svq1_decode_init(AVCodecContext *avctx) | 774 static av_cold int svq1_decode_init(AVCodecContext *avctx) |
768 { | 775 { |
769 MpegEncContext *s = avctx->priv_data; | 776 MpegEncContext *s = avctx->priv_data; |