71 uint16_t (*
buffer)[4] =
s->scratch;
72 int left[4], top[4], topleft[4];
75 #if FF_API_PRIVATE_OPT
82 for (
i = 0;
i < 4;
i++)
85 for (y = 0; y <
height; y++) {
86 const int modified_predictor = y ?
s->pred : 1;
94 for (
i = 0;
i < 4;
i++)
97 for (x = 0; x <
width; x++) {
99 buffer[x][1] = ptr[3 * x + 0] - ptr[3 * x + 1] + 0x100;
100 buffer[x][2] = ptr[3 * x + 2] - ptr[3 * x + 1] + 0x100;
101 buffer[x][0] = (ptr[3 * x + 0] + 2 * ptr[3 * x + 1] + ptr[3 * x + 2]) >> 2;
103 buffer[x][1] = ptr[4 * x + 0] - ptr[4 * x + 1] + 0x100;
104 buffer[x][2] = ptr[4 * x + 2] - ptr[4 * x + 1] + 0x100;
105 buffer[x][0] = (ptr[4 * x + 0] + 2 * ptr[4 * x + 1] + ptr[4 * x + 2]) >> 2;
107 buffer[x][3] = ptr[4 * x + 3];
120 diff = ((left[
i] -
pred + 0x100) & 0x1FF) - 0x100;
122 if (
i == 0 ||
i == 3)
139 if (mb_x == 0 || mb_y == 0) {
140 for (
i = 0;
i < 3;
i++) {
142 int x, y,
h, v, linesize;
147 for (y = 0; y < v; y++) {
148 for (x = 0; x <
h; x++) {
151 ptr =
frame->
data[
i] + (linesize * (v * mb_y + y)) + (
h * mb_x + x);
152 if (y == 0 && mb_y == 0) {
153 if (x == 0 && mb_x == 0)
158 if (x == 0 && mb_x == 0) {
159 pred = ptr[-linesize];
174 for (
i = 0;
i < 3;
i++) {
176 int x, y,
h, v, linesize;
181 for (y = 0; y < v; y++) {
182 for (x = 0; x <
h; x++) {
185 ptr =
frame->
data[
i] + (linesize * (v * mb_y + y)) + (
h * mb_x + x);
202 const int mb_width = (avctx->
width +
s->hsample[0] - 1) /
s->hsample[0];
203 const int mb_height = (avctx->
height +
s->vsample[0] - 1) /
s->vsample[0];
206 #if FF_API_PRIVATE_OPT
213 for (mb_y = 0; mb_y < mb_height; mb_y++) {
215 mb_width * 4 * 3 *
s->hsample[0] *
s->vsample[0]) {
220 for (mb_x = 0; mb_x < mb_width; mb_x++)
228 const AVFrame *pict,
int *got_packet)
234 const int mb_width = (
width +
s->hsample[0] - 1) /
s->hsample[0];
235 const int mb_height = (
height +
s->vsample[0] - 1) /
s->vsample[0];
237 int ret, header_bits;
245 max_pkt_size += mb_width * mb_height * 3 * 4
246 *
s->hsample[0] *
s->vsample[0];
255 s->pred,
s->matrix,
s->matrix);
300 "Limited range YUV is non-standard, set strict_std_compliance to "
301 "at least unofficial to use it.\n");
305 #if FF_API_CODED_FRAME
323 s->huff_code_dc_luminance,
327 s->huff_code_dc_chrominance,
334 #define OFFSET(x) offsetof(LJpegEncContext, x)
335 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
Libavcodec external API header.
#define FF_COMPLIANCE_UNOFFICIAL
Allow unofficial extensions.
static av_cold int init(AVCodecContext *avctx)
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
static void predictor(uint8_t *src, ptrdiff_t size)
reference-counted frame API
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
#define AV_INPUT_BUFFER_MIN_SIZE
minimum encoding buffer size Used to avoid some checks during header writing.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
@ AV_PICTURE_TYPE_I
Intra.
#define LIBAVUTIL_VERSION_INT
av_cold void ff_idctdsp_init(IDCTDSPContext *c, AVCodecContext *avctx)
av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable)
const uint8_t avpriv_mjpeg_val_dc[12]
const uint8_t avpriv_mjpeg_bits_dc_luminance[17]
const uint8_t avpriv_mjpeg_bits_dc_chrominance[17]
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
static enum AVPixelFormat pix_fmts[]
static int ljpeg_encode_bgr(AVCodecContext *avctx, PutBitContext *pb, const AVFrame *frame)
static av_cold int ljpeg_encode_close(AVCodecContext *avctx)
static const AVOption options[]
static av_cold int ljpeg_encode_init(AVCodecContext *avctx)
static void ljpeg_encode_yuv_mb(LJpegEncContext *s, PutBitContext *pb, const AVFrame *frame, int predictor, int mb_x, int mb_y)
static int ljpeg_encode_yuv(AVCodecContext *avctx, PutBitContext *pb, const AVFrame *frame)
static int ljpeg_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
static const AVClass ljpeg_class
const uint8_t ff_zigzag_direct[64]
Memory handling functions.
MJPEG encoder and decoder.
#define PREDICT(ret, topleft, top, left, predictor)
void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[4], int vsample[4])
void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb, ScanTable *intra_scantable, int pred, uint16_t luma_intra_matrix[64], uint16_t chroma_intra_matrix[64])
void ff_mjpeg_escape_FF(PutBitContext *pb, int start)
void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code, const uint8_t *bits_table, const uint8_t *val_table)
void ff_mjpeg_encode_dc(PutBitContext *pb, int val, uint8_t *huff_size, uint16_t *huff_code)
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits)
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
AVPixelFormat
Pixel format.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
static int put_bits_count(PutBitContext *s)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static const float pred[4]
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
enum AVColorRange color_range
MPEG vs JPEG YUV range.
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
attribute_deprecated AVFrame * coded_frame
the picture in the bitstream
attribute_deprecated int prediction_method
const char * name
Name of the codec implementation.
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.
uint16_t huff_code_dc_chrominance[12]
uint8_t huff_size_dc_luminance[12]
uint8_t huff_size_dc_chrominance[12]
uint16_t huff_code_dc_luminance[12]
#define av_malloc_array(a, b)
static av_always_inline int diff(const uint32_t a, const uint32_t b)