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