57 int lsf, mpeg25, sample_rate_index, bitrate_index,
frame_size;
59 unsigned int header = 0xFFF00000;
61 lsf = sample_rate < (24000 + 32000) / 2;
62 mpeg25 = sample_rate < (12000 + 16000) / 2;
63 sample_rate <<= lsf + mpeg25;
64 if (sample_rate < (32000 + 44100) / 2) sample_rate_index = 2;
65 else if (sample_rate < (44100 + 48000) / 2) sample_rate_index = 0;
66 else sample_rate_index = 1;
70 for (bitrate_index = 2; bitrate_index < 30; bitrate_index++) {
73 frame_size = (frame_size * 144000) / (sample_rate << lsf) +
76 if (frame_size == size)
80 header |= (!lsf) << 19;
81 header |= (4 - layer) << 17;
86 if (bitrate_index == 30)
89 header |= (bitrate_index >> 1) << 12;
90 header |= sample_rate_index << 10;
91 header |= (bitrate_index & 1) << 9;
122 static const uint8_t headers[][5] = {
123 { 3, 0x00, 0x00, 0x01 },
124 { 4, 0x00, 0x00, 0x01, 0xB6},
134 nut->
header[i] = &headers[i - 1][1];
154 if (keyframe_0_esc) {
162 for (stream_id = 0; stream_id < s->
nb_streams; stream_id++) {
163 int start2 = start + (end - start) * stream_id / s->
nb_streams;
164 int end2 = start + (end - start) * (stream_id + 1) / s->
nb_streams;
177 if (f.
den == 1 && f.
num>0)
183 for (key_frame = 0; key_frame < 2; key_frame++) {
184 if (!
intra_only || !keyframe_0_esc || key_frame != 0) {
199 int frame_bytes = codec->frame_size * (int64_t)codec->bit_rate /
200 (8 * codec->sample_rate);
202 for (pts = 0; pts < 2; pts++) {
203 for (pred = 0; pred < 2; pred++) {
224 if (codec->has_b_frames) {
241 for (pred = 0; pred < pred_count; pred++) {
242 int start3 = start2 + (end2 - start2) * pred / pred_count;
243 int end3 = start2 + (end2 - start2) * (pred + 1) / pred_count;
247 for (index = start3; index < end3; index++) {
278 int len = strlen(
string);
290 static inline void ff_put_v_trace(
AVIOContext *bc, uint64_t v,
const char *file,
298 static inline void put_s_trace(
AVIOContext *bc, int64_t v,
const char *file,
const char *
func,
int line)
304 #define ff_put_v(bc, v) ff_put_v_trace(bc, v, __FILE__, __PRETTY_FUNCTION__, __LINE__)
305 #define put_s(bc, v) put_s_trace(bc, v, __FILE__, __PRETTY_FUNCTION__, __LINE__)
310 int calculate_checksum, uint64_t startcode)
314 int forw_ptr = dyn_size + 4 * calculate_checksum;
323 if (calculate_checksum)
326 if (calculate_checksum)
334 int i, j, tmp_pts, tmp_flags, tmp_stream, tmp_mul, tmp_size, tmp_fields,
351 tmp_match = 1 - (1LL << 62);
353 for (i = 0; i < 256; ) {
372 for (j = 0; i < 256; j++, i++) {
386 if (j != tmp_mul - tmp_size)
391 if (tmp_fields > 0)
put_s(bc, tmp_pts);
392 if (tmp_fields > 1)
ff_put_v(bc, tmp_mul);
393 if (tmp_fields > 2)
ff_put_v(bc, tmp_stream);
394 if (tmp_fields > 3)
ff_put_v(bc, tmp_size);
395 if (tmp_fields > 4)
ff_put_v(bc, 0 );
396 if (tmp_fields > 5)
ff_put_v(bc, j);
397 if (tmp_fields > 6)
ff_put_v(bc, tmp_match);
398 if (tmp_fields > 7)
ff_put_v(bc, tmp_head_idx);
477 int count = 0, dyn_size;
504 int count=0, dyn_size, i;
518 count +=
add_info(dyn_bc,
"r_frame_rate", buf);
543 int ret, dyn_size, count = 0;
570 int64_t payload_size;
578 ff_put_v(bc, (next_node[1]->pos >> 4) - (dummy.
pos>>4));
579 dummy.
pos = next_node[1]->
pos;
593 for (k= j - n; k<=j && k<nut->
sp_count; k++) {
603 payload_size =
avio_tell(bc) - startpos + 8 + 4;
605 avio_wb64(bc, 8 + payload_size +
av_log2(payload_size) / 7 + 1 + 4*(payload_size > 4096));
717 if (INT64_C(1000) * time_base.
num >= time_base.
den)
789 if (pkt->
size > 4096)
809 int best_length, frame_code,
flags, needed_flags, i, header_idx;
817 "Negative pts not supported stream %d, pts %"PRId64
"\n",
848 if (dummy.
pos == INT64_MAX)
882 best_length = INT_MAX;
884 for (i = 0; i < 256; i++) {
887 int flags = fc->
flags;
895 flags = needed_flags;
898 if ((flags & needed_flags) != needed_flags)
901 if ((flags ^ needed_flags) &
FLAG_KEY)
918 if ( (flags & FLAG_CODED)
924 length += 1 - nut->
header_len[best_header_idx];
933 if (length < best_length) {
934 best_length = length;
947 ff_put_v(bc, (flags ^ needed_flags) & ~(FLAG_CODED));
948 flags = needed_flags;
1012 .mime_type =
"video/x-nut",
1013 .extensions =
"nut",