41 const AVFrame *pict,
int *got_packet)
54 max_pkt_size += width * height * 3 * 4;
56 max_pkt_size += mb_width * mb_height * 3 * 4
88 int left[3], top[3], topleft[3];
91 buffer[0][i]= 1 << (9 - 1);
94 for(y = 0; y <
height; y++) {
95 const int modified_predictor= y ? predictor : 1;
104 top[i]= left[i]= topleft[i]=
buffer[0][i];
106 for(x = 0; x <
width; x++) {
108 buffer[x][1] = ptr[3*x+0] - ptr[3*x+1] + 0x100;
109 buffer[x][2] = ptr[3*x+2] - ptr[3*x+1] + 0x100;
110 buffer[x][0] = (ptr[3*x+0] + 2*ptr[3*x+1] + ptr[3*x+2])>>2;
112 buffer[x][1] = ptr[4*x+0] - ptr[4*x+1] + 0x100;
113 buffer[x][2] = ptr[4*x+2] - ptr[4*x+1] + 0x100;
114 buffer[x][0] = (ptr[4*x+0] + 2*ptr[4*x+1] + ptr[4*x+2])>>2;
120 PREDICT(pred, topleft[i], top[i], left[i], modified_predictor);
127 diff= ((left[i] - pred + 0x100)&0x1FF) - 0x100;
139 for(mb_y = 0; mb_y < mb_height; mb_y++) {
144 for(mb_x = 0; mb_x < mb_width; mb_x++) {
145 if(mb_x==0 || mb_y==0){
148 int x,
y, h,
v, linesize;
157 ptr = p->
data[i] + (linesize * (v * mb_y +
y)) + (h * mb_x + x);
166 pred= ptr[-linesize];
168 PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
182 int x,
y, h,
v, linesize;
191 ptr = p->
data[i] + (linesize * (v * mb_y +
y)) + (h * mb_x + x);
192 PREDICT(pred, ptr[-linesize-1], ptr[-linesize], ptr[-1], predictor);
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and/or allocate data.
This structure describes decoded (raw) audio or video data.
uint8_t * rd_scratchpad
scratchpad for rate distortion mb decision
static av_cold int init(AVCodecContext *avctx)
static int encode_picture_lossless(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet)
int ff_MPV_encode_end(AVCodecContext *avctx)
int mjpeg_hsample[3]
horizontal sampling factors, default = {2, 1, 1}
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
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.
MJPEG encoder and decoder.
uint16_t huff_code_dc_chrominance[12]
packed RGB 8:8:8, 24bpp, BGRBGR...
const char * name
Name of the codec implementation.
int av_frame_ref(AVFrame *dst, AVFrame *src)
Setup a new reference to the data described by a given frame.
Picture current_picture
copy of the current picture structure.
uint8_t huff_size_dc_chrominance[12]
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int ff_MPV_encode_init(AVCodecContext *avctx)
#define PREDICT(ret, topleft, top, left, predictor)
static void predictor(uint8_t *src, int size)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
packed BGR 8:8:8, 32bpp, BGR0BGR0...
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
uint8_t * edge_emu_buffer
temporary buffer for if MVs point to out-of-frame data
Libavcodec external API header.
AVPixelFormat
Pixel format.
int flags
A combination of AV_PKT_FLAG values.
static int put_bits_count(PutBitContext *s)
void ff_mjpeg_encode_picture_header(MpegEncContext *s)
enum AVPictureType pict_type
Picture type of the frame.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
#define FF_MIN_BUFFER_SIZE
minimum encoding buffer size Used to avoid some checks during header writing.
int ff_mpv_frame_size_alloc(MpegEncContext *s, int linesize)
static const float pred[4]
struct MJpegContext * mjpeg_ctx
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
int mjpeg_vsample[3]
vertical sampling factors, default = {2, 1, 1}
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
main external API structure.
static void close(AVCodecParserContext *s)
int height
picture size. must be a multiple of 16
void ff_mjpeg_encode_picture_trailer(MpegEncContext *s)
BYTE int const BYTE int int int height
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
struct AVCodecContext * avctx
uint16_t huff_code_dc_luminance[12]
PutBitContext pb
bit output
uint8_t huff_size_dc_luminance[12]
common internal api header.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
void ff_mjpeg_encode_stuffing(MpegEncContext *s)
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
int prediction_method
prediction method (needed for huffyuv)
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
int key_frame
1 -> keyframe, 0-> not
void ff_mjpeg_encode_dc(MpegEncContext *s, int val, uint8_t *huff_size, uint16_t *huff_code)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.