00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "libavcodec/bytestream.h"
00022 #include "avformat.h"
00023 #include "internal.h"
00024 #include "oggdec.h"
00025
00026 static int skeleton_header(AVFormatContext *s, int idx)
00027 {
00028 struct ogg *ogg = s->priv_data;
00029 struct ogg_stream *os = ogg->streams + idx;
00030 AVStream *st = s->streams[idx];
00031 uint8_t *buf = os->buf + os->pstart;
00032 int version_major, version_minor;
00033 int64_t start_num, start_den;
00034 uint64_t start_granule;
00035 int target_idx, start_time;
00036
00037 strcpy(st->codec->codec_name, "skeleton");
00038 st->codec->codec_type = AVMEDIA_TYPE_DATA;
00039
00040 if (os->psize < 8)
00041 return -1;
00042
00043 if (!strncmp(buf, "fishead", 8)) {
00044 if (os->psize < 64)
00045 return -1;
00046
00047 version_major = AV_RL16(buf+8);
00048 version_minor = AV_RL16(buf+10);
00049
00050 if (version_major != 3 && version_major != 4) {
00051 av_log(s, AV_LOG_WARNING, "Unknown skeleton version %d.%d\n",
00052 version_major, version_minor);
00053 return -1;
00054 }
00055
00056
00057
00058
00059
00060
00061 start_num = AV_RL64(buf+12);
00062 start_den = AV_RL64(buf+20);
00063
00064 if (start_den) {
00065 int base_den;
00066 av_reduce(&start_time, &base_den, start_num, start_den, INT_MAX);
00067 avpriv_set_pts_info(st, 64, 1, base_den);
00068 os->lastpts =
00069 st->start_time = start_time;
00070 }
00071 } else if (!strncmp(buf, "fisbone", 8)) {
00072 if (os->psize < 52)
00073 return -1;
00074
00075 target_idx = ogg_find_stream(ogg, AV_RL32(buf+12));
00076 start_granule = AV_RL64(buf+36);
00077 if (os->start_granule != OGG_NOGRANULE_VALUE) {
00078 av_log_missing_feature(s, "multiple fisbone for the "
00079 "same stream\n", 0);
00080 return 1;
00081 }
00082 if (target_idx >= 0 && start_granule != OGG_NOGRANULE_VALUE) {
00083 os->start_granule = start_granule;
00084 }
00085 }
00086
00087 return 1;
00088 }
00089
00090 const struct ogg_codec ff_skeleton_codec = {
00091 .magic = "fishead",
00092 .magicsize = 8,
00093 .header = skeleton_header,
00094 .nb_header = 0,
00095 };