Mercurial > libavcodec.hg
comparison atrac3.c @ 7939:cd8602533b62 libavcodec
atrac3: ensure input frame is not overwritten (it is const)
this fixes the following warning:
atrac3.c:889: warning: assignment discards qualifiers from pointer target type
author | aurel |
---|---|
date | Mon, 29 Sep 2008 22:22:46 +0000 |
parents | 8226017a65ae |
children | bf12bb0efb68 |
comparison
equal
deleted
inserted
replaced
7938:66226ee647a4 | 7939:cd8602533b62 |
---|---|
776 * | 776 * |
777 * @param q Atrac3 private context | 777 * @param q Atrac3 private context |
778 * @param databuf the input data | 778 * @param databuf the input data |
779 */ | 779 */ |
780 | 780 |
781 static int decodeFrame(ATRAC3Context *q, uint8_t* databuf) | 781 static int decodeFrame(ATRAC3Context *q, const uint8_t* databuf) |
782 { | 782 { |
783 int result, i; | 783 int result, i; |
784 float *p1, *p2, *p3, *p4; | 784 float *p1, *p2, *p3, *p4; |
785 uint8_t *ptr1, *ptr2; | 785 uint8_t *ptr1; |
786 | 786 |
787 if (q->codingMode == JOINT_STEREO) { | 787 if (q->codingMode == JOINT_STEREO) { |
788 | 788 |
789 /* channel coupling mode */ | 789 /* channel coupling mode */ |
790 /* decode Sound Unit 1 */ | 790 /* decode Sound Unit 1 */ |
794 if (result != 0) | 794 if (result != 0) |
795 return (result); | 795 return (result); |
796 | 796 |
797 /* Framedata of the su2 in the joint-stereo mode is encoded in | 797 /* Framedata of the su2 in the joint-stereo mode is encoded in |
798 * reverse byte order so we need to swap it first. */ | 798 * reverse byte order so we need to swap it first. */ |
799 ptr1 = databuf; | 799 if (databuf == q->decoded_bytes_buffer) { |
800 ptr2 = databuf+q->bytes_per_frame-1; | 800 uint8_t *ptr2 = q->decoded_bytes_buffer+q->bytes_per_frame-1; |
801 ptr1 = q->decoded_bytes_buffer; | |
801 for (i = 0; i < (q->bytes_per_frame/2); i++, ptr1++, ptr2--) { | 802 for (i = 0; i < (q->bytes_per_frame/2); i++, ptr1++, ptr2--) { |
802 FFSWAP(uint8_t,*ptr1,*ptr2); | 803 FFSWAP(uint8_t,*ptr1,*ptr2); |
803 } | 804 } |
805 } else { | |
806 const uint8_t *ptr2 = databuf+q->bytes_per_frame-1; | |
807 for (i = 0; i < q->bytes_per_frame; i++) | |
808 q->decoded_bytes_buffer[i] = *ptr2--; | |
809 } | |
804 | 810 |
805 /* Skip the sync codes (0xF8). */ | 811 /* Skip the sync codes (0xF8). */ |
806 ptr1 = databuf; | 812 ptr1 = q->decoded_bytes_buffer; |
807 for (i = 4; *ptr1 == 0xF8; i++, ptr1++) { | 813 for (i = 4; *ptr1 == 0xF8; i++, ptr1++) { |
808 if (i >= q->bytes_per_frame) | 814 if (i >= q->bytes_per_frame) |
809 return -1; | 815 return -1; |
810 } | 816 } |
811 | 817 |
873 static int atrac3_decode_frame(AVCodecContext *avctx, | 879 static int atrac3_decode_frame(AVCodecContext *avctx, |
874 void *data, int *data_size, | 880 void *data, int *data_size, |
875 const uint8_t *buf, int buf_size) { | 881 const uint8_t *buf, int buf_size) { |
876 ATRAC3Context *q = avctx->priv_data; | 882 ATRAC3Context *q = avctx->priv_data; |
877 int result = 0, i; | 883 int result = 0, i; |
878 uint8_t* databuf; | 884 const uint8_t* databuf; |
879 int16_t* samples = data; | 885 int16_t* samples = data; |
880 | 886 |
881 if (buf_size < avctx->block_align) | 887 if (buf_size < avctx->block_align) |
882 return buf_size; | 888 return buf_size; |
883 | 889 |