mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
avio: make get_checksum() internal.
This commit is contained in:
parent
d09cc22d9c
commit
b64030f26d
@ -455,6 +455,7 @@ attribute_deprecated int udp_get_local_port(URLContext *h);
|
||||
attribute_deprecated void init_checksum(AVIOContext *s,
|
||||
unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
|
||||
unsigned long checksum);
|
||||
attribute_deprecated unsigned long get_checksum(AVIOContext *s);
|
||||
#endif
|
||||
|
||||
AVIOContext *avio_alloc_context(
|
||||
@ -675,8 +676,6 @@ int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size);
|
||||
*/
|
||||
int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
|
||||
|
||||
unsigned long get_checksum(AVIOContext *s);
|
||||
|
||||
#if FF_API_UDP_GET_FILE
|
||||
int udp_get_file_handle(URLContext *h);
|
||||
#endif
|
||||
|
@ -77,6 +77,7 @@ int ff_udp_get_local_port(URLContext *h);
|
||||
void ffio_init_checksum(AVIOContext *s,
|
||||
unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
|
||||
unsigned long checksum);
|
||||
unsigned long ffio_get_checksum(AVIOContext *s);
|
||||
unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf,
|
||||
unsigned int len);
|
||||
|
||||
|
@ -412,6 +412,10 @@ void init_checksum(AVIOContext *s,
|
||||
{
|
||||
ffio_init_checksum(s, update_checksum, checksum);
|
||||
}
|
||||
unsigned long get_checksum(AVIOContext *s)
|
||||
{
|
||||
return ffio_get_checksum(s);
|
||||
}
|
||||
#endif
|
||||
|
||||
int avio_put_str(AVIOContext *s, const char *str)
|
||||
@ -554,7 +558,7 @@ unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf,
|
||||
return av_crc(av_crc_get_table(AV_CRC_32_IEEE), checksum, buf, len);
|
||||
}
|
||||
|
||||
unsigned long get_checksum(AVIOContext *s)
|
||||
unsigned long ffio_get_checksum(AVIOContext *s)
|
||||
{
|
||||
s->checksum= s->update_checksum(s->checksum, s->checksum_ptr, s->buf_ptr - s->checksum_ptr);
|
||||
s->update_checksum= NULL;
|
||||
|
@ -108,7 +108,7 @@ static int get_packetheader(NUTContext *nut, AVIOContext *bc, int calculate_chec
|
||||
size= ffio_read_varlen(bc);
|
||||
if(size > 4096)
|
||||
avio_rb32(bc);
|
||||
if(get_checksum(bc) && size > 4096)
|
||||
if(ffio_get_checksum(bc) && size > 4096)
|
||||
return -1;
|
||||
|
||||
ffio_init_checksum(bc, calculate_checksum ? ff_crc04C11DB7_update : NULL, 0);
|
||||
@ -285,7 +285,7 @@ static int decode_main_header(NUTContext *nut){
|
||||
assert(nut->header_len[0]==0);
|
||||
}
|
||||
|
||||
if(skip_reserved(bc, end) || get_checksum(bc)){
|
||||
if(skip_reserved(bc, end) || ffio_get_checksum(bc)){
|
||||
av_log(s, AV_LOG_ERROR, "main header checksum mismatch\n");
|
||||
return AVERROR_INVALIDDATA;
|
||||
}
|
||||
@ -374,7 +374,7 @@ static int decode_stream_header(NUTContext *nut){
|
||||
ffio_read_varlen(bc); // samplerate_den
|
||||
GET_V(st->codec->channels, tmp > 0)
|
||||
}
|
||||
if(skip_reserved(bc, end) || get_checksum(bc)){
|
||||
if(skip_reserved(bc, end) || ffio_get_checksum(bc)){
|
||||
av_log(s, AV_LOG_ERROR, "stream header %d checksum mismatch\n", stream_id);
|
||||
return -1;
|
||||
}
|
||||
@ -469,7 +469,7 @@ static int decode_info_header(NUTContext *nut){
|
||||
}
|
||||
}
|
||||
|
||||
if(skip_reserved(bc, end) || get_checksum(bc)){
|
||||
if(skip_reserved(bc, end) || ffio_get_checksum(bc)){
|
||||
av_log(s, AV_LOG_ERROR, "info header checksum mismatch\n");
|
||||
return -1;
|
||||
}
|
||||
@ -493,7 +493,7 @@ static int decode_syncpoint(NUTContext *nut, int64_t *ts, int64_t *back_ptr){
|
||||
|
||||
ff_nut_reset_ts(nut, nut->time_base[tmp % nut->time_base_count], tmp / nut->time_base_count);
|
||||
|
||||
if(skip_reserved(bc, end) || get_checksum(bc)){
|
||||
if(skip_reserved(bc, end) || ffio_get_checksum(bc)){
|
||||
av_log(s, AV_LOG_ERROR, "sync point checksum mismatch\n");
|
||||
return -1;
|
||||
}
|
||||
@ -590,7 +590,7 @@ static int find_and_decode_index(NUTContext *nut){
|
||||
}
|
||||
}
|
||||
|
||||
if(skip_reserved(bc, end) || get_checksum(bc)){
|
||||
if(skip_reserved(bc, end) || ffio_get_checksum(bc)){
|
||||
av_log(s, AV_LOG_ERROR, "index checksum mismatch\n");
|
||||
goto fail;
|
||||
}
|
||||
|
@ -289,13 +289,13 @@ static void put_packet(NUTContext *nut, AVIOContext *bc, AVIOContext *dyn_bc, in
|
||||
avio_wb64(bc, startcode);
|
||||
ff_put_v(bc, forw_ptr);
|
||||
if(forw_ptr > 4096)
|
||||
avio_wl32(bc, get_checksum(bc));
|
||||
avio_wl32(bc, ffio_get_checksum(bc));
|
||||
|
||||
if(calculate_checksum)
|
||||
ffio_init_checksum(bc, ff_crc04C11DB7_update, 0);
|
||||
avio_write(bc, dyn_buf, dyn_size);
|
||||
if(calculate_checksum)
|
||||
avio_wl32(bc, get_checksum(bc));
|
||||
avio_wl32(bc, ffio_get_checksum(bc));
|
||||
|
||||
av_free(dyn_buf);
|
||||
}
|
||||
@ -818,8 +818,8 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt){
|
||||
if(flags & FLAG_SIZE_MSB) ff_put_v(bc, pkt->size / fc->size_mul);
|
||||
if(flags & FLAG_HEADER_IDX) ff_put_v(bc, header_idx= best_header_idx);
|
||||
|
||||
if(flags & FLAG_CHECKSUM) avio_wl32(bc, get_checksum(bc));
|
||||
else get_checksum(bc);
|
||||
if(flags & FLAG_CHECKSUM) avio_wl32(bc, ffio_get_checksum(bc));
|
||||
else ffio_get_checksum(bc);
|
||||
|
||||
avio_write(bc, pkt->data + nut->header_len[header_idx], pkt->size - nut->header_len[header_idx]);
|
||||
nus->last_flags= flags;
|
||||
|
@ -68,7 +68,7 @@ typedef struct {
|
||||
static void ogg_update_checksum(AVFormatContext *s, AVIOContext *pb, int64_t crc_offset)
|
||||
{
|
||||
int64_t pos = avio_tell(pb);
|
||||
uint32_t checksum = get_checksum(pb);
|
||||
uint32_t checksum = ffio_get_checksum(pb);
|
||||
avio_seek(pb, crc_offset, SEEK_SET);
|
||||
avio_wb32(pb, checksum);
|
||||
avio_seek(pb, pos, SEEK_SET);
|
||||
|
Loading…
Reference in New Issue
Block a user