Commit bc874dae authored by Michel Bardiaux's avatar Michel Bardiaux Committed by Michael Niedermayer

av_log() patch by (Michel Bardiaux <mbardiaux at peaktime dot be>)

Originally committed as revision 2840 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 81c5f887
......@@ -2352,7 +2352,7 @@ static void opt_output_file(const char *filename)
if (!strcmp(filename, "-"))
filename = "pipe:";
oc = av_mallocz(sizeof(AVFormatContext));
oc = av_alloc_format_context();
if (!file_oformat) {
file_oformat = guess_format(NULL, filename, NULL);
......
......@@ -3124,7 +3124,7 @@ static int rtp_new_av_stream(HTTPContext *c,
int max_packet_size;
/* now we can open the relevant output stream */
ctx = av_mallocz(sizeof(AVFormatContext));
ctx = av_alloc_format_context();
if (!ctx)
return -1;
ctx->oformat = &rtp_mux;
......
......@@ -569,10 +569,27 @@ typedef struct AVFrame {
#define DEFAULT_FRAME_RATE_BASE 1001000
/**
* Used by av_log
*/
typedef struct AVCLASS AVClass;
struct AVCLASS {
const char* class_name;
const char* (*item_name)(void*); /* actually passing a pointer to an AVCodecContext
or AVFormatContext, which begin with an AVClass.
Needed because av_log is in libavcodec and has no visibility
of AVIn/OutputFormat */
};
/**
* main external api structure.
*/
typedef struct AVCodecContext {
/**
* Info on struct for av_log
* - set by avcodec_alloc_context
*/
AVClass class;
/**
* the average bitrate.
* - encoding: set by user. unused for constant quantizer encoding
......@@ -2095,19 +2112,11 @@ void img_copy(AVPicture *dst, const AVPicture *src,
#define AV_LOG_INFO 1
#define AV_LOG_DEBUG 2
extern void av_log(AVCodecContext*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
extern void av_vlog(AVCodecContext*, int level, const char *fmt, va_list);
extern void av_log(void*, int level, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 3, 4)));
extern void av_vlog(void*, int level, const char *fmt, va_list);
extern int av_log_get_level(void);
extern void av_log_set_level(int);
extern void av_log_set_callback(void (*)(AVCodecContext*, int, const char*, va_list));
#undef AV_LOG_TRAP_PRINTF
#ifdef AV_LOG_TRAP_PRINTF
#define printf DO NOT USE
#define fprintf DO NOT USE
#undef stderr
#define stderr DO NOT USE
#endif
extern void av_log_set_callback(void (*)(void*, int, const char*, va_list));
#ifdef __cplusplus
}
......
......@@ -386,11 +386,16 @@ void avcodec_get_context_defaults(AVCodecContext *s){
* allocates a AVCodecContext and set it to defaults.
* this can be deallocated by simply calling free()
*/
static const char* context_to_name(void* class_ptr) { return ((AVCodecContext*) class_ptr)->codec->name; }
static AVClass av_codec_context_class = { "AVCodecContext", context_to_name };
AVCodecContext *avcodec_alloc_context(void){
AVCodecContext *avctx= av_malloc(sizeof(AVCodecContext));
if(avctx==NULL) return NULL;
avctx->class = av_codec_context_class;
avcodec_get_context_defaults(avctx);
return avctx;
......@@ -835,22 +840,24 @@ int64_t av_rescale(int64_t a, int b, int c){
/* av_log API */
#ifdef AV_LOG_TRAP_PRINTF
#undef stderr
#undef fprintf
#endif
static const char* null_to_name(void* class_ptr) { return "NULL"; }
static AVClass av_null_class = { "NULL", null_to_name };
static int av_log_level = AV_LOG_DEBUG;
static void av_log_default_callback(AVCodecContext* avctx, int level, const char* fmt, va_list vl)
static void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
{
static int print_prefix=1;
AVClass* avcl = ptr;
if(!avcl || !avcl->class_name)
avcl = &av_null_class;
if(level>av_log_level)
return;
return;
#undef fprintf
if(avctx && print_prefix)
fprintf(stderr, "[%s @ %p]", avctx->codec ? avctx->codec->name : "?", avctx);
if(print_prefix) {
fprintf(stderr, "[%s:%s @ %p]", avcl->class_name, avcl->item_name(avcl), avcl);
}
#define fprintf please_use_av_log
print_prefix= strstr(fmt, "\n") != NULL;
......@@ -858,19 +865,19 @@ static void av_log_default_callback(AVCodecContext* avctx, int level, const char
vfprintf(stderr, fmt, vl);
}
static void (*av_log_callback)(AVCodecContext*, int, const char*, va_list) = av_log_default_callback;
static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback;
void av_log(AVCodecContext* avctx, int level, const char *fmt, ...)
void av_log(void* avcl, int level, const char *fmt, ...)
{
va_list vl;
va_start(vl, fmt);
av_vlog(avctx, level, fmt, vl);
av_vlog(avcl, level, fmt, vl);
va_end(vl);
}
void av_vlog(AVCodecContext* avctx, int level, const char *fmt, va_list vl)
void av_vlog(void* avcl, int level, const char *fmt, va_list vl)
{
av_log_callback(avctx, level, fmt, vl);
av_log_callback(avcl, level, fmt, vl);
}
int av_log_get_level(void)
......@@ -883,7 +890,7 @@ void av_log_set_level(int level)
av_log_level = level;
}
void av_log_set_callback(void (*callback)(AVCodecContext*, int, const char*, va_list))
void av_log_set_callback(void (*callback)(void*, int, const char*, va_list))
{
av_log_callback = callback;
}
......
......@@ -1070,12 +1070,12 @@ static int asf_get_packet(AVFormatContext *s)
c = get_byte(pb);
if (c != 0x82) {
if (!url_feof(pb))
printf("ff asf bad header %x at:%lld\n", c, url_ftell(pb));
av_log(s, AV_LOG_ERROR, "ff asf bad header %x at:%lld\n", c, url_ftell(pb));
}
if ((c & 0x0f) == 2) { // always true for now
if (get_le16(pb) != 0) {
if (!url_feof(pb))
printf("ff asf bad non zero\n");
av_log(s, AV_LOG_ERROR, "ff asf bad non zero\n");
return -EIO;
}
rsize+=2;
......@@ -1190,7 +1190,7 @@ static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
/* unhandled packet (should not happen) */
url_fskip(pb, asf->packet_frag_size);
asf->packet_size_left -= asf->packet_frag_size;
printf("ff asf skip %d %d\n", asf->packet_frag_size, num & 0x7f);
av_log(s, AV_LOG_ERROR, "ff asf skip %d %d\n", asf->packet_frag_size, num & 0x7f);
continue;
}
asf->asf_st = s->streams[asf->stream_index]->priv_data;
......@@ -1203,7 +1203,7 @@ static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
) {
/* cannot continue current packet: free it */
// FIXME better check if packet was already allocated
printf("ff asf parser skips: %d - %d o:%d - %d %d %d fl:%d\n",
av_log(s, AV_LOG_INFO, "ff asf parser skips: %d - %d o:%d - %d %d %d fl:%d\n",
asf_st->pkt.size,
asf->packet_obj_size,
asf->packet_frag_offset, asf_st->frag_offset,
......@@ -1213,7 +1213,7 @@ static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
asf_st->frag_offset = 0;
if (asf->packet_frag_offset != 0) {
url_fskip(pb, asf->packet_frag_size);
printf("ff asf parser skiping %db\n", asf->packet_frag_size);
av_log(s, AV_LOG_INFO, "ff asf parser skiping %db\n", asf->packet_frag_size);
asf->packet_size_left -= asf->packet_frag_size;
continue;
}
......@@ -1367,7 +1367,7 @@ static int64_t asf_read_pts(AVFormatContext *s, int64_t *ppos, int stream_index)
asf_reset_header(s);
for(;;){
if (av_read_frame(s, pkt) < 0){
printf("seek failed\n");
av_log(s, AV_LOG_INFO, "seek failed\n");
return AV_NOPTS_VALUE;
}
pts= pkt->pts;
......
......@@ -106,7 +106,7 @@ static int audio_open(AudioData *s, int is_output, const char *audio_device)
s->codec_id = CODEC_ID_PCM_S16BE;
break;
default:
fprintf(stderr, "Soundcard does not support 16 bit sample format\n");
av_log(NULL, AV_LOG_ERROR, "Soundcard does not support 16 bit sample format\n");
close(audio_fd);
return -EIO;
}
......
......@@ -241,6 +241,7 @@ typedef struct AVStream {
/* format I/O context */
typedef struct AVFormatContext {
AVClass class; /* set by av_alloc_format_context */
/* can only be iformat or oformat, not both at the same time */
struct AVInputFormat *iformat;
struct AVOutputFormat *oformat;
......@@ -523,6 +524,8 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
AVInputFormat *fmt,
int buf_size,
AVFormatParameters *ap);
/* no av_open for output, so applications will need this: */
AVFormatContext *av_alloc_format_context(void);
#define AVERROR_UNKNOWN (-1) /* unknown error */
#define AVERROR_IO (-2) /* i/o error */
......
......@@ -610,7 +610,7 @@ int dv_assemble_frame(DVMuxContext *c, AVStream* st,
if (st->codec.codec_type == CODEC_TYPE_VIDEO) {
/* FIXME: we have to have more sensible approach than this one */
if (c->has_video)
fprintf(stderr, "Can't process DV frame #%d. Insufficient audio data or severe sync problem.\n", c->frames);
av_log(&st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient audio data or severe sync problem.\n", c->frames);
dv_inject_video(c, data, *frame);
c->has_video = 1;
......@@ -635,7 +635,7 @@ int dv_assemble_frame(DVMuxContext *c, AVStream* st,
/* FIXME: we have to have more sensible approach than this one */
if (fifo_size(&c->audio_data, c->audio_data.rptr) + data_size >= 100*AVCODEC_MAX_AUDIO_FRAME_SIZE)
fprintf(stderr, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames);
av_log(&st->codec, AV_LOG_ERROR, "Can't process DV frame #%d. Insufficient video data or severe sync problem.\n", c->frames);
fifo_write(&c->audio_data, (uint8_t *)data, data_size, &c->audio_data.wptr);
}
......@@ -848,7 +848,7 @@ static int dv_write_header(AVFormatContext *s)
{
s->priv_data = dv_init_mux(s);
if (!s->priv_data) {
fprintf(stderr, "Can't initialize DV format!\n"
av_log(s, AV_LOG_ERROR, "Can't initialize DV format!\n"
"Make sure that you supply exactly two streams:\n"
" video: 25fps or 29.97fps, audio: 2ch/48Khz/PCM\n");
return -1;
......
......@@ -153,7 +153,7 @@ static int dv1394_read_packet(AVFormatContext *context, AVPacket *pkt)
* We have to reset :(.
*/
fprintf(stderr, "DV1394: Ring buffer overflow. Reseting ..\n");
av_log(context, AV_LOG_ERROR, "DV1394: Ring buffer overflow. Reseting ..\n");
dv1394_reset(dv);
dv1394_start(dv);
......@@ -191,7 +191,7 @@ restart_poll:
dv->done = 0;
if (s.dropped_frames) {
fprintf(stderr, "DV1394: Frame drop detected (%d). Reseting ..\n",
av_log(context, AV_LOG_ERROR, "DV1394: Frame drop detected (%d). Reseting ..\n",
s.dropped_frames);
dv1394_reset(dv);
......
......@@ -102,7 +102,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
} else {
skip:
/* skip packet */
printf("skipping flv packet: type %d, size %d, flags %d\n", type, size, flags);
av_log(s, AV_LOG_ERROR, "skipping flv packet: type %d, size %d, flags %d\n", type, size, flags);
url_fskip(&s->pb, size);
goto redo;
}
......
......@@ -99,7 +99,7 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
}
if (!(s->video_cap.type & VID_TYPE_CAPTURE)) {
fprintf(stderr, "Fatal: grab device does not handle capture\n");
av_log(s1, AV_LOG_ERROR, "Fatal: grab device does not handle capture\n");
goto fail;
}
......@@ -223,9 +223,9 @@ static int grab_read_header(AVFormatContext *s1, AVFormatParameters *ap)
if (ret < 0) {
if (errno != EAGAIN) {
fail1:
fprintf(stderr, "Fatal: grab device does not support suitable format\n");
av_log(s1, AV_LOG_ERROR, "Fatal: grab device does not support suitable format\n");
} else {
fprintf(stderr,"Fatal: grab device does not receive any video signal\n");
av_log(s1, AV_LOG_ERROR,"Fatal: grab device does not receive any video signal\n");
}
goto fail;
}
......@@ -277,7 +277,7 @@ static int v4l_mm_read_picture(VideoData *s, uint8_t *buf)
s->gb_buf.frame = (s->gb_frame + 1) % s->gb_buffers.frames;
if (ioctl(s->fd, VIDIOCMCAPTURE, &s->gb_buf) < 0) {
if (errno == EAGAIN)
fprintf(stderr,"Cannot Sync\n");
av_log(NULL, AV_LOG_ERROR, "Cannot Sync\n");
else
perror("VIDIOCMCAPTURE");
return -EIO;
......@@ -387,8 +387,8 @@ static int aiw_init(VideoData *s)
if (height == s->video_cap.maxheight*2) s->deint=1;
if (width == s->video_cap.maxwidth/2) s->halfw=1;
} else {
fprintf(stderr,"\nIncorrect Grab Size Supplied - Supported Sizes Are:\n");
fprintf(stderr," %dx%d %dx%d %dx%d\n\n",
av_log(NULL, AV_LOG_ERROR, "\nIncorrect Grab Size Supplied - Supported Sizes Are:\n");
av_log(NULL, AV_LOG_ERROR, " %dx%d %dx%d %dx%d\n\n",
s->video_cap.maxwidth,s->video_cap.maxheight,
s->video_cap.maxwidth,s->video_cap.maxheight*2,
s->video_cap.maxwidth/2,s->video_cap.maxheight);
......
......@@ -135,7 +135,7 @@ static int roq_read_header(AVFormatContext *s,
break;
default:
printf (" unknown RoQ chunk type (%04X)\n", LE_16(&preamble[0]));
av_log(s, AV_LOG_ERROR, " unknown RoQ chunk type (%04X)\n", LE_16(&preamble[0]));
return AVERROR_INVALIDDATA;
break;
}
......@@ -268,7 +268,7 @@ static int roq_read_packet(AVFormatContext *s,
break;
default:
printf (" unknown RoQ chunk (%04X)\n", chunk_type);
av_log(s, AV_LOG_ERROR, " unknown RoQ chunk (%04X)\n", chunk_type);
return AVERROR_INVALIDDATA;
break;
}
......
......@@ -1531,7 +1531,7 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap)
/* check MOV header */
err = mov_read_default(mov, pb, atom);
if (err<0 || (!mov->found_moov && !mov->found_mdat)) {
fprintf(stderr, "mov: header not found !!! (err:%d, moov:%d, mdat:%d) pos:%lld\n",
av_log(s, AV_LOG_ERROR, "mov: header not found !!! (err:%d, moov:%d, mdat:%d) pos:%lld\n",
err, mov->found_moov, mov->found_mdat, url_ftell(pb));
return -1;
}
......
......@@ -773,7 +773,7 @@ static void compute_pts_dts(AVStream *st, int64_t *ppts, int64_t *pdts,
}
}
#if 1
printf("pts=%0.3f dts=%0.3f pict_type=%c\n",
av_log(&st->codec, AV_LOG_DEBUG, "pts=%0.3f dts=%0.3f pict_type=%c\n",
pts / 90000.0, dts / 90000.0,
av_get_pict_type_char(st->codec.coded_frame->pict_type));
#endif
......
......@@ -456,12 +456,12 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap)
/* main header */
tmp = get_be64(bc);
if (tmp != MAIN_STARTCODE)
fprintf(stderr, "damaged? startcode!=1 (%Ld)\n", tmp);
av_log(s, AV_LOG_ERROR, "damaged? startcode!=1 (%Ld)\n", tmp);
get_packetheader(nut, bc);
tmp = get_v(bc);
if (tmp != 0)
fprintf(stderr, "bad version (%Ld)\n", tmp);
av_log(s, AV_LOG_ERROR, "bad version (%Ld)\n", tmp);
nb_streams = get_v(bc);
get_be32(bc); /* checkusm */
......@@ -481,7 +481,7 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap)
tmp = get_be64(bc);
if (tmp != STREAM_STARTCODE)
fprintf(stderr, "damaged? startcode!=1 (%Ld)\n", tmp);
av_log(s, AV_LOG_ERROR, "damaged? startcode!=1 (%Ld)\n", tmp);
get_packetheader(nut, bc);
st = av_new_stream(s, get_v(bc));
if (!st)
......@@ -494,16 +494,16 @@ static int nut_read_header(AVFormatContext *s, AVFormatParameters *ap)
st->codec.codec_type = CODEC_TYPE_VIDEO;
st->codec.codec_id = codec_get_bmp_id(tmp);
if (st->codec.codec_id == CODEC_ID_NONE)
fprintf(stderr, "Unknown codec?!\n");
av_log(s, AV_LOG_ERROR, "Unknown codec?!\n");
break;
case 32:
st->codec.codec_type = CODEC_TYPE_AUDIO;
st->codec.codec_id = codec_get_wav_id(tmp);
if (st->codec.codec_id == CODEC_ID_NONE)
fprintf(stderr, "Unknown codec?!\n");
av_log(s, AV_LOG_ERROR, "Unknown codec?!\n");
break;
default:
fprintf(stderr, "Unknown stream class (%d)\n", class);
av_log(s, AV_LOG_ERROR, "Unknown stream class (%d)\n", class);
return -1;
}
s->bit_rate += get_v(bc);
......@@ -565,12 +565,12 @@ static int nut_read_packet(AVFormatContext *s, AVPacket *pkt)
tmp = get_byte(bc); /* flags */
}
else
fprintf(stderr, "error in zero bit / startcode %LX\n", tmp);
av_log(s, AV_LOG_ERROR, "error in zero bit / startcode %LX\n", tmp);
}
get_packetheader(nut, bc);
#if 0
if (((tmp & 0x60)>>5) > 3) /* priority <= 3 */
fprintf(stderr, "sanity check failed!\n");
av_log(s, AV_LOG_ERROR, "sanity check failed!\n");
#endif
id = get_v(bc);
if ((tmp & 0x8) >> 3)
......
......@@ -123,11 +123,11 @@ static void dump(unsigned char *buf,size_t len)
{
int i;
for(i=0;i<len;i++) {
if ((i&15)==0) printf("%04x ",i);
printf("%02x ",buf[i]);
if ((i&15)==15) printf("\n");
if ((i&15)==0) av_log(NULL, AV_LOG_DEBUG, "%04x ",i);
av_log(NULL, AV_LOG_DEBUG, "%02x ",buf[i]);
if ((i&15)==15) av_log(NULL, AV_LOG_DEBUG, "\n");
}
printf("\n");
av_log(NULL, AV_LOG_DEBUG, "\n");
}
static int str_read_header(AVFormatContext *s,
......@@ -239,11 +239,11 @@ static int str_read_header(AVFormatContext *s,
}
if (str->video_channel != -1)
printf (" video channel = %d, %d x %d %d\n", str->video_channel,
av_log (s, AV_LOG_DEBUG, " video channel = %d, %d x %d %d\n", str->video_channel,
str->channels[str->video_channel].width,
str->channels[str->video_channel].height,str->channels[str->video_channel].video_stream_index);
if (str->audio_channel != -1)
printf (" audio channel = %d, %d Hz, %d channels, %d bits/sample %d\n",
av_log (s, AV_LOG_DEBUG, " audio channel = %d, %d Hz, %d channels, %d bits/sample %d\n",
str->audio_channel,
str->channels[str->audio_channel].sample_rate,
str->channels[str->audio_channel].channels,
......
......@@ -636,7 +636,7 @@ static int rm_read_header(AVFormatContext *s, AVFormatParameters *ap)
} else {
if (get_le32(pb) != MKTAG('V', 'I', 'D', 'O')) {
fail1:
fprintf(stderr, "Unsupported video codec\n");
av_log(&st->codec, AV_LOG_ERROR, "Unsupported video codec\n");
goto fail;
}
st->codec.codec_tag = get_le32(pb);
......
......@@ -301,7 +301,7 @@ int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,
return -1;
#if defined(DEBUG) || 1
if (seq != ((s->seq + 1) & 0xffff)) {
printf("RTP: PT=%02x: bad cseq %04x expected=%04x\n",
av_log(&s->st->codec, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n",
payload_type, seq, ((s->seq + 1) & 0xffff));
}
s->seq = seq;
......
......@@ -1050,7 +1050,7 @@ static int rtsp_read_play(AVFormatContext *s)
RTSPHeader reply1, *reply = &reply1;
char cmd[1024];
printf("hello state=%d\n", rt->state);
av_log(s, AV_LOG_DEBUG, "hello state=%d\n", rt->state);
if (rt->state == RTSP_STATE_PAUSED) {
snprintf(cmd, sizeof(cmd),
......
......@@ -341,7 +341,7 @@ static int swf_write_header(AVFormatContext *s)
if ( enc->codec_id == CODEC_ID_FLV1 || enc->codec_id == CODEC_ID_MJPEG ) {
video_enc = enc;
} else {
fprintf(stderr, "SWF only supports FLV1 and MJPEG\n");
av_log(enc, AV_LOG_ERROR, "SWF only supports FLV1 and MJPEG\n");
return -1;
}
}
......@@ -479,7 +479,7 @@ static int swf_write_video(AVFormatContext *s,
/* Flash Player limit */
if ( swf->swf_frame_number == 16000 ) {
fprintf(stderr, "warning: Flash Player limit of 16000 frames reached\n");
av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
}
/* Store video data in queue */
......@@ -680,7 +680,7 @@ static int swf_write_audio(AVFormatContext *s,
/* Flash Player limit */
if ( swf->swf_frame_number == 16000 ) {
fprintf(stderr, "warning: Flash Player limit of 16000 frames reached\n");
av_log(enc, AV_LOG_INFO, "warning: Flash Player limit of 16000 frames reached\n");
}
if (enc->codec_id == CODEC_ID_MP3 ) {
......@@ -825,7 +825,7 @@ static int swf_read_header(AVFormatContext *s, AVFormatParameters *ap)
}
break;
}
fprintf(stderr, "No media found in SWF\n");
av_log(s, AV_LOG_ERROR, "No media found in SWF\n");
return -EIO;
}
if ( tag == TAG_VIDEOSTREAM && !vst) {
......
......@@ -300,6 +300,26 @@ AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened)
/**
* open a media file from an IO stream. 'fmt' must be specified.
*/
static const char* format_to_name(void* class_ptr)
{
AVFormatContext* fc = (AVFormatContext*) class_ptr;
if(fc->iformat) return fc->iformat->name;
else if(fc->oformat) return fc->oformat->name;
else return "NULL";
}
static const AVClass av_format_context_class = { "AVFormatContext", format_to_name };
AVFormatContext *av_alloc_format_context(void)
{
AVFormatContext *ic;
ic = av_mallocz(sizeof(AVFormatContext));
if (!ic) return ic;
ic->class = av_format_context_class;
return ic;
}
int av_open_input_stream(AVFormatContext **ic_ptr,
ByteIOContext *pb, const char *filename,
AVInputFormat *fmt, AVFormatParameters *ap)
......@@ -307,7 +327,7 @@ int av_open_input_stream(AVFormatContext **ic_ptr,
int err;
AVFormatContext *ic;
ic = av_mallocz(sizeof(AVFormatContext));
ic = av_alloc_format_context();
if (!ic) {
err = AVERROR_NOMEM;
goto fail;
......@@ -1725,13 +1745,13 @@ void dump_format(AVFormatContext *ic,
int i, flags;
char buf[256];
fprintf(stderr, "%s #%d, %s, %s '%s':\n",
av_log(ic, AV_LOG_DEBUG, "%s #%d, %s, %s '%s':\n",
is_output ? "Output" : "Input",
index,
is_output ? ic->oformat->name : ic->iformat->name,
is_output ? "to" : "from", url);
if (!is_output) {
fprintf(stderr, " Duration: ");
av_log(ic, AV_LOG_DEBUG, " Duration: ");
if (ic->duration != AV_NOPTS_VALUE) {
int hours, mins, secs, us;
secs = ic->duration / AV_TIME_BASE;
......@@ -1740,23 +1760,23 @@ void dump_format(AVFormatContext *ic,
secs %= 60;
hours = mins / 60;
mins %= 60;
fprintf(stderr, "%02d:%02d:%02d.%01d", hours, mins, secs,
av_log(ic, AV_LOG_DEBUG, "%02d:%02d:%02d.%01d", hours, mins, secs,
(10 * us) / AV_TIME_BASE);
} else {
fprintf(stderr, "N/A");
av_log(ic, AV_LOG_DEBUG, "N/A");
}
fprintf(stderr, ", bitrate: ");
av_log(ic, AV_LOG_DEBUG, ", bitrate: ");
if (ic->bit_rate) {
fprintf(stderr,"%d kb/s", ic->bit_rate / 1000);
av_log(ic, AV_LOG_DEBUG,"%d kb/s", ic->bit_rate / 1000);
} else {
fprintf(stderr, "N/A");
av_log(ic, AV_LOG_DEBUG, "N/A");
}
fprintf(stderr, "\n");
av_log(ic, AV_LOG_DEBUG, "\n");
}
for(i=0;i<ic->nb_streams;i++) {
AVStream *st = ic->streams[i];