annotate ffmpeg/libavformat/nut.h @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents f445c3017523
children
rev   line source
yading@11 1 /*
yading@11 2 * "NUT" Container Format (de)muxer
yading@11 3 * Copyright (c) 2006 Michael Niedermayer
yading@11 4 *
yading@11 5 * This file is part of FFmpeg.
yading@11 6 *
yading@11 7 * FFmpeg is free software; you can redistribute it and/or
yading@11 8 * modify it under the terms of the GNU Lesser General Public
yading@11 9 * License as published by the Free Software Foundation; either
yading@11 10 * version 2.1 of the License, or (at your option) any later version.
yading@11 11 *
yading@11 12 * FFmpeg is distributed in the hope that it will be useful,
yading@11 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@11 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@11 15 * Lesser General Public License for more details.
yading@11 16 *
yading@11 17 * You should have received a copy of the GNU Lesser General Public
yading@11 18 * License along with FFmpeg; if not, write to the Free Software
yading@11 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@11 20 */
yading@11 21
yading@11 22 #ifndef AVFORMAT_NUT_H
yading@11 23 #define AVFORMAT_NUT_H
yading@11 24
yading@11 25 //#include <limits.h>
yading@11 26 //#include "libavutil/adler32.h"
yading@11 27 //#include "libavcodec/mpegaudio.h"
yading@11 28 #include "avformat.h"
yading@11 29 #include "internal.h"
yading@11 30 #include "metadata.h"
yading@11 31
yading@11 32 #define MAIN_STARTCODE (0x7A561F5F04ADULL + (((uint64_t)('N'<<8) + 'M')<<48))
yading@11 33 #define STREAM_STARTCODE (0x11405BF2F9DBULL + (((uint64_t)('N'<<8) + 'S')<<48))
yading@11 34 #define SYNCPOINT_STARTCODE (0xE4ADEECA4569ULL + (((uint64_t)('N'<<8) + 'K')<<48))
yading@11 35 #define INDEX_STARTCODE (0xDD672F23E64EULL + (((uint64_t)('N'<<8) + 'X')<<48))
yading@11 36 #define INFO_STARTCODE (0xAB68B596BA78ULL + (((uint64_t)('N'<<8) + 'I')<<48))
yading@11 37
yading@11 38 #define ID_STRING "nut/multimedia container\0"
yading@11 39
yading@11 40 #define MAX_DISTANCE (1024*32-1)
yading@11 41
yading@11 42 typedef enum{
yading@11 43 FLAG_KEY = 1, ///<if set, frame is keyframe
yading@11 44 FLAG_EOR = 2, ///<if set, stream has no relevance on presentation. (EOR)
yading@11 45 FLAG_CODED_PTS = 8, ///<if set, coded_pts is in the frame header
yading@11 46 FLAG_STREAM_ID = 16, ///<if set, stream_id is coded in the frame header
yading@11 47 FLAG_SIZE_MSB = 32, ///<if set, data_size_msb is at frame header, otherwise data_size_msb is 0
yading@11 48 FLAG_CHECKSUM = 64, ///<if set, the frame header contains a checksum
yading@11 49 FLAG_RESERVED = 128, ///<if set, reserved_count is coded in the frame header
yading@11 50 FLAG_HEADER_IDX =1024, ///<If set, header_idx is coded in the frame header.
yading@11 51 FLAG_MATCH_TIME =2048, ///<If set, match_time_delta is coded in the frame header
yading@11 52 FLAG_CODED =4096, ///<if set, coded_flags are stored in the frame header
yading@11 53 FLAG_INVALID =8192, ///<if set, frame_code is invalid
yading@11 54 } Flag;
yading@11 55
yading@11 56 typedef struct Syncpoint {
yading@11 57 uint64_t pos;
yading@11 58 uint64_t back_ptr;
yading@11 59 // uint64_t global_key_pts;
yading@11 60 int64_t ts;
yading@11 61 } Syncpoint;
yading@11 62
yading@11 63 typedef struct FrameCode {
yading@11 64 uint16_t flags;
yading@11 65 uint8_t stream_id;
yading@11 66 uint16_t size_mul;
yading@11 67 uint16_t size_lsb;
yading@11 68 int16_t pts_delta;
yading@11 69 uint8_t reserved_count;
yading@11 70 uint8_t header_idx;
yading@11 71 } FrameCode;
yading@11 72
yading@11 73 typedef struct StreamContext {
yading@11 74 int last_flags;
yading@11 75 int skip_until_key_frame;
yading@11 76 int64_t last_pts;
yading@11 77 int time_base_id;
yading@11 78 AVRational *time_base;
yading@11 79 int msb_pts_shift;
yading@11 80 int max_pts_distance;
yading@11 81 int decode_delay; //FIXME duplicate of has_b_frames
yading@11 82 int64_t *keyframe_pts;
yading@11 83 } StreamContext;
yading@11 84
yading@11 85 typedef struct ChapterContext {
yading@11 86 AVRational *time_base;
yading@11 87 } ChapterContext;
yading@11 88
yading@11 89 typedef struct NUTContext {
yading@11 90 AVFormatContext *avf;
yading@11 91 // int written_packet_size;
yading@11 92 // int64_t packet_start;
yading@11 93 FrameCode frame_code[256];
yading@11 94 uint8_t header_len[128];
yading@11 95 const uint8_t *header[128];
yading@11 96 uint64_t next_startcode; ///< stores the next startcode if it has already been parsed but the stream is not seekable
yading@11 97 StreamContext *stream;
yading@11 98 ChapterContext *chapter;
yading@11 99 unsigned int max_distance;
yading@11 100 unsigned int time_base_count;
yading@11 101 int64_t last_syncpoint_pos;
yading@11 102 int header_count;
yading@11 103 AVRational *time_base;
yading@11 104 struct AVTreeNode *syncpoints;
yading@11 105 int sp_count;
yading@11 106 int64_t max_pts;
yading@11 107 AVRational *max_pts_tb;
yading@11 108 } NUTContext;
yading@11 109
yading@11 110 extern const AVCodecTag ff_nut_subtitle_tags[];
yading@11 111 extern const AVCodecTag ff_nut_video_tags[];
yading@11 112 extern const AVCodecTag ff_nut_audio_tags[];
yading@11 113 extern const AVCodecTag ff_nut_data_tags[];
yading@11 114
yading@11 115 extern const AVCodecTag * const ff_nut_codec_tags[];
yading@11 116
yading@11 117 typedef struct Dispositions {
yading@11 118 char str[9];
yading@11 119 int flag;
yading@11 120 } Dispositions;
yading@11 121
yading@11 122 void ff_nut_reset_ts(NUTContext *nut, AVRational time_base, int64_t val);
yading@11 123 int64_t ff_lsb2full(StreamContext *stream, int64_t lsb);
yading@11 124 int ff_nut_sp_pos_cmp(const Syncpoint *a, const Syncpoint *b);
yading@11 125 int ff_nut_sp_pts_cmp(const Syncpoint *a, const Syncpoint *b);
yading@11 126 void ff_nut_add_sp(NUTContext *nut, int64_t pos, int64_t back_ptr, int64_t ts);
yading@11 127 void ff_nut_free_sp(NUTContext *nut);
yading@11 128
yading@11 129 extern const Dispositions ff_nut_dispositions[];
yading@11 130
yading@11 131 extern const AVMetadataConv ff_nut_metadata_conv[];
yading@11 132
yading@11 133 #endif /* AVFORMAT_NUT_H */