# HG changeset patch # User mbardiaux # Date 1173703001 0 # Node ID b33db97089ba7aeb6b3d75d5889d771c299c1f10 # Parent 330115d147d6fc8a4bafea7d933a305eb13ae7b3 Give context to dprintf diff -r 330115d147d6 -r b33db97089ba mov.c --- a/mov.c Mon Mar 12 10:59:47 2007 +0000 +++ b/mov.c Mon Mar 12 12:36:41 2007 +0000 @@ -232,7 +232,7 @@ } total_size += 8; a.offset += 8; - dprintf("type: %08x %.4s sz: %"PRIx64" %"PRIx64" %"PRIx64"\n", a.type, (char*)&a.type, a.size, atom.size, total_size); + dprintf(c->fc, "type: %08x %.4s sz: %"PRIx64" %"PRIx64" %"PRIx64"\n", a.type, (char*)&a.type, a.size, atom.size, total_size); if (a.size == 1) { /* 64 bit extended size */ a.size = get_be64(pb) - 8; a.offset += 8; @@ -311,8 +311,8 @@ ctype = get_le32(pb); type = get_le32(pb); /* component subtype */ - dprintf("ctype= %c%c%c%c (0x%08lx)\n", *((char *)&ctype), ((char *)&ctype)[1], ((char *)&ctype)[2], ((char *)&ctype)[3], (long) ctype); - dprintf("stype= %c%c%c%c\n", *((char *)&type), ((char *)&type)[1], ((char *)&type)[2], ((char *)&type)[3]); + dprintf(c->fc, "ctype= %c%c%c%c (0x%08lx)\n", *((char *)&ctype), ((char *)&ctype)[1], ((char *)&ctype)[2], ((char *)&ctype)[3], (long) ctype); + dprintf(c->fc, "stype= %c%c%c%c\n", *((char *)&type), ((char *)&type)[1], ((char *)&type)[2], ((char *)&type)[3]); if(!ctype) c->isom = 1; if(type == MKTAG('v', 'i', 'd', 'e')) @@ -349,12 +349,12 @@ return len; } -static int mov_mp4_read_descr(ByteIOContext *pb, int *tag) +static int mov_mp4_read_descr(MOVContext *c, ByteIOContext *pb, int *tag) { int len; *tag = get_byte(pb); len = mov_mp4_read_descr_len(pb); - dprintf("MPEG4 description: tag=0x%02x len=%d\n", *tag, len); + dprintf(c->fc, "MPEG4 description: tag=0x%02x len=%d\n", *tag, len); return len; } @@ -366,14 +366,14 @@ /* Well, broken but suffisant for some MP4 streams */ get_be32(pb); /* version + flags */ - len = mov_mp4_read_descr(pb, &tag); + len = mov_mp4_read_descr(c, pb, &tag); if (tag == MP4ESDescrTag) { get_be16(pb); /* ID */ get_byte(pb); /* priority */ } else get_be16(pb); /* ID */ - len = mov_mp4_read_descr(pb, &tag); + len = mov_mp4_read_descr(c, pb, &tag); if (tag == MP4DecConfigDescrTag) { sc->esds.object_type_id = get_byte(pb); sc->esds.stream_type = get_byte(pb); @@ -382,10 +382,10 @@ sc->esds.avg_bitrate = get_be32(pb); st->codec->codec_id= codec_get_id(ff_mov_obj_type, sc->esds.object_type_id); - dprintf("esds object type id %d\n", sc->esds.object_type_id); - len = mov_mp4_read_descr(pb, &tag); + dprintf(c->fc, "esds object type id %d\n", sc->esds.object_type_id); + len = mov_mp4_read_descr(c, pb, &tag); if (tag == MP4DecSpecificDescrTag) { - dprintf("Specific MPEG4 header len=%d\n", len); + dprintf(c->fc, "Specific MPEG4 header len=%d\n", len); st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE); if (st->codec->extradata) { get_buffer(pb, st->codec->extradata, len); @@ -527,7 +527,7 @@ if (st->codec->extradata) { memcpy(st->codec->extradata, "SVQ3", 4); // fake get_buffer(pb, st->codec->extradata + 0x5a, atom.size); - dprintf("Reading SMI %"PRId64" %s\n", atom.size, st->codec->extradata + 0x5a); + dprintf(c->fc, "Reading SMI %"PRId64" %s\n", atom.size, st->codec->extradata + 0x5a); } else url_fskip(pb, atom.size); @@ -702,7 +702,7 @@ st->codec->codec_type = CODEC_TYPE_VIDEO; } - dprintf("size=%d 4CC= %c%c%c%c codec_type=%d\n", + dprintf(c->fc, "size=%d 4CC= %c%c%c%c codec_type=%d\n", size, (format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff, (format >> 24) & 0xff, st->codec->codec_type); @@ -812,7 +812,7 @@ get_be32(pb); /* vendor */ st->codec->channels = get_be16(pb); /* channel count */ - dprintf("audio channels %d\n", st->codec->channels); + dprintf(c->fc, "audio channels %d\n", st->codec->channels); st->codec->bits_per_sample = get_be16(pb); /* sample size */ /* do we need to force to 16 for AMR ? */ @@ -840,7 +840,7 @@ } //Read QT version 1 fields. In version 0 theese dont exist - dprintf("version =%d, isom =%d\n",version,c->isom); + dprintf(c->fc, "version =%d, isom =%d\n",version,c->isom); if(!c->isom) { if(version==1) { sc->sample_size_v1.den = get_be32(pb); /* samples per packet */ @@ -1063,7 +1063,7 @@ sc->time_rate= ff_gcd(sc->time_rate, sample_duration); - dprintf("sample_count=%d, sample_duration=%d\n",sample_count,sample_duration); + dprintf(c->fc, "sample_count=%d, sample_duration=%d\n",sample_count,sample_duration); duration+=(int64_t)sample_duration*sample_count; total_sample_count+=sample_count; @@ -1090,7 +1090,7 @@ sc->ctts_count = entries; sc->ctts_data = av_malloc(entries * sizeof(Time2Sample)); - dprintf("track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries); + dprintf(c->fc, "track[%i].ctts.entries = %i\n", c->fc->nb_streams-1, entries); for(i=0; ifc->nb_streams-1, c->streams[c->fc->nb_streams-1]->edit_count); + dprintf(c->fc, "track[%i].edit_count = %i\n", c->fc->nb_streams-1, c->streams[c->fc->nb_streams-1]->edit_count); return 0; } @@ -1389,7 +1389,7 @@ stss_index++; } sample_size = sc->sample_size > 0 ? sc->sample_size : sc->sample_sizes[current_sample]; - dprintf("AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", size %d, distance %d, keyframe %d\n", + dprintf(mov->fc, "AVIndex stream %d, sample %d, offset %"PRIx64", dts %"PRId64", size %d, distance %d, keyframe %d\n", st->index, current_sample, current_offset, current_dts, sample_size, distance, keyframe); av_add_index_entry(st, current_offset, current_dts, sample_size, distance, keyframe ? AVINDEX_KEYFRAME : 0); current_offset += sample_size; @@ -1433,7 +1433,7 @@ /* check for last chunk */ if (chunk_size == INT_MAX) for (j = 0; j < mov->mdat_count; j++) { - dprintf("mdat %d, offset %"PRIx64", size %"PRId64", current offset %"PRIx64"\n", + dprintf(mov->fc, "mdat %d, offset %"PRIx64", size %"PRId64", current offset %"PRIx64"\n", j, mov->mdat_list[j].offset, mov->mdat_list[j].size, current_offset); if (mov->mdat_list[j].offset <= current_offset && mov->mdat_list[j].offset + mov->mdat_list[j].size > current_offset) chunk_size = mov->mdat_list[j].offset + mov->mdat_list[j].size - current_offset; @@ -1459,7 +1459,7 @@ } } } - dprintf("AVIndex stream %d, chunk %d, offset %"PRIx64", dts %"PRId64", size %d, duration %d\n", + dprintf(mov->fc, "AVIndex stream %d, chunk %d, offset %"PRIx64", dts %"PRId64", size %d, duration %d\n", st->index, i, current_offset, current_dts, chunk_size, chunk_duration); assert(chunk_duration % sc->time_rate == 0); current_dts += chunk_duration / sc->time_rate; @@ -1492,7 +1492,7 @@ err, mov->found_moov, mov->found_mdat, url_ftell(pb)); return -1; } - dprintf("on_parse_exit_offset=%d\n", (int) url_ftell(pb)); + dprintf(mov->fc, "on_parse_exit_offset=%d\n", (int) url_ftell(pb)); /* some cleanup : make sure we are on the mdat atom */ if(!url_is_streamed(pb) && (url_ftell(pb) != mov->mdat_offset)) @@ -1549,7 +1549,7 @@ AVIndexEntry *current_sample = &s->streams[i]->index_entries[msc->current_sample]; int64_t dts = av_rescale(current_sample->timestamp * (int64_t)msc->time_rate, AV_TIME_BASE, msc->time_scale); - dprintf("stream %d, sample %ld, dts %"PRId64"\n", i, msc->current_sample, dts); + dprintf(s, "stream %d, sample %ld, dts %"PRId64"\n", i, msc->current_sample, dts); if (dts < best_dts) { sample = current_sample; best_dts = dts; @@ -1568,7 +1568,7 @@ #ifdef CONFIG_DV_DEMUXER if (sc->dv_audio_container) { dv_get_packet(mov->dv_demux, pkt); - dprintf("dv audio pkt size %d\n", pkt->size); + dprintf(s, "dv audio pkt size %d\n", pkt->size); } else { #endif url_fseek(&s->pb, sample->pos, SEEK_SET); @@ -1597,7 +1597,7 @@ } pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? PKT_FLAG_KEY : 0; pkt->pos = sample->pos; - dprintf("stream %d, pts %"PRId64", dts %"PRId64", pos 0x%"PRIx64", duration %d\n", pkt->stream_index, pkt->pts, pkt->dts, pkt->pos, pkt->duration); + dprintf(s, "stream %d, pts %"PRId64", dts %"PRId64", pos 0x%"PRIx64", duration %d\n", pkt->stream_index, pkt->pts, pkt->dts, pkt->pos, pkt->duration); return 0; } @@ -1608,11 +1608,11 @@ int i; sample = av_index_search_timestamp(st, timestamp, flags); - dprintf("stream %d, timestamp %"PRId64", sample %d\n", st->index, timestamp, sample); + dprintf(st->codec, "stream %d, timestamp %"PRId64", sample %d\n", st->index, timestamp, sample); if (sample < 0) /* not sure what to do */ return -1; sc->current_sample = sample; - dprintf("stream %d, found sample %ld\n", st->index, sc->current_sample); + dprintf(st->codec, "stream %d, found sample %ld\n", st->index, sc->current_sample); /* adjust ctts index */ if (sc->ctts_data) { time_sample = 0; diff -r 330115d147d6 -r b33db97089ba mxf.c --- a/mxf.c Mon Mar 12 10:59:47 2007 +0000 +++ b/mxf.c Mon Mar 12 12:36:41 2007 +0000 @@ -187,7 +187,7 @@ #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y))) -#define PRINT_KEY(s, x) dprintf("%s %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", s, \ +#define PRINT_KEY(pc, s, x) dprintf(pc, "%s %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", s, \ (x)[0], (x)[1], (x)[2], (x)[3], (x)[4], (x)[5], (x)[6], (x)[7], (x)[8], (x)[9], (x)[10], (x)[11], (x)[12], (x)[13], (x)[14], (x)[15]) static int64_t klv_decode_ber_length(ByteIOContext *pb) @@ -324,7 +324,7 @@ return -1; } #ifdef DEBUG - PRINT_KEY("read packet", klv.key); + PRINT_KEY(s, "read packet", klv.key); #endif if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key)) { int res = mxf_decrypt_triplet(s, pkt, &klv); @@ -500,7 +500,7 @@ do { code = get_byte(pb); - dprintf("pixel layout: code 0x%x\n", code); + dprintf(NULL, "pixel layout: code 0x%x\n", code); switch (code) { case 0x52: /* R */ descriptor->bits_per_sample += get_byte(pb); @@ -668,7 +668,7 @@ MXFPackage *temp_package = NULL; int i, j, k; - dprintf("metadata sets count %d\n", mxf->metadata_sets_count); + dprintf(mxf->fc, "metadata sets count %d\n", mxf->metadata_sets_count); /* TODO: handle multiple material packages (OP3x) */ for (i = 0; i < mxf->packages_count; i++) { material_package = mxf_resolve_strong_ref(mxf, &mxf->packages_refs[i], MaterialPackage); @@ -753,7 +753,7 @@ } #ifdef DEBUG - PRINT_KEY("data definition ul", source_track->sequence->data_definition_ul); + PRINT_KEY(mxf->fc, "data definition ul", source_track->sequence->data_definition_ul); #endif st->codec->codec_type = mxf_get_codec_type(mxf_data_definition_uls, &source_track->sequence->data_definition_ul); @@ -780,8 +780,8 @@ continue; } #ifdef DEBUG - PRINT_KEY("essence codec ul", descriptor->essence_codec_ul); - PRINT_KEY("essence container ul", descriptor->essence_container_ul); + PRINT_KEY(mxf->fc, "essence codec ul", descriptor->essence_codec_ul); + PRINT_KEY(mxf->fc, "essence container ul", descriptor->essence_container_ul); #endif essence_container_ul = &descriptor->essence_container_ul; /* HACK: replacing the original key with mxf_encrypted_essence_container @@ -836,7 +836,7 @@ } } if (container_ul && container_ul->wrapping == Clip) { - dprintf("stream %d: clip wrapped essence\n", st->index); + dprintf(mxf->fc, "stream %d: clip wrapped essence\n", st->index); st->need_parsing = 1; } } @@ -921,7 +921,7 @@ return -1; } #ifdef DEBUG - PRINT_KEY("read header", klv.key); + PRINT_KEY(s, "read header", klv.key); #endif if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key) || IS_KLV_KEY(klv.key, mxf_essence_element_key)) {