29 #include "libavutil/avassert.h"
30 #include "libavutil/buffer.h"
31 #include "libavutil/common.h"
32 #include "libavutil/intreadwrite.h"
33 #include "libavutil/imgutils.h"
34 #include "libavutil/opt.h"
88 if (tags->
fourcc == fourcc)
95 #if LIBAVCODEC_VERSION_MAJOR < 55
174 int buf_size = avpkt->
size;
175 int linesize_align = 4;
189 if (context->
tff >= 0) {
210 for (i = 0; 2 * i + 1 < buf_size && i<avpkt->
size; i++) {
211 dst[2 * i + 0] = buf[i] >> 4;
212 dst[2 * i + 1] = buf[i] & 15;
217 for (i = 0; 4 * i + 3 < buf_size && i<avpkt->
size; i++) {
218 dst[4 * i + 0] = buf[i] >> 6;
219 dst[4 * i + 1] = buf[i] >> 4 & 3;
220 dst[4 * i + 2] = buf[i] >> 2 & 3;
221 dst[4 * i + 3] = buf[i] & 3;
226 }
else if (need_copy) {
227 memcpy(frame->
buf[0]->
data, buf, buf_size);
236 if (buf_size < len) {
237 av_log(avctx,
AV_LOG_ERROR,
"Invalid buffer size, packet size %d < expected frame_size %d\n", buf_size, len);
286 if (!frame->
buf[1]) {
298 flip(avctx, picture);
315 for (y = 0; y < avctx->
height; y++) {
316 for (x = 0; x < avctx->
width; x++)
317 line[2 * x + 1] ^= 0x80;
325 for(y = 0; y < avctx->
height; y++) {
326 for(x = 0; x < avctx->
width - 1; x += 2)
359 .priv_class = &rawdec_class,
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
This structure describes decoded (raw) audio or video data.
AVCodec ff_rawvideo_decoder
int linesize[AV_NUM_DATA_POINTERS]
number of bytes per line
#define LIBAVUTIL_VERSION_INT
int64_t pos
byte position in stream, -1 if unknown
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), big-endian, most significant bit to 0 ...
static av_cold int init(AVCodecContext *avctx)
enum AVPixelFormat ff_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc)
packed RGB 8:8:8, 24bpp, RGBRGB...
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
void av_frame_set_pkt_duration(AVFrame *frame, int64_t val)
int avpicture_fill(AVPicture *picture, const uint8_t *ptr, enum AVPixelFormat pix_fmt, int width, int height)
Setup the picture fields based on the specified image parameters and the provided image data buffer...
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
packed RGB 8:8:8, 24bpp, BGRBGR...
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
const PixelFormatTag ff_raw_pix_fmt_tags[]
const char * name
Name of the codec implementation.
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
static const PixelFormatTag pix_fmt_bps_avi[]
#define AV_OPT_FLAG_VIDEO_PARAM
int interlaced_frame
The content of the picture is interlaced.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
#define FFSWAP(type, a, b)
packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
uint8_t * data[AV_NUM_DATA_POINTERS]
pointers to the image data planes
int duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
const OptionDef options[]
#define AV_PIX_FMT_FLAG_PSEUDOPAL
The pixel format is "pseudo-paletted".
static const uint8_t frame_size[4]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int avpriv_set_systematic_pal2(uint32_t pal[256], enum AVPixelFormat pix_fmt)
static const PixelFormatTag pix_fmt_bps_mov[]
Libavcodec external API header.
AVPixelFormat
Pixel format.
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...
enum AVPictureType pict_type
Picture type of the frame.
uint8_t * data
The data buffer.
uint8_t * av_packet_get_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
int width
picture width / height.
static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
int64_t reordered_opaque
opaque 64bit number (generally a PTS) that will be reordered and output in AVFrame.reordered_opaque
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
enum AVPixelFormat avpriv_find_pix_fmt(const PixelFormatTag *tags, unsigned int fourcc)
AVBufferRef * av_buffer_alloc(int size)
Allocate an AVBuffer of the given size using av_malloc().
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
main external API structure.
static void close(AVCodecParserContext *s)
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
void av_frame_set_pkt_pos(AVFrame *frame, int64_t val)
AVBufferRef * buf[AV_NUM_DATA_POINTERS]
AVBuffer references backing the data for this frame.
packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0 ...
int64_t reordered_opaque
reordered opaque 64bit (generally an integer or a double precision float PTS but can be anything)...
Describe the class of an AVClass context structure.
#define MKTAG(a, b, c, d)
static av_cold int raw_close_decoder(AVCodecContext *avctx)
int palette_has_changed
Tell user application that palette has changed from previous frame.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
int64_t pkt_pts
PTS copied from the AVPacket that was decoded to produce this frame.
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb...
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
A reference to a data buffer.
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
static void flip(AVCodecContext *avctx, AVPicture *picture)
static av_cold int raw_init_decoder(AVCodecContext *avctx)
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
int top_field_first
If the content is interlaced, is top field displayed first.
int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height)
Calculate the size in bytes that a picture of the given width and height would occupy if stored in th...
int key_frame
1 -> keyframe, 0-> not
enum AVFieldOrder field_order
Field order.
static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
8 bit with PIX_FMT_RGB32 palette
AVPacket * pkt
Current packet as passed into the decoder, to avoid having to pass the packet into every function...
packed RGB 5:5:5, 16bpp, (msb)1A 5R 5G 5B(lsb), little-endian, most significant bit to 0 ...
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
static const AVClass rawdec_class