forward_ptr doesnt contain its own length anymore

Originally committed as revision 4578 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Michael Niedermayer 2005-09-11 08:28:03 +00:00
parent e7902f2095
commit 177e5460b9
2 changed files with 9 additions and 6 deletions

View File

@ -462,8 +462,7 @@ static inline void put_vb_trace(ByteIOContext *bc, uint64_t v, char *file, char
static int put_packetheader(NUTContext *nut, ByteIOContext *bc, int max_size, int calculate_checksum) static int put_packetheader(NUTContext *nut, ByteIOContext *bc, int max_size, int calculate_checksum)
{ {
put_flush_packet(bc); put_flush_packet(bc);
nut->packet_start[2]+= nut->written_packet_size; nut->packet_start[2]= url_ftell(bc) - 8;
assert(url_ftell(bc) - 8 == nut->packet_start[2]);
nut->written_packet_size = max_size; nut->written_packet_size = max_size;
if(calculate_checksum) if(calculate_checksum)
@ -475,10 +474,14 @@ static int put_packetheader(NUTContext *nut, ByteIOContext *bc, int max_size, in
return 0; return 0;
} }
/**
*
* must not be called more then once per packet
*/
static int update_packetheader(NUTContext *nut, ByteIOContext *bc, int additional_size, int calculate_checksum){ static int update_packetheader(NUTContext *nut, ByteIOContext *bc, int additional_size, int calculate_checksum){
int64_t start= nut->packet_start[2]; int64_t start= nut->packet_start[2];
int64_t cur= url_ftell(bc); int64_t cur= url_ftell(bc);
int size= cur - start + additional_size; int size= cur - start - get_length(nut->written_packet_size)/7 - 8;
if(calculate_checksum) if(calculate_checksum)
size += 4; size += 4;
@ -1276,7 +1279,7 @@ static int nut_read_packet(AVFormatContext *s, AVPacket *pkt)
case INDEX_STARTCODE: case INDEX_STARTCODE:
get_packetheader(nut, bc, 0); get_packetheader(nut, bc, 0);
assert(nut->packet_start[2] == pos); assert(nut->packet_start[2] == pos);
url_fseek(bc, nut->written_packet_size + nut->packet_start[2], SEEK_SET); url_fseek(bc, nut->written_packet_size, SEEK_CUR);
break; break;
case INFO_STARTCODE: case INFO_STARTCODE:
if(decode_info_header(nut)<0) if(decode_info_header(nut)<0)
@ -1357,7 +1360,7 @@ av_log(s, AV_LOG_DEBUG, "read_timestamp(X,%d,%lld,%lld)\n", stream_index, *pos_a
case INFO_STARTCODE: case INFO_STARTCODE:
get_packetheader(nut, bc, 0); get_packetheader(nut, bc, 0);
assert(nut->packet_start[2]==pos); assert(nut->packet_start[2]==pos);
url_fseek(bc, nut->written_packet_size + pos, SEEK_SET); url_fseek(bc, nut->written_packet_size, SEEK_CUR);
break; break;
case KEYFRAME_STARTCODE: case KEYFRAME_STARTCODE:
frame_type=2; frame_type=2;

View File

@ -25,7 +25,7 @@ c85c98bb1c9a5fe833eed5d23fbf8499 *./data/b-libav.ffm
55d26d5f682f75fa57a5c126056c4c31 *./data/b-libav.mov 55d26d5f682f75fa57a5c126056c4c31 *./data/b-libav.mov
369865 ./data/b-libav.mov 369865 ./data/b-libav.mov
./data/b-libav.mov CRC=48f5a90d ./data/b-libav.mov CRC=48f5a90d
7c1a4d31acaaeaf172f59367e927f72c *./data/b-libav.nut b66c53a5283f1a28637a617512ba0805 *./data/b-libav.nut
332358 ./data/b-libav.nut 332358 ./data/b-libav.nut
./data/b-libav.nut CRC=ccab3a27 ./data/b-libav.nut CRC=ccab3a27
b466c970d54eb254ad0f954b08535634 *./data/b-libav.dv b466c970d54eb254ad0f954b08535634 *./data/b-libav.dv