Mercurial > libavformat.hg
annotate libnut.c @ 1494:f1b6a9a50eec libavformat
Remove wrong/misleading comment.
author | diego |
---|---|
date | Tue, 14 Nov 2006 01:02:30 +0000 |
parents | a3f1e3720b29 |
children | 88c11d433ffb |
rev | line source |
---|---|
1482
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
1 #include "avformat.h" |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
2 #include "riff.h" |
1487
a3f1e3720b29
change include "nut.h" to <nut.h> to make gcc pick the correct nut.h for libnut de/muxer..
ods15
parents:
1482
diff
changeset
|
3 #include <nut.h> |
1482
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
4 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
5 #define ID_STRING "nut/multimedia container" |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
6 #define ID_LENGTH (strlen(ID_STRING) + 1) |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
7 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
8 typedef struct { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
9 nut_context_t * nut; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
10 nut_stream_header_t * s; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
11 } NUTContext; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
12 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
13 static const CodecTag nut_tags[] = { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
14 { CODEC_ID_MPEG4, MKTAG('m', 'p', '4', 's') }, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
15 { CODEC_ID_MP3, MKTAG('m', 'p', '3', ' ') }, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
16 { CODEC_ID_VORBIS, MKTAG('v', 'r', 'b', 's') }, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
17 { 0, 0 }, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
18 }; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
19 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
20 #ifdef CONFIG_MUXERS |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
21 frame_table_input_t ft_default[] = { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
22 // There must be atleast this safety net: |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
23 //{ 4128, 3, 0, 1, 0, 0, 0 }, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
24 //{ flag, fields, pts, mul, stream, size, count } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
25 { 8192, 0, 0, 1, 0, 0, 0 }, // invalid 0x00 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
26 { 56, 0, 0, 1, 0, 0, 0 }, // safety net non key frame |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
27 { 56, 0, 0, 1, 0, 0, 0 }, // safety net key frame |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
28 { 4128, 0, 0, 1, 0, 0, 0 }, // one more safety net |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
29 { 27, 0, 0, 1, 0, 0, 0 }, // EOR frame |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
30 { 1, 4, 1, 337, 1, 336, 0 }, // used 82427 times |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
31 { 1, 4, 1, 385, 1, 384, 0 }, // used 56044 times |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
32 { 0, 4, 2, 7, 0, 6, 0 }, // used 20993 times |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
33 { 0, 4, 1, 7, 0, 6, 0 }, // used 10398 times |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
34 { 1, 4, 1, 481, 1, 480, 0 }, // used 3527 times |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
35 { 1, 4, 1, 289, 1, 288, 0 }, // used 2042 times |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
36 { 1, 4, 1, 577, 1, 576, 0 }, // used 1480 times |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
37 { 1, 4, 1, 673, 1, 672, 0 }, // used 862 times |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
38 { 1, 4, 1, 769, 1, 768, 0 }, // used 433 times |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
39 { 1, 4, 1, 961, 1, 960, 0 }, // used 191 times |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
40 { 32, 3, 2, 101, 0, 0, 0 }, // "1.2.0" => 14187 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
41 { 32, 3, -1, 40, 0, 0, 0 }, // "1.-1.0" => 5707 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
42 { 32, 3, 1, 81, 0, 0, 0 }, // "1.1.0" => 11159 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
43 { 33, 3, 1, 11, 0, 0, 0 }, // "1.1.1" => 1409 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
44 { 105, 3, 0, 6, 0, 0, 0 }, // checksum for video |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
45 { 8192, 2, 0, 1, 0, 0, 0 }, // invalid 0xFF |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
46 { -1, 0, 0, 0, 0, 0, 0 }, // end |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
47 }; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
48 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
49 static int av_write(void * h, size_t len, const uint8_t * buf) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
50 ByteIOContext * bc = h; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
51 put_buffer(bc, buf, len); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
52 //put_flush_packet(bc); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
53 return len; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
54 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
55 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
56 static int nut_write_header(AVFormatContext * avf) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
57 NUTContext * priv = avf->priv_data; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
58 ByteIOContext * bc = &avf->pb; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
59 nut_muxer_opts_t mopts = { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
60 .output = { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
61 .priv = bc, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
62 .write = av_write, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
63 }, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
64 .alloc = { av_malloc, av_realloc, av_free }, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
65 .write_index = 1, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
66 .realtime_stream = 0, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
67 .max_distance = 32768, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
68 .fti = ft_default |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
69 }; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
70 nut_stream_header_t * s; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
71 int i; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
72 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
73 priv->s = s = av_mallocz((avf->nb_streams + 1) * sizeof*s); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
74 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
75 for (i = 0; i < avf->nb_streams; i++) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
76 AVCodecContext * codec = avf->streams[i]->codec; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
77 int j; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
78 int fourcc = 0; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
79 int nom, denom, ssize; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
80 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
81 s[i].type = codec->codec_type == CODEC_TYPE_VIDEO ? NUT_VIDEO_CLASS : NUT_AUDIO_CLASS; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
82 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
83 if (codec->codec_tag) fourcc = codec->codec_tag; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
84 else fourcc = codec_get_tag(nut_tags, codec->codec_id); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
85 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
86 if (!fourcc) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
87 if (codec->codec_type == CODEC_TYPE_VIDEO) fourcc = codec_get_bmp_tag(codec->codec_id); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
88 if (codec->codec_type == CODEC_TYPE_AUDIO) fourcc = codec_get_wav_tag(codec->codec_id); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
89 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
90 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
91 s[i].fourcc_len = 4; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
92 s[i].fourcc = av_malloc(s[i].fourcc_len); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
93 for (j = 0; j < s[i].fourcc_len; j++) s[i].fourcc[j] = (fourcc >> (j*8)) & 0xFF; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
94 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
95 ff_parse_specific_params(codec, &nom, &ssize, &denom); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
96 av_set_pts_info(avf->streams[i], 60, denom, nom); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
97 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
98 s[i].time_base.nom = denom; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
99 s[i].time_base.den = nom; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
100 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
101 s[i].fixed_fps = 0; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
102 s[i].decode_delay = codec->has_b_frames; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
103 s[i].codec_specific_len = codec->extradata_size; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
104 s[i].codec_specific = codec->extradata; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
105 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
106 if (codec->codec_type == CODEC_TYPE_VIDEO) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
107 s[i].width = codec->width; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
108 s[i].height = codec->height; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
109 s[i].sample_width = 0; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
110 s[i].sample_height = 0; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
111 s[i].colorspace_type = 0; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
112 } else { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
113 s[i].samplerate_nom = codec->sample_rate; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
114 s[i].samplerate_denom = 1; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
115 s[i].channel_count = codec->channels; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
116 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
117 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
118 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
119 s[avf->nb_streams].type = -1; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
120 priv->nut = nut_muxer_init(&mopts, s, NULL); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
121 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
122 return 0; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
123 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
124 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
125 static int nut_write_packet(AVFormatContext * avf, AVPacket * pkt) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
126 NUTContext * priv = avf->priv_data; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
127 nut_packet_t p; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
128 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
129 p.len = pkt->size; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
130 p.stream = pkt->stream_index; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
131 p.pts = pkt->pts; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
132 p.flags = pkt->flags & PKT_FLAG_KEY ? NUT_FLAG_KEY : 0; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
133 p.next_pts = 0; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
134 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
135 nut_write_frame_reorder(priv->nut, &p, pkt->data); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
136 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
137 return 0; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
138 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
139 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
140 static int nut_write_trailer(AVFormatContext * avf) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
141 ByteIOContext * bc = &avf->pb; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
142 NUTContext * priv = avf->priv_data; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
143 int i; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
144 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
145 nut_muxer_uninit_reorder(priv->nut); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
146 put_flush_packet(bc); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
147 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
148 for(i = 0; priv->s[i].type != -1; i++ ) av_freep(&priv->s[i].fourcc); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
149 av_freep(&priv->s); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
150 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
151 return 0; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
152 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
153 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
154 AVOutputFormat nut_muxer = { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
155 "nut", |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
156 "nut format", |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
157 "video/x-nut", |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
158 "nut", |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
159 sizeof(NUTContext), |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
160 CODEC_ID_VORBIS, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
161 CODEC_ID_MPEG4, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
162 nut_write_header, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
163 nut_write_packet, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
164 nut_write_trailer, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
165 .flags = AVFMT_GLOBALHEADER, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
166 }; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
167 #endif //CONFIG_MUXERS |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
168 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
169 static int nut_probe(AVProbeData *p) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
170 if (p->buf_size >= ID_LENGTH && !memcmp(p->buf, ID_STRING, ID_LENGTH)) return AVPROBE_SCORE_MAX; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
171 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
172 return 0; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
173 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
174 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
175 static size_t av_read(void * h, size_t len, uint8_t * buf) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
176 ByteIOContext * bc = h; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
177 return get_buffer(bc, buf, len); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
178 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
179 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
180 static off_t av_seek(void * h, long long pos, int whence) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
181 ByteIOContext * bc = h; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
182 if (whence == SEEK_END) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
183 pos = url_fsize(bc) + pos; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
184 whence = SEEK_SET; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
185 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
186 return url_fseek(bc, pos, whence); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
187 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
188 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
189 static int nut_read_header(AVFormatContext * avf, AVFormatParameters * ap) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
190 NUTContext * priv = avf->priv_data; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
191 ByteIOContext * bc = &avf->pb; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
192 nut_demuxer_opts_t dopts = { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
193 .input = { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
194 .priv = bc, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
195 .seek = av_seek, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
196 .read = av_read, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
197 .eof = NULL, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
198 .file_pos = 0, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
199 }, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
200 .alloc = { av_malloc, av_realloc, av_free }, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
201 .read_index = 1 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
202 }; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
203 nut_context_t * nut = priv->nut = nut_demuxer_init(&dopts); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
204 nut_stream_header_t * s; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
205 int ret, i; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
206 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
207 if ((ret = nut_read_headers(nut, &s, NULL))) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
208 if (ret < 0) av_log(avf, AV_LOG_ERROR, " NUT error: %s\n", nut_error(-ret)); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
209 nut_demuxer_uninit(nut); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
210 return -1; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
211 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
212 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
213 priv->s = s; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
214 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
215 for (i = 0; s[i].type != -1 && i < 2; i++) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
216 AVStream * st = av_new_stream(avf, i); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
217 int j; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
218 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
219 for (j = 0; j < s[i].fourcc_len && j < 8; j++) st->codec->codec_tag |= s[i].fourcc[j]<<(j*8); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
220 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
221 st->codec->has_b_frames = s[i].decode_delay; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
222 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
223 st->codec->extradata_size = s[i].codec_specific_len; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
224 if (st->codec->extradata_size) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
225 st->codec->extradata = av_mallocz(st->codec->extradata_size); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
226 memcpy(st->codec->extradata, s[i].codec_specific, st->codec->extradata_size); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
227 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
228 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
229 av_set_pts_info(avf->streams[i], 60, s[i].time_base.nom, s[i].time_base.den); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
230 st->start_time = 0; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
231 st->duration = s[i].max_pts; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
232 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
233 st->codec->codec_id = codec_get_id(nut_tags, st->codec->codec_tag); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
234 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
235 switch(s[i].type) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
236 case NUT_AUDIO_CLASS: |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
237 st->codec->codec_type = CODEC_TYPE_AUDIO; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
238 if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = codec_get_wav_id(st->codec->codec_tag); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
239 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
240 st->codec->channels = s[i].channel_count; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
241 st->codec->sample_rate = s[i].samplerate_nom / s[i].samplerate_denom; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
242 break; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
243 case NUT_VIDEO_CLASS: |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
244 st->codec->codec_type = CODEC_TYPE_VIDEO; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
245 if (st->codec->codec_id == CODEC_ID_NONE) st->codec->codec_id = codec_get_bmp_id(st->codec->codec_tag); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
246 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
247 st->codec->width = s[i].width; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
248 st->codec->height = s[i].height; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
249 st->codec->sample_aspect_ratio.num = s[i].sample_width; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
250 st->codec->sample_aspect_ratio.den = s[i].sample_height; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
251 break; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
252 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
253 if (st->codec->codec_id == CODEC_ID_NONE) av_log(avf, AV_LOG_ERROR, "Unknown codec?!\n"); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
254 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
255 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
256 return 0; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
257 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
258 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
259 static int nut_read_packet(AVFormatContext * avf, AVPacket * pkt) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
260 NUTContext * priv = avf->priv_data; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
261 nut_packet_t pd; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
262 int ret; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
263 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
264 while ((ret = nut_read_next_packet(priv->nut, &pd)) < 0) |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
265 av_log(avf, AV_LOG_ERROR, " NUT error: %s\n", nut_error(-ret)); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
266 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
267 if (ret || av_new_packet(pkt, pd.len) < 0) return -1; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
268 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
269 if (pd.flags & NUT_FLAG_KEY) pkt->flags |= PKT_FLAG_KEY; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
270 pkt->pts = pd.pts; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
271 pkt->stream_index = pd.stream; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
272 pkt->pos = url_ftell(&avf->pb); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
273 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
274 ret = nut_read_frame(priv->nut, &pd.len, pkt->data); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
275 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
276 return ret; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
277 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
278 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
279 static int nut_read_seek(AVFormatContext * avf, int stream_index, int64_t target_ts, int flags) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
280 NUTContext * priv = avf->priv_data; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
281 int active_streams[] = { stream_index, -1 }; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
282 double time_pos = target_ts * priv->s[stream_index].time_base.nom / (double)priv->s[stream_index].time_base.den; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
283 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
284 if (nut_seek(priv->nut, time_pos, 2*!(flags & AVSEEK_FLAG_BACKWARD), active_streams)) return -1; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
285 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
286 return 0; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
287 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
288 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
289 static int nut_read_close(AVFormatContext *s) { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
290 NUTContext * priv = s->priv_data; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
291 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
292 nut_demuxer_uninit(priv->nut); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
293 av_free(priv->s); |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
294 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
295 return 0; |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
296 } |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
297 |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
298 AVInputFormat nut_demuxer = { |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
299 "nut", |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
300 "nut format", |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
301 sizeof(NUTContext), |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
302 nut_probe, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
303 nut_read_header, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
304 nut_read_packet, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
305 nut_read_close, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
306 nut_read_seek, |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
307 .extensions = "nut", |
617beb4c6247
Add libnut support until ffmpeg gets an independant and complete de/muxer for NUT
ods15
parents:
diff
changeset
|
308 }; |