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

Function encode_frame

libavcodec/asvenc.c:293–371  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291}
292
293static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
294 const AVFrame *pict, int *got_packet)
295{
296 ASVEncContext *const a = avctx->priv_data;
297 const ASVCommonContext *const c = &a->c;
298 int size, ret;
299
300 ret = ff_alloc_packet(avctx, pkt, c->mb_height * c->mb_width * MAX_MB_SIZE + 3);
301 if (ret < 0)
302 return ret;
303
304 if (!PIXBLOCKDSP_8BPP_GET_PIXELS_SUPPORTS_UNALIGNED &&
305 ((uintptr_t)pict->data[0] & 7 || pict->linesize[0] & 7 ||
306 (uintptr_t)pict->data[1] & 7 || pict->linesize[1] & 7 ||
307 (uintptr_t)pict->data[2] & 7 || pict->linesize[2] & 7))
308 a->get_pixels = a->pdsp.get_pixels_unaligned;
309 else
310 a->get_pixels = a->pdsp.get_pixels;
311
312 init_put_bits(&a->pb, pkt->data, pkt->size);
313
314 for (int mb_y = 0; mb_y < c->mb_height2; mb_y++) {
315 for (int mb_x = 0; mb_x < c->mb_width2; mb_x++) {
316 dct_get(a, pict, mb_x, mb_y);
317 encode_mb(a, a->block);
318 }
319 }
320
321 if (avctx->width & 15) {
322 const uint8_t *src[3] = {
323 pict->data[0] + c->mb_width2 * 16,
324 pict->data[1] + c->mb_width2 * 8,
325 pict->data[2] + c->mb_width2 * 8,
326 };
327 int available_width = avctx->width & 15;
328
329 for (int mb_y = 0; mb_y < c->mb_height2; mb_y++) {
330 handle_partial_mb(a, src, pict->linesize, available_width, 16);
331 src[0] += 16 * pict->linesize[0];
332 src[1] += 8 * pict->linesize[1];
333 src[2] += 8 * pict->linesize[2];
334 }
335 }
336
337 if (avctx->height & 15) {
338 const uint8_t *src[3] = {
339 pict->data[0] + c->mb_height2 * 16 * pict->linesize[0],
340 pict->data[1] + c->mb_height2 * 8 * pict->linesize[1],
341 pict->data[2] + c->mb_height2 * 8 * pict->linesize[2],
342 };
343 int available_height = avctx->height & 15;
344
345 for (int remaining = avctx->width;; remaining -= 16) {
346 handle_partial_mb(a, src, pict->linesize, remaining, available_height);
347 if (remaining <= 16)
348 break;
349 src[0] += 16;
350 src[1] += 8;

Callers

nothing calls this directly

Calls 9

ff_alloc_packetFunction · 0.85
init_put_bitsFunction · 0.85
dct_getFunction · 0.85
handle_partial_mbFunction · 0.85
flush_put_bitsFunction · 0.85
flush_put_bits_leFunction · 0.85
put_bits_ptrFunction · 0.85
put_bytes_outputFunction · 0.85
encode_mbFunction · 0.70

Tested by

no test coverage detected