Mercurial > libavcodec.hg
comparison truemotion2.c @ 8723:0acc958e87b0 libavcodec
Make TM2 decoder byteswap input into separate buffer instead of doing it in-place.
author | kostya |
---|---|
date | Sun, 01 Feb 2009 15:27:44 +0000 |
parents | ad457492fd92 |
children | 54bc8a2727b0 |
comparison
equal
deleted
inserted
replaced
8722:ad457492fd92 | 8723:0acc958e87b0 |
---|---|
766 const uint8_t *buf, int buf_size) | 766 const uint8_t *buf, int buf_size) |
767 { | 767 { |
768 TM2Context * const l = avctx->priv_data; | 768 TM2Context * const l = avctx->priv_data; |
769 AVFrame * const p= (AVFrame*)&l->pic; | 769 AVFrame * const p= (AVFrame*)&l->pic; |
770 int i, skip, t; | 770 int i, skip, t; |
771 | 771 uint8_t *swbuf; |
772 | |
773 swbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); | |
774 if(!swbuf){ | |
775 av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n"); | |
776 return -1; | |
777 } | |
772 p->reference = 1; | 778 p->reference = 1; |
773 p->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; | 779 p->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; |
774 if(avctx->reget_buffer(avctx, p) < 0){ | 780 if(avctx->reget_buffer(avctx, p) < 0){ |
775 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | 781 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
776 return -1; | 782 av_free(swbuf); |
777 } | 783 return -1; |
778 | 784 } |
779 l->dsp.bswap_buf((uint32_t*)buf, (const uint32_t*)buf, buf_size >> 2); //FIXME SERIOUS BUG | 785 |
780 skip = tm2_read_header(l, buf); | 786 l->dsp.bswap_buf((uint32_t*)swbuf, (const uint32_t*)buf, buf_size >> 2); |
781 | 787 skip = tm2_read_header(l, swbuf); |
782 if(skip == -1) | 788 |
783 return -1; | 789 if(skip == -1){ |
790 av_free(swbuf); | |
791 return -1; | |
792 } | |
784 | 793 |
785 for(i = 0; i < TM2_NUM_STREAMS; i++){ | 794 for(i = 0; i < TM2_NUM_STREAMS; i++){ |
786 t = tm2_read_stream(l, buf + skip, tm2_stream_order[i]); | 795 t = tm2_read_stream(l, swbuf + skip, tm2_stream_order[i]); |
787 if(t == -1){ | 796 if(t == -1){ |
797 av_free(swbuf); | |
788 return -1; | 798 return -1; |
789 } | 799 } |
790 skip += t; | 800 skip += t; |
791 } | 801 } |
792 p->key_frame = tm2_decode_blocks(l, p); | 802 p->key_frame = tm2_decode_blocks(l, p); |
796 p->pict_type = FF_P_TYPE; | 806 p->pict_type = FF_P_TYPE; |
797 | 807 |
798 l->cur = !l->cur; | 808 l->cur = !l->cur; |
799 *data_size = sizeof(AVFrame); | 809 *data_size = sizeof(AVFrame); |
800 *(AVFrame*)data = l->pic; | 810 *(AVFrame*)data = l->pic; |
811 av_free(swbuf); | |
801 | 812 |
802 return buf_size; | 813 return buf_size; |
803 } | 814 } |
804 | 815 |
805 static av_cold int decode_init(AVCodecContext *avctx){ | 816 static av_cold int decode_init(AVCodecContext *avctx){ |