#include "audiointerleave.h"
#include "avformat.h"
-#include "avio_internal.h"
#include "id3v2.h"
#include "internal.h"
#include "metadata.h"
(av_get_frame_filename(buf, sizeof(buf), filename, 1) >= 0);
}
-AVInputFormat *av_probe_input_format2(AVProbeData *pd, int is_opened,
- int *score_max)
-{
- AVProbeData lpd = *pd;
- AVInputFormat *fmt1 = NULL, *fmt;
- int score, id3 = 0;
-
- if (lpd.buf_size > 10 && ff_id3v2_match(lpd.buf, ID3v2_DEFAULT_MAGIC)) {
- int id3len = ff_id3v2_tag_len(lpd.buf);
- if (lpd.buf_size > id3len + 16) {
- lpd.buf += id3len;
- lpd.buf_size -= id3len;
- }
- id3 = 1;
- }
-
- fmt = NULL;
- while ((fmt1 = av_iformat_next(fmt1))) {
- if (!is_opened == !(fmt1->flags & AVFMT_NOFILE))
- continue;
- score = 0;
- if (fmt1->read_probe) {
- score = fmt1->read_probe(&lpd);
- } else if (fmt1->extensions) {
- if (av_match_ext(lpd.filename, fmt1->extensions))
- score = AVPROBE_SCORE_EXTENSION;
- }
- if (score > *score_max) {
- *score_max = score;
- fmt = fmt1;
- } else if (score == *score_max)
- fmt = NULL;
- }
-
- // A hack for files with huge id3v2 tags -- try to guess by file extension.
- if (!fmt && is_opened && *score_max < AVPROBE_SCORE_EXTENSION / 2) {
- while ((fmt = av_iformat_next(fmt)))
- if (fmt->extensions &&
- av_match_ext(lpd.filename, fmt->extensions)) {
- *score_max = AVPROBE_SCORE_EXTENSION / 2;
- break;
- }
- }
-
- if (!fmt && id3 && *score_max < AVPROBE_SCORE_EXTENSION / 2 - 1) {
- while ((fmt = av_iformat_next(fmt)))
- if (fmt->extensions && av_match_ext("mp3", fmt->extensions)) {
- *score_max = AVPROBE_SCORE_EXTENSION / 2 - 1;
- break;
- }
- }
-
- return fmt;
-}
-
-AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened)
-{
- int score = 0;
- return av_probe_input_format2(pd, is_opened, &score);
-}
-
static int set_codec_from_probe_data(AVFormatContext *s, AVStream *st,
AVProbeData *pd, int score)
{
{ "dts", AV_CODEC_ID_DTS, AVMEDIA_TYPE_AUDIO },
{ "eac3", AV_CODEC_ID_EAC3, AVMEDIA_TYPE_AUDIO },
{ "h264", AV_CODEC_ID_H264, AVMEDIA_TYPE_VIDEO },
+ { "latm", AV_CODEC_ID_AAC_LATM, AVMEDIA_TYPE_AUDIO },
{ "m4v", AV_CODEC_ID_MPEG4, AVMEDIA_TYPE_VIDEO },
{ "mp3", AV_CODEC_ID_MP3, AVMEDIA_TYPE_AUDIO },
{ "mpegvideo", AV_CODEC_ID_MPEG2VIDEO, AVMEDIA_TYPE_VIDEO },
/************************************************************/
/* input media file */
-/** size of probe buffer, for guessing file type from file contents */
-#define PROBE_BUF_MIN 2048
-#define PROBE_BUF_MAX (1 << 20)
-
-int av_probe_input_buffer(AVIOContext *pb, AVInputFormat **fmt,
- const char *filename, void *logctx,
- unsigned int offset, unsigned int max_probe_size)
-{
- AVProbeData pd = { filename ? filename : "" };
- uint8_t *buf = NULL;
- int ret = 0, probe_size;
-
- if (!max_probe_size)
- max_probe_size = PROBE_BUF_MAX;
- else if (max_probe_size > PROBE_BUF_MAX)
- max_probe_size = PROBE_BUF_MAX;
- else if (max_probe_size < PROBE_BUF_MIN)
- return AVERROR(EINVAL);
-
- if (offset >= max_probe_size)
- return AVERROR(EINVAL);
- avio_skip(pb, offset);
- max_probe_size -= offset;
-
- for (probe_size = PROBE_BUF_MIN; probe_size <= max_probe_size && !*fmt;
- probe_size = FFMIN(probe_size << 1,
- FFMAX(max_probe_size, probe_size + 1))) {
- int score = probe_size < max_probe_size ? AVPROBE_SCORE_MAX / 4 : 0;
-
- /* Read probe data. */
- if ((ret = av_reallocp(&buf, probe_size + AVPROBE_PADDING_SIZE)) < 0)
- return ret;
- if ((ret = avio_read(pb, buf + pd.buf_size,
- probe_size - pd.buf_size)) < 0) {
- /* Fail if error was not end of file, otherwise, lower score. */
- if (ret != AVERROR_EOF) {
- av_free(buf);
- return ret;
- }
- score = 0;
- ret = 0; /* error was end of file, nothing read */
- }
- pd.buf_size += ret;
- pd.buf = buf;
-
- memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);
-
- /* Guess file format. */
- *fmt = av_probe_input_format2(&pd, 1, &score);
- if (*fmt) {
- /* This can only be true in the last iteration. */
- if (score <= AVPROBE_SCORE_MAX / 4) {
- av_log(logctx, AV_LOG_WARNING,
- "Format detected only with low score of %d, "
- "misdetection possible!\n", score);
- } else
- av_log(logctx, AV_LOG_DEBUG,
- "Probed with size=%d and score=%d\n", probe_size, score);
- }
- }
-
- if (!*fmt) {
- av_free(buf);
- return AVERROR_INVALIDDATA;
- }
-
- /* Rewind. Reuse probe buffer to avoid seeking. */
- if ((ret = ffio_rewind_with_probe_data(pb, buf, pd.buf_size)) < 0)
- av_free(buf);
-
- return ret;
-}
-
/* Open input file and probe the format if necessary. */
static int init_input(AVFormatContext *s, const char *filename,
AVDictionary **options)
/**********************************************************/
-/**
- * Get the number of samples of an audio frame. Return -1 on error.
- */
-int ff_get_audio_frame_size(AVCodecContext *enc, int size, int mux)
-{
- int frame_size;
-
- /* give frame_size priority if demuxing */
- if (!mux && enc->frame_size > 1)
- return enc->frame_size;
-
- if ((frame_size = av_get_audio_frame_duration(enc, size)) > 0)
- return frame_size;
-
- /* Fall back on using frame_size if muxing. */
- if (enc->frame_size > 1)
- return enc->frame_size;
-
- return -1;
-}
-
/**
* Return the frame duration in seconds. Return 0 if not available.
*/
-void ff_compute_frame_duration(int *pnum, int *pden, AVStream *st,
+void ff_compute_frame_duration(AVFormatContext *s, int *pnum, int *pden, AVStream *st,
AVCodecParserContext *pc, AVPacket *pkt)
{
+ AVRational codec_framerate = s->iformat ? st->codec->framerate :
+ av_inv_q(st->codec->time_base);
int frame_size;
*pnum = 0;
} else if (st->time_base.num * 1000LL > st->time_base.den) {
*pnum = st->time_base.num;
*pden = st->time_base.den;
- } else if (st->codec->time_base.num * 1000LL > st->codec->time_base.den) {
- *pnum = st->codec->time_base.num;
- *pden = st->codec->time_base.den;
+ } else if (codec_framerate.den * 1000LL > codec_framerate.num) {
+ *pnum = codec_framerate.den;
+ *pden = codec_framerate.num;
if (pc && pc->repeat_pict) {
if (*pnum > INT_MAX / (1 + pc->repeat_pict))
*pden /= 1 + pc->repeat_pict;
}
break;
case AVMEDIA_TYPE_AUDIO:
- frame_size = ff_get_audio_frame_size(st->codec, pkt->size, 0);
+ frame_size = av_get_audio_frame_duration(st->codec, pkt->size);
if (frame_size <= 0 || st->codec->sample_rate <= 0)
break;
*pnum = frame_size;
if (delay == 1 && pkt->dts == pkt->pts &&
pkt->dts != AV_NOPTS_VALUE && presentation_delayed) {
av_log(s, AV_LOG_DEBUG, "invalid dts/pts combination\n");
- pkt->dts = pkt->pts = AV_NOPTS_VALUE;
+ pkt->dts = AV_NOPTS_VALUE;
}
if (pkt->duration == 0 && st->codec->codec_type != AVMEDIA_TYPE_AUDIO) {
- ff_compute_frame_duration(&num, &den, st, pc, pkt);
+ ff_compute_frame_duration(s, &num, &den, st, pc, pkt);
if (den && num) {
pkt->duration = av_rescale_rnd(1, num * (int64_t) st->time_base.den,
den * (int64_t) st->time_base.num,
st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
int duration = pkt->duration;
if (!duration && st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
- ff_compute_frame_duration(&num, &den, st, pc, pkt);
+ ff_compute_frame_duration(s, &num, &den, st, pc, pkt);
if (den && num) {
duration = av_rescale_rnd(1,
num * (int64_t) st->time_base.den,
st->time_base,
AV_ROUND_DOWN);
}
- } else if (st->codec->time_base.num != 0 &&
- st->codec->time_base.den != 0) {
- out_pkt.duration = av_rescale_q_rnd(st->parser->duration,
- st->codec->time_base,
- st->time_base,
- AV_ROUND_DOWN);
}
out_pkt.stream_index = st->index;
static int read_frame_internal(AVFormatContext *s, AVPacket *pkt)
{
int ret = 0, i, got_packet = 0;
+ AVDictionary *metadata = NULL;
av_init_packet(pkt);
if (!got_packet && s->parse_queue)
ret = read_from_packet_buffer(&s->parse_queue, &s->parse_queue_end, pkt);
+ av_opt_get_dict_val(s, "metadata", AV_OPT_SEARCH_CHILDREN, &metadata);
+ if (metadata) {
+ s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED;
+ av_dict_copy(&s->metadata, metadata, 0);
+ av_dict_free(&metadata);
+ av_opt_set_dict_val(s, "metadata", NULL, AV_OPT_SEARCH_CHILDREN);
+ }
+
if (s->debug & FF_FDEBUG_TS)
av_log(s, AV_LOG_DEBUG,
"read_frame_internal stream=%d, pts=%"PRId64", dts=%"PRId64", "
return ((const int[]) { 24, 30, 60, 12, 15 })[i - 60 * 12] * 1000 * 12;
}
-/* Is the time base unreliable?
- * This is a heuristic to balance between quick acceptance of the values in
- * the headers vs. some extra checks.
- * Old DivX and Xvid often have nonsense timebases like 1fps or 2fps.
- * MPEG-2 commonly misuses field repeat flags to store different framerates.
- * And there are "variable" fps files this needs to detect as well. */
-static int tb_unreliable(AVCodecContext *c)
-{
- if (c->time_base.den >= 101L * c->time_base.num ||
- c->time_base.den < 5L * c->time_base.num ||
- // c->codec_tag == AV_RL32("DIVX") ||
- // c->codec_tag == AV_RL32("XVID") ||
- c->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
- c->codec_id == AV_CODEC_ID_H264)
- return 1;
- return 0;
-}
-
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
{
int i, count, ret, read_size, j;
if (ic->fps_probe_size >= 0)
fps_analyze_framecount = ic->fps_probe_size;
/* variable fps and no guess at the real fps */
- if (tb_unreliable(st->codec) && !st->avg_frame_rate.num &&
+ if (!st->avg_frame_rate.num &&
st->codec_info_nb_frames < fps_analyze_framecount &&
st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
break;
!st->codec->extradata)
break;
if (st->first_dts == AV_NOPTS_VALUE &&
+ st->codec_info_nb_frames < ic->max_ts_probe &&
(st->codec->codec_type == AVMEDIA_TYPE_VIDEO ||
st->codec->codec_type == AVMEDIA_TYPE_AUDIO))
break;
AV_TIME_BASE_Q) >= ic->max_analyze_duration) {
av_log(ic, AV_LOG_WARNING, "max_analyze_duration %d reached\n",
ic->max_analyze_duration);
+ if (ic->flags & AVFMT_FLAG_NOBUFFER)
+ av_packet_unref(pkt);
break;
}
}
int i = st->parser->parser->split(st->codec, pkt->data, pkt->size);
if (i > 0 && i < FF_MAX_EXTRADATA_SIZE) {
st->codec->extradata_size = i;
- st->codec->extradata = av_malloc(st->codec->extradata_size +
- FF_INPUT_BUFFER_PADDING_SIZE);
+ st->codec->extradata = av_mallocz(st->codec->extradata_size +
+ FF_INPUT_BUFFER_PADDING_SIZE);
if (!st->codec->extradata)
return AVERROR(ENOMEM);
memcpy(st->codec->extradata, pkt->data,
st->codec->extradata_size);
- memset(st->codec->extradata + i, 0,
- FF_INPUT_BUFFER_PADDING_SIZE);
}
}
try_decode_frame(st, pkt,
(options && i < orig_nb_streams) ? &options[i] : NULL);
+ if (ic->flags & AVFMT_FLAG_NOBUFFER)
+ av_packet_unref(pkt);
+
st->codec_info_nb_frames++;
count++;
}
void avformat_free_context(AVFormatContext *s)
{
- int i;
+ int i, j;
AVStream *st;
+ if (!s)
+ return;
+
av_opt_free(s);
if (s->iformat && s->iformat->priv_class && s->priv_data)
av_opt_free(s->priv_data);
for (i = 0; i < s->nb_streams; i++) {
/* free all data in a stream component */
st = s->streams[i];
+
+ for (j = 0; j < st->nb_side_data; j++)
+ av_freep(&st->side_data[j].data);
+ av_freep(&st->side_data);
+ st->nb_side_data = 0;
+
if (st->parser) {
av_parser_close(st->parser);
}
avio_close(pb);
}
-AVStream *avformat_new_stream(AVFormatContext *s, AVCodec *c)
+AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c)
{
AVStream *st;
int i;
}
st->codec = avcodec_alloc_context3(c);
- if (s->iformat)
+ if (s->iformat) {
/* no default bitrate if decoding */
st->codec->bit_rate = 0;
+
+ /* default pts setting is MPEG-like */
+ avpriv_set_pts_info(st, 33, 1, 90000);
+ }
+
st->index = s->nb_streams;
st->start_time = AV_NOPTS_VALUE;
st->duration = AV_NOPTS_VALUE;
st->first_dts = AV_NOPTS_VALUE;
st->probe_packets = MAX_PROBE_PACKETS;
- /* default pts setting is MPEG-like */
- avpriv_set_pts_info(st, 33, 1, 90000);
st->last_IP_pts = AV_NOPTS_VALUE;
for (i = 0; i < MAX_REORDER_DELAY + 1; i++)
st->pts_buffer[i] = AV_NOPTS_VALUE;
}
}
-static void print_fps(double d, const char *postfix)
-{
- uint64_t v = lrintf(d * 100);
- if (v % 100)
- av_log(NULL, AV_LOG_INFO, ", %3.2f %s", d, postfix);
- else if (v % (100 * 1000))
- av_log(NULL, AV_LOG_INFO, ", %1.0f %s", d, postfix);
- else
- av_log(NULL, AV_LOG_INFO, ", %1.0fk %s", d / 1000, postfix);
-}
-
-static void dump_metadata(void *ctx, AVDictionary *m, const char *indent)
-{
- if (m && !(av_dict_count(m) == 1 && av_dict_get(m, "language", NULL, 0))) {
- AVDictionaryEntry *tag = NULL;
-
- av_log(ctx, AV_LOG_INFO, "%sMetadata:\n", indent);
- while ((tag = av_dict_get(m, "", tag, AV_DICT_IGNORE_SUFFIX)))
- if (strcmp("language", tag->key))
- av_log(ctx, AV_LOG_INFO,
- "%s %-16s: %s\n", indent, tag->key, tag->value);
- }
-}
-
-/* "user interface" functions */
-static void dump_stream_format(AVFormatContext *ic, int i,
- int index, int is_output)
-{
- char buf[256];
- int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);
- AVStream *st = ic->streams[i];
- int g = av_gcd(st->time_base.num, st->time_base.den);
- AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
- avcodec_string(buf, sizeof(buf), st->codec, is_output);
- av_log(NULL, AV_LOG_INFO, " Stream #%d.%d", index, i);
- /* the pid is an important information, so we display it */
- /* XXX: add a generic system */
- if (flags & AVFMT_SHOW_IDS)
- av_log(NULL, AV_LOG_INFO, "[0x%x]", st->id);
- if (lang)
- av_log(NULL, AV_LOG_INFO, "(%s)", lang->value);
- av_log(NULL, AV_LOG_DEBUG, ", %d, %d/%d", st->codec_info_nb_frames,
- st->time_base.num / g, st->time_base.den / g);
- av_log(NULL, AV_LOG_INFO, ": %s", buf);
- if (st->sample_aspect_ratio.num && // default
- av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)) {
- AVRational display_aspect_ratio;
- av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
- st->codec->width * st->sample_aspect_ratio.num,
- st->codec->height * st->sample_aspect_ratio.den,
- 1024 * 1024);
- av_log(NULL, AV_LOG_INFO, ", PAR %d:%d DAR %d:%d",
- st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
- display_aspect_ratio.num, display_aspect_ratio.den);
- }
- if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) {
- if (st->avg_frame_rate.den && st->avg_frame_rate.num)
- print_fps(av_q2d(st->avg_frame_rate), "fps");
- if (st->time_base.den && st->time_base.num)
- print_fps(1 / av_q2d(st->time_base), "tbn");
- if (st->codec->time_base.den && st->codec->time_base.num)
- print_fps(1 / av_q2d(st->codec->time_base), "tbc");
- }
- if (st->disposition & AV_DISPOSITION_DEFAULT)
- av_log(NULL, AV_LOG_INFO, " (default)");
- if (st->disposition & AV_DISPOSITION_DUB)
- av_log(NULL, AV_LOG_INFO, " (dub)");
- if (st->disposition & AV_DISPOSITION_ORIGINAL)
- av_log(NULL, AV_LOG_INFO, " (original)");
- if (st->disposition & AV_DISPOSITION_COMMENT)
- av_log(NULL, AV_LOG_INFO, " (comment)");
- if (st->disposition & AV_DISPOSITION_LYRICS)
- av_log(NULL, AV_LOG_INFO, " (lyrics)");
- if (st->disposition & AV_DISPOSITION_KARAOKE)
- av_log(NULL, AV_LOG_INFO, " (karaoke)");
- if (st->disposition & AV_DISPOSITION_FORCED)
- av_log(NULL, AV_LOG_INFO, " (forced)");
- if (st->disposition & AV_DISPOSITION_HEARING_IMPAIRED)
- av_log(NULL, AV_LOG_INFO, " (hearing impaired)");
- if (st->disposition & AV_DISPOSITION_VISUAL_IMPAIRED)
- av_log(NULL, AV_LOG_INFO, " (visual impaired)");
- if (st->disposition & AV_DISPOSITION_CLEAN_EFFECTS)
- av_log(NULL, AV_LOG_INFO, " (clean effects)");
- av_log(NULL, AV_LOG_INFO, "\n");
- dump_metadata(NULL, st->metadata, " ");
-}
-
-void av_dump_format(AVFormatContext *ic, int index,
- const char *url, int is_output)
-{
- int i;
- uint8_t *printed = ic->nb_streams ? av_mallocz(ic->nb_streams) : NULL;
- if (ic->nb_streams && !printed)
- return;
-
- av_log(NULL, AV_LOG_INFO, "%s #%d, %s, %s '%s':\n",
- is_output ? "Output" : "Input",
- index,
- is_output ? ic->oformat->name : ic->iformat->name,
- is_output ? "to" : "from", url);
- dump_metadata(NULL, ic->metadata, " ");
- if (!is_output) {
- av_log(NULL, AV_LOG_INFO, " Duration: ");
- if (ic->duration != AV_NOPTS_VALUE) {
- int hours, mins, secs, us;
- secs = ic->duration / AV_TIME_BASE;
- us = ic->duration % AV_TIME_BASE;
- mins = secs / 60;
- secs %= 60;
- hours = mins / 60;
- mins %= 60;
- av_log(NULL, AV_LOG_INFO, "%02d:%02d:%02d.%02d", hours, mins, secs,
- (100 * us) / AV_TIME_BASE);
- } else {
- av_log(NULL, AV_LOG_INFO, "N/A");
- }
- if (ic->start_time != AV_NOPTS_VALUE) {
- int secs, us;
- av_log(NULL, AV_LOG_INFO, ", start: ");
- secs = ic->start_time / AV_TIME_BASE;
- us = abs(ic->start_time % AV_TIME_BASE);
- av_log(NULL, AV_LOG_INFO, "%d.%06d",
- secs, (int) av_rescale(us, 1000000, AV_TIME_BASE));
- }
- av_log(NULL, AV_LOG_INFO, ", bitrate: ");
- if (ic->bit_rate)
- av_log(NULL, AV_LOG_INFO, "%d kb/s", ic->bit_rate / 1000);
- else
- av_log(NULL, AV_LOG_INFO, "N/A");
- av_log(NULL, AV_LOG_INFO, "\n");
- }
- for (i = 0; i < ic->nb_chapters; i++) {
- AVChapter *ch = ic->chapters[i];
- av_log(NULL, AV_LOG_INFO, " Chapter #%d.%d: ", index, i);
- av_log(NULL, AV_LOG_INFO,
- "start %f, ", ch->start * av_q2d(ch->time_base));
- av_log(NULL, AV_LOG_INFO,
- "end %f\n", ch->end * av_q2d(ch->time_base));
-
- dump_metadata(NULL, ch->metadata, " ");
- }
- if (ic->nb_programs) {
- int j, k, total = 0;
- for (j = 0; j < ic->nb_programs; j++) {
- AVDictionaryEntry *name = av_dict_get(ic->programs[j]->metadata,
- "name", NULL, 0);
- av_log(NULL, AV_LOG_INFO, " Program %d %s\n", ic->programs[j]->id,
- name ? name->value : "");
- dump_metadata(NULL, ic->programs[j]->metadata, " ");
- for (k = 0; k < ic->programs[j]->nb_stream_indexes; k++) {
- dump_stream_format(ic, ic->programs[j]->stream_index[k],
- index, is_output);
- printed[ic->programs[j]->stream_index[k]] = 1;
- }
- total += ic->programs[j]->nb_stream_indexes;
- }
- if (total < ic->nb_streams)
- av_log(NULL, AV_LOG_INFO, " No Program\n");
- }
- for (i = 0; i < ic->nb_streams; i++)
- if (!printed[i])
- dump_stream_format(ic, i, index, is_output);
-
- av_free(printed);
-}
-
uint64_t ff_ntp_time(void)
{
return (av_gettime() / 1000) * 1000 + NTP_OFFSET_US;
return -1;
}
-#define HEXDUMP_PRINT(...) \
- do { \
- if (!f) \
- av_log(avcl, level, __VA_ARGS__); \
- else \
- fprintf(f, __VA_ARGS__); \
- } while (0)
-
-static void hex_dump_internal(void *avcl, FILE *f, int level,
- const uint8_t *buf, int size)
-{
- int len, i, j, c;
-
- for (i = 0; i < size; i += 16) {
- len = size - i;
- if (len > 16)
- len = 16;
- HEXDUMP_PRINT("%08x ", i);
- for (j = 0; j < 16; j++) {
- if (j < len)
- HEXDUMP_PRINT(" %02x", buf[i + j]);
- else
- HEXDUMP_PRINT(" ");
- }
- HEXDUMP_PRINT(" ");
- for (j = 0; j < len; j++) {
- c = buf[i + j];
- if (c < ' ' || c > '~')
- c = '.';
- HEXDUMP_PRINT("%c", c);
- }
- HEXDUMP_PRINT("\n");
- }
-}
-
-void av_hex_dump(FILE *f, const uint8_t *buf, int size)
-{
- hex_dump_internal(NULL, f, 0, buf, size);
-}
-
-void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size)
-{
- hex_dump_internal(avcl, NULL, level, buf, size);
-}
-
-static void pkt_dump_internal(void *avcl, FILE *f, int level, AVPacket *pkt,
- int dump_payload, AVRational time_base)
-{
- HEXDUMP_PRINT("stream #%d:\n", pkt->stream_index);
- HEXDUMP_PRINT(" keyframe=%d\n", (pkt->flags & AV_PKT_FLAG_KEY) != 0);
- HEXDUMP_PRINT(" duration=%0.3f\n", pkt->duration * av_q2d(time_base));
- /* DTS is _always_ valid after av_read_frame() */
- HEXDUMP_PRINT(" dts=");
- if (pkt->dts == AV_NOPTS_VALUE)
- HEXDUMP_PRINT("N/A");
- else
- HEXDUMP_PRINT("%0.3f", pkt->dts * av_q2d(time_base));
- /* PTS may not be known if B-frames are present. */
- HEXDUMP_PRINT(" pts=");
- if (pkt->pts == AV_NOPTS_VALUE)
- HEXDUMP_PRINT("N/A");
- else
- HEXDUMP_PRINT("%0.3f", pkt->pts * av_q2d(time_base));
- HEXDUMP_PRINT("\n");
- HEXDUMP_PRINT(" size=%d\n", pkt->size);
- if (dump_payload)
- av_hex_dump(f, pkt->data, pkt->size);
-}
-
-void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st)
-{
- pkt_dump_internal(NULL, f, 0, pkt, dump_payload, st->time_base);
-}
-
-void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
- AVStream *st)
-{
- pkt_dump_internal(avcl, NULL, level, pkt, dump_payload, st->time_base);
-}
-
void av_url_split(char *proto, int proto_size,
char *authorization, int authorization_size,
char *hostname, int hostname_size,
#endif
}
-int avformat_query_codec(AVOutputFormat *ofmt, enum AVCodecID codec_id,
+int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id,
int std_compliance)
{
if (ofmt) {
return 0;
}
+
+uint8_t *av_stream_get_side_data(AVStream *st, enum AVPacketSideDataType type,
+ int *size)
+{
+ int i;
+
+ for (i = 0; i < st->nb_side_data; i++) {
+ if (st->side_data[i].type == type) {
+ if (size)
+ *size = st->side_data[i].size;
+ return st->side_data[i].data;
+ }
+ }
+ return NULL;
+}