Lines 276-287
static int str_read_packet(AVFormatConte
Link Here
|
276 |
int current_sector = AV_RL16(§or[0x1C]); |
276 |
int current_sector = AV_RL16(§or[0x1C]); |
277 |
int sector_count = AV_RL16(§or[0x1E]); |
277 |
int sector_count = AV_RL16(§or[0x1E]); |
278 |
int frame_size = AV_RL32(§or[0x24]); |
278 |
int frame_size = AV_RL32(§or[0x24]); |
279 |
int bytes_to_copy; |
279 |
|
|
|
280 |
if(!( frame_size>=0 |
281 |
&& current_sector < sector_count |
282 |
&& sector_count*VIDEO_DATA_CHUNK_SIZE >=frame_size)){ |
283 |
av_log(s, AV_LOG_ERROR, "Invalid parameters %d %d %d\n", current_sector, sector_count, frame_size); |
284 |
return AVERROR_INVALIDDATA; |
285 |
} |
286 |
|
280 |
// printf("%d %d %d\n",current_sector,sector_count,frame_size); |
287 |
// printf("%d %d %d\n",current_sector,sector_count,frame_size); |
281 |
/* if this is the first sector of the frame, allocate a pkt */ |
288 |
/* if this is the first sector of the frame, allocate a pkt */ |
282 |
pkt = &str->tmp_pkt; |
289 |
pkt = &str->tmp_pkt; |
283 |
if (current_sector == 0) { |
290 |
|
284 |
if (av_new_packet(pkt, frame_size)) |
291 |
if(pkt->size != sector_count*VIDEO_DATA_CHUNK_SIZE){ |
|
|
292 |
if(pkt->data) |
293 |
av_log(s, AV_LOG_ERROR, "missmatching sector_count\n"); |
294 |
av_free_packet(pkt); |
295 |
if (av_new_packet(pkt, sector_count*VIDEO_DATA_CHUNK_SIZE)) |
285 |
return AVERROR(EIO); |
296 |
return AVERROR(EIO); |
286 |
|
297 |
|
287 |
pkt->pos= url_ftell(pb) - RAW_CD_SECTOR_SIZE; |
298 |
pkt->pos= url_ftell(pb) - RAW_CD_SECTOR_SIZE; |
Lines 295-309
static int str_read_packet(AVFormatConte
Link Here
|
295 |
str->pts += (90000 / 15); |
306 |
str->pts += (90000 / 15); |
296 |
} |
307 |
} |
297 |
|
308 |
|
298 |
/* load all the constituent chunks in the video packet */ |
309 |
memcpy(pkt->data + current_sector*VIDEO_DATA_CHUNK_SIZE, |
299 |
bytes_to_copy = frame_size - current_sector*VIDEO_DATA_CHUNK_SIZE; |
310 |
sector + VIDEO_DATA_HEADER_SIZE, |
300 |
if (bytes_to_copy>0) { |
311 |
VIDEO_DATA_CHUNK_SIZE); |
301 |
if (bytes_to_copy>VIDEO_DATA_CHUNK_SIZE) bytes_to_copy=VIDEO_DATA_CHUNK_SIZE; |
312 |
|
302 |
memcpy(pkt->data + current_sector*VIDEO_DATA_CHUNK_SIZE, |
|
|
303 |
sector + VIDEO_DATA_HEADER_SIZE, bytes_to_copy); |
304 |
} |
305 |
if (current_sector == sector_count-1) { |
313 |
if (current_sector == sector_count-1) { |
|
|
314 |
pkt->size= frame_size; |
306 |
*ret_pkt = *pkt; |
315 |
*ret_pkt = *pkt; |
|
|
316 |
pkt->data= NULL; |
317 |
pkt->size= -1; |
307 |
return 0; |
318 |
return 0; |
308 |
} |
319 |
} |
309 |
|
320 |
|