22#include "config_components.h"
38 const AVFrame *p,
int *got_packet)
41 uint8_t *bytestream, *bytestream_start, *bytestream_end;
42 int i,
h, h1,
c, n, linesize, ret;
53 bytestream =
pkt->data;
54 bytestream_end =
pkt->data +
pkt->size;
61 n = (avctx->
width + 7) >> 3;
100 n = avctx->
width * 2;
107 n = avctx->
width * 4;
110 n = avctx->
width * 2;
116 snprintf(bytestream, bytestream_end - bytestream,
117 "P%c\n%d %d\n",
c, avctx->
width, h1);
118 bytestream += strlen(bytestream);
123 snprintf(bytestream, bytestream_end - bytestream,
126 bytestream += strlen(bytestream);
133 snprintf(bytestream, bytestream_end - bytestream,
135 bytestream += strlen(bytestream);
141 const float *
r = (
const float *)(p->data[2] + p->linesize[2] * (avctx->
height - 1));
142 const float *
g = (
const float *)(p->data[0] + p->linesize[0] * (avctx->
height - 1));
143 const float *
b = (
const float *)(p->data[1] + p->linesize[1] * (avctx->
height - 1));
145 for (
int i = 0;
i < avctx->
height;
i++) {
146 for (
int j = 0; j < avctx->
width; j++) {
153 r -= p->linesize[2] / 4;
154 g -= p->linesize[0] / 4;
155 b -= p->linesize[1] / 4;
160 const float *
g = (
const float *)(p->data[0] + p->linesize[0] * (avctx->
height - 1));
162 for (
int i = 0;
i < avctx->
height;
i++) {
163 for (
int j = 0; j < avctx->
width; j++) {
168 g -= p->linesize[0] / 4;
171 const float *
r = (
const float *)p->data[2];
172 const float *
g = (
const float *)p->data[0];
173 const float *
b = (
const float *)p->data[1];
175 for (
int i = 0;
i < avctx->
height;
i++) {
176 for (
int j = 0; j < avctx->
width; j++) {
183 r += p->linesize[2] / 4;
184 g += p->linesize[0] / 4;
185 b += p->linesize[1] / 4;
188 const float *
g = (
const float *)p->data[0];
190 for (
int i = 0;
i < avctx->
height;
i++) {
191 for (
int j = 0; j < avctx->
width; j++) {
196 g += p->linesize[0] / 4;
199 const uint8_t *ptr = p->data[0];
200 linesize = p->linesize[0];
201 for (
i = 0;
i <
h;
i++) {
202 memcpy(bytestream, ptr, n);
209 const uint8_t *ptr1 = p->data[1], *ptr2 = p->data[2];
212 for (
i = 0;
i <
h;
i++) {
213 memcpy(bytestream, ptr1, n);
215 memcpy(bytestream, ptr2, n);
217 ptr1 += p->linesize[1];
218 ptr2 += p->linesize[2];
227#if CONFIG_PGM_ENCODER
239#if CONFIG_PGMYUV_ENCODER
251#if CONFIG_PPM_ENCODER
263#if CONFIG_PBM_ENCODER
275#if CONFIG_PFM_ENCODER
288#if CONFIG_PHM_ENCODER
305 .
init = phm_enc_init,
const FFCodec ff_ppm_encoder
const FFCodec ff_pgm_encoder
const FFCodec ff_pbm_encoder
const FFCodec ff_pfm_encoder
const FFCodec ff_pgmyuv_encoder
const FFCodec ff_phm_encoder
Libavcodec external API header.
#define i(width, name, range_min, range_max)
#define CODEC_PIXFMTS(...)
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
int(* init)(AVBSFContext *ctx)
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
static uint16_t float2half(uint32_t f, const Float2HalfTables *t)
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align)
Return the size in bytes of the amount of data required to store an image with the given parameters.
static av_always_inline uint32_t av_float2int(float f)
Reinterpret a float as a 32-bit integer.
void ff_init_float2half_tables(Float2HalfTables *t)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GRAYF32
@ AV_PIX_FMT_GRAY16BE
Y , 16bpp, big-endian.
@ AV_PIX_FMT_YUV420P16BE
planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
@ AV_PIX_FMT_GRAYF32LE
IEEE-754 single precision Y, 32bpp, little-endian.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_GBRPF32BE
IEEE-754 single precision planar GBR 4:4:4, 96bpp, big-endian.
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
@ AV_PIX_FMT_RGB48BE
packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big...
@ AV_PIX_FMT_GBRPF32LE
IEEE-754 single precision planar GBR 4:4:4, 96bpp, little-endian.
@ AV_PIX_FMT_GRAYF32BE
IEEE-754 single precision Y, 32bpp, big-endian.
@ AV_PIX_FMT_MONOWHITE
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb.
static int pnm_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *p, int *got_packet)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int depth
Number of bits in the component.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Float2HalfTables f2h_tables