Add a context to av_log() calls and modify a function prototype to allow it.

Originally committed as revision 17382 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Benoit Fouet 2009-02-16 16:33:00 +00:00
parent 2a1d51c573
commit 87ad63c0f9
1 changed files with 16 additions and 15 deletions

View File

@ -87,8 +87,9 @@ static void print_tag(const char *str, unsigned int tag, int size)
}
#endif
static int get_riff(AVIContext *avi, ByteIOContext *pb)
static int get_riff(AVFormatContext *s, ByteIOContext *pb)
{
AVIContext *avi = s->priv_data;
char header[8];
int i;
@ -105,7 +106,7 @@ static int get_riff(AVIContext *avi, ByteIOContext *pb)
return -1;
if(header[7] == 0x19)
av_log(NULL, AV_LOG_INFO, "This file has been generated by a totally broken muxer.\n");
av_log(s, AV_LOG_INFO, "This file has been generated by a totally broken muxer.\n");
return 0;
}
@ -247,7 +248,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
avi->stream_index= -1;
if (get_riff(avi, pb) < 0)
if (get_riff(s, avi, pb) < 0)
return -1;
avi->fsize = url_fsize(pb);
@ -407,7 +408,7 @@ static int avi_read_header(AVFormatContext *s, AVFormatParameters *ap)
get_le32(pb); /* quality */
ast->sample_size = get_le32(pb); /* sample ssize */
ast->cum_len *= FFMAX(1, ast->sample_size);
// av_log(NULL, AV_LOG_DEBUG, "%d %d %d %d\n", ast->rate, ast->scale, ast->start, ast->sample_size);
// av_log(s, AV_LOG_DEBUG, "%d %d %d %d\n", ast->rate, ast->scale, ast->start, ast->sample_size);
switch(tag1) {
case MKTAG('v', 'i', 'd', 's'):
@ -659,7 +660,7 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
ts /= ast->sample_size;
ts= av_rescale(ts, AV_TIME_BASE * (int64_t)st->time_base.num, st->time_base.den);
// av_log(NULL, AV_LOG_DEBUG, "%"PRId64" %d/%d %"PRId64"\n", ts, st->time_base.num, st->time_base.den, ast->frame_offset);
// av_log(s, AV_LOG_DEBUG, "%"PRId64" %d/%d %"PRId64"\n", ts, st->time_base.num, st->time_base.den, ast->frame_offset);
if(ts < best_ts && st->nb_index_entries){
best_ts= ts;
best_st= st;
@ -680,12 +681,12 @@ static int avi_read_packet(AVFormatContext *s, AVPacket *pkt)
* FFMAX(1, best_ast->sample_size);
}
// av_log(NULL, AV_LOG_DEBUG, "%d\n", i);
// av_log(s, AV_LOG_DEBUG, "%d\n", i);
if(i>=0){
int64_t pos= best_st->index_entries[i].pos;
pos += best_ast->packet_size - best_ast->remaining;
url_fseek(s->pb, pos + 8, SEEK_SET);
// av_log(NULL, AV_LOG_DEBUG, "pos=%"PRId64"\n", pos);
// av_log(s, AV_LOG_DEBUG, "pos=%"PRId64"\n", pos);
assert(best_ast->remaining <= best_ast->packet_size);
@ -734,7 +735,7 @@ resync:
// pkt->dts += ast->start;
if(ast->sample_size)
pkt->dts /= ast->sample_size;
//av_log(NULL, AV_LOG_DEBUG, "dts:%"PRId64" offset:%"PRId64" %d/%d smpl_siz:%d base:%d st:%d size:%d\n", pkt->dts, ast->frame_offset, ast->scale, ast->rate, ast->sample_size, AV_TIME_BASE, avi->stream_index, size);
//av_log(s, AV_LOG_DEBUG, "dts:%"PRId64" offset:%"PRId64" %d/%d smpl_siz:%d base:%d st:%d size:%d\n", pkt->dts, ast->frame_offset, ast->scale, ast->rate, ast->sample_size, AV_TIME_BASE, avi->stream_index, size);
pkt->stream_index = avi->stream_index;
if (st->codec->codec_type == CODEC_TYPE_VIDEO) {
@ -777,7 +778,7 @@ resync:
size= d[4] + (d[5]<<8) + (d[6]<<16) + (d[7]<<24);
n= get_stream_idx(d+2);
//av_log(NULL, AV_LOG_DEBUG, "%X %X %X %X %X %X %X %X %"PRId64" %d %d\n", d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], i, size, n);
//av_log(s, AV_LOG_DEBUG, "%X %X %X %X %X %X %X %X %"PRId64" %d %d\n", d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7], i, size, n);
if(i + size > avi->fsize || d[0]<0)
continue;
@ -787,7 +788,7 @@ resync:
||(d[0] == 'J' && d[1] == 'U' && d[2] == 'N' && d[3] == 'K')
||(d[0] == 'i' && d[1] == 'd' && d[2] == 'x' && d[3] == '1')){
url_fskip(pb, size);
//av_log(NULL, AV_LOG_DEBUG, "SKIP\n");
//av_log(s, AV_LOG_DEBUG, "SKIP\n");
goto resync;
}
@ -846,7 +847,7 @@ resync:
(d[2] == 'd' && d[3] == 'c') ||
(d[2] == 'w' && d[3] == 'b')*/) {
//av_log(NULL, AV_LOG_DEBUG, "OK\n");
//av_log(s, AV_LOG_DEBUG, "OK\n");
if(d[2]*256+d[3] == ast->prefix)
ast->prefix_count++;
else{
@ -895,7 +896,7 @@ static int avi_read_idx1(AVFormatContext *s, int size)
pos = get_le32(pb);
len = get_le32(pb);
#if defined(DEBUG_SEEK)
av_log(NULL, AV_LOG_DEBUG, "%d: tag=0x%x flags=0x%x pos=0x%x len=%d/",
av_log(s, AV_LOG_DEBUG, "%d: tag=0x%x flags=0x%x pos=0x%x len=%d/",
i, tag, flags, pos, len);
#endif
if(i==0 && pos > avi->movi_list)
@ -910,7 +911,7 @@ static int avi_read_idx1(AVFormatContext *s, int size)
ast = st->priv_data;
#if defined(DEBUG_SEEK)
av_log(NULL, AV_LOG_DEBUG, "%d cum_len=%"PRId64"\n", len, ast->cum_len);
av_log(s, AV_LOG_DEBUG, "%d cum_len=%"PRId64"\n", len, ast->cum_len);
#endif
if(last_pos == pos)
avi->non_interleaved= 1;
@ -1011,7 +1012,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
pos = st->index_entries[index].pos;
timestamp = st->index_entries[index].timestamp;
// av_log(NULL, AV_LOG_DEBUG, "XX %"PRId64" %d %"PRId64"\n", timestamp, index, st->index_entries[index].timestamp);
// av_log(s, AV_LOG_DEBUG, "XX %"PRId64" %d %"PRId64"\n", timestamp, index, st->index_entries[index].timestamp);
if (CONFIG_DV_DEMUXER && avi->dv_demux) {
/* One and only one real stream for DV in AVI, and it has video */
@ -1054,7 +1055,7 @@ static int avi_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp
index++;
}
// av_log(NULL, AV_LOG_DEBUG, "%"PRId64" %d %"PRId64"\n", timestamp, index, st2->index_entries[index].timestamp);
// av_log(s, AV_LOG_DEBUG, "%"PRId64" %d %"PRId64"\n", timestamp, index, st2->index_entries[index].timestamp);
/* extract the current frame number */
ast2->frame_offset = st2->index_entries[index].timestamp;
if(ast2->sample_size)