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

Function flashsv_encode_frame

libavcodec/flashsvenc.c:207–253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205
206
207static int flashsv_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
208 const AVFrame *pict, int *got_packet)
209{
210 FlashSVContext * const s = avctx->priv_data;
211 const uint8_t *prev_frame = s->previous_frame;
212 int res;
213 int I_frame = 0;
214 int opt_w = 4, opt_h = 4;
215
216 /* First frame needs to be a keyframe */
217 if (!s->previous_frame) {
218 prev_frame = pict->data[0];
219 I_frame = 1;
220 }
221
222 /* Check the placement of keyframes */
223 if (avctx->gop_size > 0 &&
224 avctx->frame_num >= s->last_key_frame + avctx->gop_size) {
225 I_frame = 1;
226 }
227
228 res = ff_alloc_packet(avctx, pkt, s->packet_size);
229 if (res < 0)
230 return res;
231
232 pkt->size = encode_bitstream(s, pict, pkt->data, pkt->size,
233 opt_w * 16, opt_h * 16,
234 prev_frame, &I_frame);
235
236 //mark the frame type so the muxer can mux it correctly
237 if (I_frame) {
238 s->last_key_frame = avctx->frame_num;
239 ff_dlog(avctx, "Inserting keyframe at frame %"PRId64"\n", avctx->frame_num);
240 }
241
242 if (I_frame)
243 pkt->flags |= AV_PKT_FLAG_KEY;
244 *got_packet = 1;
245
246 //save the current frame
247 res = av_buffer_replace(&s->prev_frame_buf, pict->buf[0]);
248 if (res < 0)
249 return res;
250 s->previous_frame = pict->data[0];
251
252 return 0;
253}
254
255const FFCodec ff_flashsv_encoder = {
256 .p.name = "flashsv",

Callers

nothing calls this directly

Calls 3

ff_alloc_packetFunction · 0.85
encode_bitstreamFunction · 0.85
av_buffer_replaceFunction · 0.85

Tested by

no test coverage detected