Go to the documentation of this file.
40 const uint8_t *bits_table,
const uint8_t *value_table)
62 uint16_t luma_intra_matrix[64],
63 uint16_t chroma_intra_matrix[64],
64 int hsample[3],
int use_slices)
70 int matrix_count = 1 + !!memcmp(luma_intra_matrix,
72 sizeof(luma_intra_matrix[0]) * 64);
77 put_bits(p, 16, 2 + matrix_count * (1 + 64));
80 for (
int i = 0;
i < 64;
i++) {
82 put_bits(p, 8, luma_intra_matrix[j]);
85 if (matrix_count > 1) {
90 put_bits(p, 8, chroma_intra_matrix[j]);
141 size_t *max_pkt_size)
147 if (!sd || !sd->
size)
152 "profile: too large for JPEG\n",
158 new_pkt_size = *max_pkt_size + nb_chunks * (UINT16_MAX + 2 );
159 if (new_pkt_size < *max_pkt_size)
161 *max_pkt_size = new_pkt_size;
175 if (sar.
num > 65535 || sar.
den > 65535) {
178 "Cannot store exact aspect ratio %d:%d\n",
200 if (sd && sd->
size) {
203 size_t remaining = sd->
size;
207 for (
int i = 0;
i < nb_chunks;
i++) {
247 size = strlen(
"CS=ITU601")+3;
258 vsample[0] = hsample[0] =
259 vsample[1] = hsample[1] =
260 vsample[2] = hsample[2] =
261 vsample[3] = hsample[3] = 1;
263 vsample[0] = vsample[1] = vsample[2] = 2;
264 hsample[0] = hsample[1] = hsample[2] = 1;
266 int chroma_h_shift, chroma_v_shift;
270 vsample[1] = 2 >> chroma_v_shift;
271 vsample[2] = 2 >> chroma_v_shift;
273 hsample[1] = 2 >> chroma_h_shift;
274 hsample[2] = 2 >> chroma_h_shift;
281 uint16_t luma_intra_matrix[64],
282 uint16_t chroma_intra_matrix[64],
285 const int lossless = !m;
286 int hsample[4], vsample[4];
288 int chroma_matrix = !!memcmp(luma_intra_matrix,
290 sizeof(luma_intra_matrix[0])*64);
303 luma_intra_matrix, chroma_intra_matrix, hsample,
333 put_bits(pb, 8, lossless ? 0 : chroma_matrix);
339 put_bits(pb, 8, lossless ? 0 : chroma_matrix);
341 if (components == 4) {
368 if (components == 4) {
390 uint8_t *buf = pb->
buf + start;
391 int align= (-(size_t)(buf))&3;
402 if(buf[
i]==0xFF) ff_count++;
407 v= *(uint32_t*)(&buf[
i]);
408 acc= (((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
409 v= *(uint32_t*)(&buf[
i+4]);
410 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
411 v= *(uint32_t*)(&buf[
i+8]);
412 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
413 v= *(uint32_t*)(&buf[
i+12]);
414 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
422 if(buf[
i]==0xFF) ff_count++;
425 if(ff_count==0)
return;
430 for(
i=
size-1; ff_count;
i--){
444 const uint8_t *bits_table,
445 const uint8_t *val_table)
451 for (
int i = 1;
i <= 16;
i++) {
452 int nb = bits_table[
i];
453 for (
int j = 0; j < nb; j++) {
454 int sym = val_table[k++];
456 huff_code[sym] =
code;
471 uint8_t *huff_size, uint16_t *huff_code)
476 put_bits(pb, huff_size[0], huff_code[0]);
486 put_bits(pb, huff_size[nbits], huff_code[nbits]);
501 "Non full-range YUV is non-standard, set strict_std_compliance "
502 "to at most unofficial to use it.\n");
void ff_mjpeg_encode_dc(PutBitContext *pb, int val, uint8_t *huff_size, uint16_t *huff_code)
#define AV_LOG_WARNING
Something somehow does not look correct.
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 jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p, const AVFrame *frame)
static int put_bytes_output(const PutBitContext *s)
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
static void put_sbits(PutBitContext *pb, int n, int32_t value)
int av_log2_16bit(unsigned v)
This structure describes decoded (raw) audio or video data.
uint8_t bits_ac_chrominance[17]
AC chrominance Huffman bits.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
@ AVCOL_RANGE_JPEG
Full range content.
void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb, const AVFrame *frame, struct MJpegContext *m, ScanTable *intra_scantable, int pred, uint16_t luma_intra_matrix[64], uint16_t chroma_intra_matrix[64], int use_slices)
uint8_t val_dc_chrominance[12]
DC chrominance Huffman values.
const uint8_t ff_mjpeg_val_dc[]
@ AV_PIX_FMT_BGR24
packed RGB 8:8:8, 24bpp, BGRBGR...
@ AV_PIX_FMT_BGRA
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
static int put_huffman_table(PutBitContext *p, int table_class, int table_id, const uint8_t *bits_table, const uint8_t *value_table)
int force_duplicated_matrix
const uint8_t ff_mjpeg_bits_ac_chrominance[]
#define FF_COMPLIANCE_UNOFFICIAL
Allow unofficial extensions.
int flags
AV_CODEC_FLAG_*.
static double val(void *priv, double ch)
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t bits_dc_luminance[17]
DC luminance Huffman bits.
uint8_t val_dc_luminance[12]
DC luminance Huffman values.
@ HUFFMAN_TABLE_OPTIMAL
Compute and use optimal Huffman tables.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
uint8_t val_ac_chrominance[256]
AC chrominance Huffman values.
void ff_put_string(PutBitContext *pb, const char *string, int terminate_string)
Put the string string in the bitstream.
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Rational number (pair of numerator and denominator).
@ AV_FRAME_DATA_ICC_PROFILE
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
@ AV_PIX_FMT_BGR0
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
const uint8_t ff_mjpeg_val_ac_chrominance[]
const uint8_t ff_mjpeg_val_ac_luminance[]
const uint8_t ff_mjpeg_bits_ac_luminance[]
const uint8_t ff_mjpeg_bits_dc_luminance[]
int ff_mjpeg_add_icc_profile_size(AVCodecContext *avctx, const AVFrame *frame, size_t *max_pkt_size)
void ff_mjpeg_build_huffman_codes(uint8_t *huff_size, uint16_t *huff_code, const uint8_t *bits_table, const uint8_t *val_table)
#define i(width, name, range_min, range_max)
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
static int put_bits_count(PutBitContext *s)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
int ff_mjpeg_encode_check_pix_fmt(AVCodecContext *avctx)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
uint8_t bits_dc_chrominance[17]
DC chrominance Huffman bits.
static const float pred[4]
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
int strict_std_compliance
strictly follow the standard (MPEG-4, ...).
main external API structure.
static uint8_t * put_bits_ptr(PutBitContext *s)
Return the pointer to the byte where the bitstream writer will put the next bit.
void ff_mjpeg_escape_FF(PutBitContext *pb, int start)
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
Holds JPEG frame data and Huffman table data.
static void put_marker(PutBitContext *p, enum JpegMarker code)
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
const uint8_t ff_mjpeg_bits_dc_chrominance[]
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
void ff_mjpeg_init_hvsample(AVCodecContext *avctx, int hsample[4], int vsample[4])
Structure to hold side data for an AVFrame.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
int width
picture width / height.
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define MKTAG(a, b, c, d)
uint8_t bits_ac_luminance[17]
AC luminance Huffman bits.
uint8_t val_ac_luminance[256]
AC luminance Huffman values.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p, MJpegContext *m, ScanTable *intra_scantable, uint16_t luma_intra_matrix[64], uint16_t chroma_intra_matrix[64], int hsample[3], int use_slices)