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

Function encode_frame

libavcodec/ffv1enc.c:1710–1849  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1708}
1709
1710static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
1711 const AVFrame *pict, int *got_packet)
1712{
1713 FFV1Context *f = avctx->priv_data;
1714 RangeCoder *const c = &f->slices[0].c;
1715 uint8_t keystate = 128;
1716 uint8_t *buf_p;
1717 int i, ret;
1718 int64_t maxsize;
1719
1720 if(!pict) {
1721 if (avctx->flags & AV_CODEC_FLAG_PASS1) {
1722 int j, k, m;
1723 char *p = avctx->stats_out;
1724 char *end = p + STATS_OUT_SIZE;
1725
1726 memset(f->rc_stat, 0, sizeof(f->rc_stat));
1727 for (i = 0; i < f->quant_table_count; i++)
1728 memset(f->rc_stat2[i], 0, f->context_count[i] * sizeof(*f->rc_stat2[i]));
1729
1730 av_assert0(f->slice_count == f->max_slice_count);
1731 for (j = 0; j < f->slice_count; j++) {
1732 const FFV1SliceContext *sc = &f->slices[j];
1733 for (i = 0; i < 256; i++) {
1734 f->rc_stat[i][0] += sc->rc_stat[i][0];
1735 f->rc_stat[i][1] += sc->rc_stat[i][1];
1736 }
1737 for (i = 0; i < f->quant_table_count; i++) {
1738 for (k = 0; k < f->context_count[i]; k++)
1739 for (m = 0; m < 32; m++) {
1740 f->rc_stat2[i][k][m][0] += sc->rc_stat2[i][k][m][0];
1741 f->rc_stat2[i][k][m][1] += sc->rc_stat2[i][k][m][1];
1742 }
1743 }
1744 }
1745
1746 for (j = 0; j < 256; j++) {
1747 snprintf(p, end - p, "%" PRIu64 " %" PRIu64 " ",
1748 f->rc_stat[j][0], f->rc_stat[j][1]);
1749 p += strlen(p);
1750 }
1751 snprintf(p, end - p, "\n");
1752
1753 for (i = 0; i < f->quant_table_count; i++) {
1754 for (j = 0; j < f->context_count[i]; j++)
1755 for (m = 0; m < 32; m++) {
1756 snprintf(p, end - p, "%" PRIu64 " %" PRIu64 " ",
1757 f->rc_stat2[i][j][m][0], f->rc_stat2[i][j][m][1]);
1758 p += strlen(p);
1759 }
1760 }
1761 snprintf(p, end - p, "%d\n", f->gob_count);
1762 }
1763 return 0;
1764 }
1765
1766 /* Maximum packet size */
1767 maxsize = ff_ffv1_encode_buffer_size(avctx);

Callers

nothing calls this directly

Calls 9

av_logFunction · 0.85
ff_alloc_packetFunction · 0.85
ff_init_range_encoderFunction · 0.85
ff_build_rac_statesFunction · 0.85
put_racFunction · 0.85
av_crcFunction · 0.85
av_crc_get_tableFunction · 0.85
write_headerFunction · 0.70

Tested by

no test coverage detected