Mercurial > libavformat.hg
annotate crc.c @ 1197:75bfe00a5d30 libavformat
get rid of DECLARED_ALIGNED
| author | bcoudurier |
|---|---|
| date | Sat, 29 Jul 2006 13:13:08 +0000 |
| parents | 3fd51d88c897 |
| children | 0899bfe4105c |
| rev | line source |
|---|---|
| 885 | 1 /* |
| 0 | 2 * CRC decoder (for codec/format testing) |
| 3 * Copyright (c) 2002 Fabrice Bellard. | |
| 4 * | |
| 5 * This library is free software; you can redistribute it and/or | |
| 6 * modify it under the terms of the GNU Lesser General Public | |
| 7 * License as published by the Free Software Foundation; either | |
| 8 * version 2 of the License, or (at your option) any later version. | |
| 9 * | |
| 10 * This library is distributed in the hope that it will be useful, | |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 * Lesser General Public License for more details. | |
| 14 * | |
| 15 * You should have received a copy of the GNU Lesser General Public | |
| 16 * License along with this library; if not, write to the Free Software | |
|
896
edbe5c3717f9
Update licensing information: The FSF changed postal address.
diego
parents:
885
diff
changeset
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 0 | 18 */ |
| 19 #include "avformat.h" | |
| 1176 | 20 #include "adler32.h" |
| 0 | 21 |
| 1169 | 22 #ifdef CONFIG_CRC_MUXER |
| 0 | 23 typedef struct CRCState { |
| 65 | 24 uint32_t crcval; |
| 0 | 25 } CRCState; |
| 26 | |
| 27 static int crc_write_header(struct AVFormatContext *s) | |
| 28 { | |
| 29 CRCState *crc = s->priv_data; | |
| 30 | |
| 31 /* init CRC */ | |
| 1182 | 32 crc->crcval = 1; |
| 0 | 33 |
| 34 return 0; | |
| 35 } | |
| 36 | |
| 468 | 37 static int crc_write_packet(struct AVFormatContext *s, AVPacket *pkt) |
| 0 | 38 { |
| 39 CRCState *crc = s->priv_data; | |
| 1176 | 40 crc->crcval = av_adler32_update(crc->crcval, pkt->data, pkt->size); |
| 0 | 41 return 0; |
| 42 } | |
| 43 | |
| 44 static int crc_write_trailer(struct AVFormatContext *s) | |
| 45 { | |
| 46 CRCState *crc = s->priv_data; | |
| 47 char buf[64]; | |
| 48 | |
| 870 | 49 snprintf(buf, sizeof(buf), "CRC=0x%08x\n", crc->crcval); |
| 50 put_buffer(&s->pb, buf, strlen(buf)); | |
| 51 put_flush_packet(&s->pb); | |
| 52 return 0; | |
| 53 } | |
| 1169 | 54 #endif |
| 870 | 55 |
| 1169 | 56 #ifdef CONFIG_FRAMECRC_MUXER |
| 870 | 57 static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt) |
| 58 { | |
| 1176 | 59 uint32_t crc = av_adler32_update(0, pkt->data, pkt->size); |
| 870 | 60 char buf[256]; |
| 61 | |
| 881 | 62 snprintf(buf, sizeof(buf), "%d, %"PRId64", %d, 0x%08x\n", pkt->stream_index, pkt->dts, pkt->size, crc); |
| 0 | 63 put_buffer(&s->pb, buf, strlen(buf)); |
| 64 put_flush_packet(&s->pb); | |
| 65 return 0; | |
| 66 } | |
| 1169 | 67 #endif |
| 0 | 68 |
| 1169 | 69 #ifdef CONFIG_CRC_MUXER |
| 70 AVOutputFormat crc_muxer = { | |
| 0 | 71 "crc", |
| 72 "crc testing format", | |
| 73 NULL, | |
| 74 "", | |
| 75 sizeof(CRCState), | |
| 76 CODEC_ID_PCM_S16LE, | |
| 77 CODEC_ID_RAWVIDEO, | |
| 78 crc_write_header, | |
| 79 crc_write_packet, | |
| 80 crc_write_trailer, | |
| 81 }; | |
| 1169 | 82 #endif |
| 83 #ifdef CONFIG_FRAMECRC_MUXER | |
| 84 AVOutputFormat framecrc_muxer = { | |
| 870 | 85 "framecrc", |
| 86 "framecrc testing format", | |
| 87 NULL, | |
| 88 "", | |
| 89 0, | |
| 90 CODEC_ID_PCM_S16LE, | |
| 91 CODEC_ID_RAWVIDEO, | |
| 92 NULL, | |
| 93 framecrc_write_packet, | |
| 94 NULL, | |
| 95 }; | |
| 1169 | 96 #endif |
