Go to the documentation of this file.
22 #include "config_components.h"
39 for (
i=0;
i<n/2;
i++) {
48 const uint8_t *buf = avpkt->
data;
49 int buf_size = avpkt->
size;
51 int i, j, k, n, linesize,
h, upgrade = 0, is_mono = 0;
53 int components, sample_len,
ret;
58 s->bytestream_end = buf + buf_size;
77 if (
s->maxval < 65535)
84 if (
s->maxval < 65535)
107 n = avctx->
width * 2;
112 n = avctx->
width * 2;
115 if (
s->maxval < 65535)
119 n = avctx->
width * 4;
122 if (
s->maxval < 65535)
127 n = (avctx->
width + 7) >> 3;
134 if (n * avctx->
height >
s->bytestream_end -
s->bytestream)
136 if(
s->type < 4 || (is_mono &&
s->type==7)){
140 for(j=0; j<avctx->
width * components; j++){
144 while(
s->bytestream <
s->bytestream_end && (*
s->bytestream <
'0' || *
s->bytestream >
'9' ))
146 if(
s->bytestream >=
s->bytestream_end)
150 v = (*
s->bytestream++)&1;
153 for (k = 0; k < 6 &&
c <= 9; k += 1) {
155 c = (*
s->bytestream++) -
'0';
162 if (sample_len == 16) {
163 ((uint16_t*)ptr)[j] = (((1<<sample_len)-1)*v + (
s->maxval>>1))/
s->maxval;
165 put_bits(&pb, sample_len, (((1<<sample_len)-1)*v + (
s->maxval>>1))/
s->maxval);
167 if (sample_len != 16)
172 for (
int i = 0;
i < avctx->
height;
i++) {
175 else if (upgrade == 1) {
176 unsigned int f = (255 * 128 +
s->maxval / 2) /
s->maxval;
177 for (
unsigned j = 0; j < n; j++)
178 ptr[j] = (
s->bytestream[j] *
f + 64) >> 7;
179 }
else if (upgrade == 2) {
180 unsigned int f = (65535 * 32768 +
s->maxval / 2) /
s->maxval;
181 for (
unsigned j = 0; j < n / 2; j++) {
182 unsigned v =
AV_RB16(
s->bytestream + 2*j);
183 ((uint16_t *)ptr)[j] = (v *
f + 16384) >> 15;
195 unsigned char *ptr1, *ptr2;
200 if (
s->maxval >= 256)
202 if (n * avctx->
height * 3 / 2 >
s->bytestream_end -
s->bytestream)
213 for (
i = 0;
i <
h;
i++) {
225 uint16_t *ptr1, *ptr2;
226 const int f = (65535 * 32768 +
s->maxval / 2) /
s->maxval;
229 n = avctx->
width * 2;
232 if (n * avctx->
height * 3 / 2 >
s->bytestream_end -
s->bytestream)
235 for (j = 0; j < n / 2; j++) {
237 ((uint16_t *)ptr)[j] = (v *
f + 16384) >> 15;
242 ptr1 = (uint16_t*)p->
data[1];
243 ptr2 = (uint16_t*)p->
data[2];
246 for (
i = 0;
i <
h;
i++) {
247 for (j = 0; j < n / 2; j++) {
249 ptr1[j] = (v *
f + 16384) >> 15;
253 for (j = 0; j < n / 2; j++) {
255 ptr2[j] = (v *
f + 16384) >> 15;
266 if (avctx->
width * avctx->
height * 12LL >
s->bytestream_end -
s->bytestream)
272 r = (
float *)p->
data[2];
273 g = (
float *)p->
data[0];
274 b = (
float *)p->
data[1];
276 for (
int j = 0; j < avctx->
width; j++) {
290 r = (
float *)p->
data[2];
291 g = (
float *)p->
data[0];
292 b = (
float *)p->
data[1];
294 for (
int j = 0; j < avctx->
width; j++) {
307 if (avctx->
width * avctx->
height * 6 >
s->bytestream_end -
s->bytestream)
313 r = (
float *)p->
data[2];
314 g = (
float *)p->
data[0];
315 b = (
float *)p->
data[1];
317 for (
int j = 0; j < avctx->
width; j++) {
331 r = (
float *)p->
data[2];
332 g = (
float *)p->
data[0];
333 b = (
float *)p->
data[1];
335 for (
int j = 0; j < avctx->
width; j++) {
358 if (avctx->
width * avctx->
height * 4 >
s->bytestream_end -
s->bytestream)
362 float *
g = (
float *)p->
data[0];
364 for (
int j = 0; j < avctx->
width; j++) {
371 float *
g = (
float *)p->
data[0];
373 for (
int j = 0; j < avctx->
width; j++) {
381 if (avctx->
width * avctx->
height * 2 >
s->bytestream_end -
s->bytestream)
385 float *
g = (
float *)p->
data[0];
387 for (
int j = 0; j < avctx->
width; j++) {
394 float *
g = (
float *)p->
data[0];
396 for (
int j = 0; j < avctx->
width; j++) {
411 return s->bytestream -
s->bytestream_start;
415 #if CONFIG_PGM_DECODER
428 #if CONFIG_PGMYUV_DECODER
441 #if CONFIG_PPM_DECODER
454 #if CONFIG_PBM_DECODER
467 #if CONFIG_PAM_DECODER
480 #if CONFIG_PFM_DECODER
493 #if CONFIG_PHM_DECODER
510 .
init = phm_dec_init,
const FFCodec ff_pgm_decoder
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
This structure describes decoded (raw) audio or video data.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
const FFCodec ff_phm_decoder
@ AV_PIX_FMT_MONOWHITE
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb.
#define AV_PIX_FMT_YUV420P10
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
const FFCodec ff_pam_decoder
AVCodec p
The public AVCodec.
enum AVDiscard skip_frame
Skip decoding for selected frames.
static av_always_inline float av_int2float(uint32_t i)
Reinterpret a 32-bit integer as a float.
const FFCodec ff_pgmyuv_decoder
#define AV_PIX_FMT_GRAY16
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_CODEC_DECODE_CB(func)
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
#define AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P16
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
#define AV_PIX_FMT_GRAYF32
#define CODEC_LONG_NAME(str)
@ AV_PIX_FMT_RGBA
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
@ AVDISCARD_ALL
discard all
@ AV_PIX_FMT_GRAY8A
alias for AV_PIX_FMT_YA8
#define AV_PIX_FMT_RGBA64
@ AV_PIX_FMT_MONOBLACK
Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb.
static int pnm_decode_frame(AVCodecContext *avctx, AVFrame *p, int *got_frame, AVPacket *avpkt)
static void samplecpy(uint8_t *dst, const uint8_t *src, int n, int maxval)
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
int(* init)(AVBSFContext *ctx)
@ AV_PIX_FMT_RGB24
packed RGB 8:8:8, 24bpp, RGBRGB...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
const FFCodec ff_ppm_decoder
#define AV_PIX_FMT_GBRPF32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
#define FF_CODEC_CAP_SKIP_FRAME_FILL_PARAM
The decoder extracts and fills its parameters even if the frame is skipped due to the skip_frame sett...
#define i(width, name, range_min, range_max)
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static uint32_t half2float(uint16_t h, const Half2FloatTables *t)
void ff_init_half2float_tables(Half2FloatTables *t)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
main external API structure.
int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext *const s)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static void scale(int *out, const int *in, const int w, const int h, const int shift)
const FFCodec ff_pbm_decoder
This structure stores compressed data.
int width
picture width / height.
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
const FFCodec ff_pfm_decoder
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16