MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / build_frame_code

Function build_frame_code

libavformat/nutenc.c:128–241  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128static void build_frame_code(AVFormatContext *s){
129 NUTContext *nut = s->priv_data;
130 int key_frame, index, pred, stream_id;
131 int start=1;
132 int end= 254;
133 int keyframe_0_esc= s->nb_streams > 2;
134 int pred_table[10];
135 FrameCode *ft;
136
137 ft= &nut->frame_code[start];
138 ft->flags= FLAG_CODED;
139 ft->size_mul=1;
140 ft->pts_delta=1;
141 start++;
142
143 if(keyframe_0_esc){
144 /* keyframe = 0 escape */
145 FrameCode *ft= &nut->frame_code[start];
146 ft->flags= FLAG_STREAM_ID | FLAG_SIZE_MSB | FLAG_CODED_PTS;
147 ft->size_mul=1;
148 start++;
149 }
150
151 for(stream_id= 0; stream_id<s->nb_streams; stream_id++){
152 int start2= start + (end-start)*stream_id / s->nb_streams;
153 int end2 = start + (end-start)*(stream_id+1) / s->nb_streams;
154 AVCodecContext *codec = s->streams[stream_id]->codec;
155 int is_audio= codec->codec_type == AVMEDIA_TYPE_AUDIO;
156 int intra_only= /*codec->intra_only || */is_audio;
157 int pred_count;
158
159 for(key_frame=0; key_frame<2; key_frame++){
160 if(intra_only && keyframe_0_esc && key_frame==0)
161 continue;
162
163 {
164 FrameCode *ft= &nut->frame_code[start2];
165 ft->flags= FLAG_KEY*key_frame;
166 ft->flags|= FLAG_SIZE_MSB | FLAG_CODED_PTS;
167 ft->stream_id= stream_id;
168 ft->size_mul=1;
169 if(is_audio)
170 ft->header_idx= find_header_idx(s, codec, -1, key_frame);
171 start2++;
172 }
173 }
174
175 key_frame= intra_only;
176#if 1
177 if(is_audio){
178 int frame_bytes= codec->frame_size*(int64_t)codec->bit_rate / (8*codec->sample_rate);
179 int pts;
180 for(pts=0; pts<2; pts++){
181 for(pred=0; pred<2; pred++){
182 FrameCode *ft= &nut->frame_code[start2];
183 ft->flags= FLAG_KEY*key_frame;
184 ft->stream_id= stream_id;
185 ft->size_mul=frame_bytes + 2;

Callers 1

write_headerFunction · 0.85

Calls 1

find_header_idxFunction · 0.85

Tested by

no test coverage detected