29 const AVFrame *p,
int *got_packet)
31 uint8_t *bytestream, *bytestream_start, *bytestream_end;
32 int i,
h, h1,
c, n, linesize, ret;
49 n = (avctx->
width + 7) >> 3;
88 snprintf(bytestream, bytestream_end - bytestream,
89 "P%c\n%d %d\n",
c, avctx->
width, h1);
90 bytestream += strlen(bytestream);
92 snprintf(bytestream, bytestream_end - bytestream,
94 bytestream += strlen(bytestream);
98 snprintf(bytestream, bytestream_end - bytestream,
100 bytestream += strlen(bytestream);
104 float *
r = (
float *)p->
data[2];
105 float *
g = (
float *)p->
data[0];
106 float *
b = (
float *)p->
data[1];
109 for (
int j = 0; j < avctx->
width; j++) {
123 for (
i = 0;
i <
h;
i++) {
124 memcpy(bytestream, ptr, n);
135 for (
i = 0;
i <
h;
i++) {
136 memcpy(bytestream, ptr1, n);
138 memcpy(bytestream, ptr2, n);
144 pkt->
size = bytestream - bytestream_start;
153 #if FF_API_CODED_FRAME
163 #if CONFIG_PGM_ENCODER
178 #if CONFIG_PGMYUV_ENCODER
193 #if CONFIG_PPM_ENCODER
208 #if CONFIG_PBM_ENCODER
222 #if CONFIG_PFM_ENCODER
AVCodec ff_pgmyuv_encoder
Libavcodec external API header.
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#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.
@ AV_PICTURE_TYPE_I
Intra.
static av_always_inline uint32_t av_float2int(float f)
Reinterpret a float as a 32-bit integer.
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
#define FF_DISABLE_DEPRECATION_WARNINGS
#define FF_ENABLE_DEPRECATION_WARNINGS
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_GBRPF32
AVPixelFormat
Pixel format.
@ 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_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_MONOWHITE
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb.
static av_cold int pnm_encode_init(AVCodecContext *avctx)
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.
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
const char * name
Name of the codec implementation.
int depth
Number of bits in the component.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int key_frame
1 -> keyframe, 0-> not
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
enum AVPictureType pict_type
Picture type of the frame.
This structure stores compressed data.
int flags
A combination of AV_PKT_FLAG values.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.