* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "avformat.h"
-#include "common.h"
-
-typedef enum {
- PKT_MAP = 0xbc,
- PKT_MEDIA = 0xbf,
- PKT_EOS = 0xfb,
- PKT_FLT = 0xfc,
- PKT_UMF = 0xfd
-} pkt_type_t;
-
-typedef enum {
- MAT_NAME = 0x40,
- MAT_FIRST_FIELD = 0x41,
- MAT_LAST_FIELD = 0x42,
- MAT_MARK_IN = 0x43,
- MAT_MARK_OUT = 0x44,
- MAT_SIZE = 0x45
-} mat_tag_t;
-typedef enum {
- TRACK_NAME = 0x4c,
- TRACK_AUX = 0x4d,
- TRACK_VER = 0x4e,
- TRACK_MPG_AUX = 0x4f,
- TRACK_FPS = 0x50,
- TRACK_LINES = 0x51,
- TRACK_FPF = 0x52
-} track_tag_t;
+#include "libavutil/common.h"
+#include "avformat.h"
+#include "gxf.h"
typedef struct {
int64_t first_field;
return i;
}
st = av_new_stream(s, id);
+ if (!st)
+ return AVERROR(ENOMEM);
switch (format) {
case 3:
case 4:
/**
* \brief filters out interesting tags from material information.
- * \param len lenght of tag section, will be adjusted to contain remaining bytes
+ * \param len length of tag section, will be adjusted to contain remaining bytes
* \param si struct to store collected information into
*/
static void gxf_material_tags(ByteIOContext *pb, int *len, st_info_t *si) {
* \brief read index from FLT packet into stream 0 av_index
*/
static void gxf_read_index(AVFormatContext *s, int pkt_len) {
- ByteIOContext *pb = &s->pb;
+ ByteIOContext *pb = s->pb;
AVStream *st = s->streams[0];
uint32_t fields_per_map = get_le32(pb);
uint32_t map_cnt = get_le32(pb);
}
static int gxf_header(AVFormatContext *s, AVFormatParameters *ap) {
- ByteIOContext *pb = &s->pb;
+ ByteIOContext *pb = s->pb;
pkt_type_t pkt_type;
int map_len;
int len;
int cur_track;
int64_t cur_timestamp = AV_NOPTS_VALUE;
int len;
- ByteIOContext *pb = &s->pb;
+ ByteIOContext *pb = s->pb;
pkt_type_t type;
tmp = get_be32(pb);
start:
}
static int gxf_packet(AVFormatContext *s, AVPacket *pkt) {
- ByteIOContext *pb = &s->pb;
+ ByteIOContext *pb = s->pb;
pkt_type_t pkt_type;
int pkt_len;
while (!url_feof(pb)) {
int track_type, track_id, ret;
int field_nr;
+ int stream_index;
if (!parse_packet_header(pb, &pkt_type, &pkt_len)) {
if (!url_feof(pb))
av_log(s, AV_LOG_ERROR, "GXF: sync lost\n");
pkt_len -= 16;
track_type = get_byte(pb);
track_id = get_byte(pb);
+ stream_index = get_sindex(s, track_id, track_type);
+ if (stream_index < 0)
+ return stream_index;
field_nr = get_be32(pb);
get_be32(pb); // field information
get_be32(pb); // "timeline" field number
// field information, it might be better to take this into account
// as well.
ret = av_get_packet(pb, pkt, pkt_len);
- pkt->stream_index = get_sindex(s, track_id, track_type);
+ pkt->stream_index = stream_index;
pkt->dts = field_nr;
return ret;
}
- return AVERROR_IO;
+ return AVERROR(EIO);
}
static int gxf_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) {
if (idx < st->nb_index_entries - 2)
maxlen = st->index_entries[idx + 2].pos - pos;
maxlen = FFMAX(maxlen, 200 * 1024);
- url_fseek(&s->pb, pos, SEEK_SET);
+ url_fseek(s->pb, pos, SEEK_SET);
found = gxf_resync_media(s, maxlen, -1, timestamp);
if (FFABS(found - timestamp) > 4)
return -1;
static int64_t gxf_read_timestamp(AVFormatContext *s, int stream_index,
int64_t *pos, int64_t pos_limit) {
- ByteIOContext *pb = &s->pb;
+ ByteIOContext *pb = s->pb;
int64_t res;
url_fseek(pb, *pos, SEEK_SET);
res = gxf_resync_media(s, pos_limit - *pos, -1, -1);
AVInputFormat gxf_demuxer = {
"gxf",
- "GXF format",
+ NULL_IF_CONFIG_SMALL("GXF format"),
0,
gxf_probe,
gxf_header,