41 const uint8_t *bits_table,
const uint8_t *value_table)
48 for (
int i = 1;
i <= 16;
i++) {
53 for (
int i = 0;
i < n;
i++)
61 const uint8_t intra_matrix_permutation[64],
62 const uint16_t luma_intra_matrix[64],
63 const uint16_t chroma_intra_matrix[64],
64 int hsample[3],
int use_slices,
int matrices_differ)
70 int matrix_count = 1 + matrices_differ;
75 put_bits(p, 16, 2 + matrix_count * (1 + 64));
78 for (
int i = 0;
i < 64;
i++) {
79 uint8_t j = intra_matrix_permutation[
i];
80 put_bits(p, 8, luma_intra_matrix[j]);
83 if (matrix_count > 1) {
86 for (
int i = 0;
i < 64;
i++) {
87 uint8_t j = intra_matrix_permutation[
i];
88 put_bits(p, 8, chroma_intra_matrix[j]);
139 size_t *max_pkt_size)
145 if (!sd || !sd->
size)
150 "profile: too large for JPEG\n",
156 new_pkt_size = *max_pkt_size + nb_chunks * (UINT16_MAX + 2 );
157 if (new_pkt_size < *max_pkt_size)
159 *max_pkt_size = new_pkt_size;
190 "Gain map metadata is incompatible with Ultra HDR XMP\n");
198 size_t new_pkt_size = *max_pkt_size + extra_size;
199 if (new_pkt_size < *max_pkt_size)
201 *max_pkt_size = new_pkt_size;
215 if (sar.
num > 65535 || sar.
den > 65535) {
218 "Cannot store exact aspect ratio %d:%d\n",
240 if (sd && sd->
size) {
243 size_t remaining = sd->
size;
247 for (
int i = 0;
i < nb_chunks;
i++) {
323 size = strlen(
"CS=ITU601")+3;
334 vsample[0] = hsample[0] =
335 vsample[1] = hsample[1] =
336 vsample[2] = hsample[2] =
337 vsample[3] = hsample[3] = 1;
339 vsample[0] = vsample[1] = vsample[2] = 2;
340 hsample[0] = hsample[1] = hsample[2] = 1;
342 int chroma_h_shift, chroma_v_shift;
346 vsample[1] = 2 >> chroma_v_shift;
347 vsample[2] = 2 >> chroma_v_shift;
349 hsample[1] = 2 >> chroma_h_shift;
350 hsample[2] = 2 >> chroma_h_shift;
356 const uint8_t intra_matrix_permutation[64],
int pred,
357 const uint16_t luma_intra_matrix[64],
358 const uint16_t chroma_intra_matrix[64],
361 const int lossless = !m;
362 int hsample[4], vsample[4];
376 chroma_matrix = !lossless && !!memcmp(luma_intra_matrix,
378 sizeof(luma_intra_matrix[0]) * 64);
380 luma_intra_matrix, chroma_intra_matrix, hsample,
381 use_slices, chroma_matrix);
386 default:
av_unreachable(
"ff_mjpeg_encode_picture_header only called by "
387 "AMV, LJPEG, MJPEG and the former has been ruled out");
390 put_bits(pb, 16, 8 + 3 * components);
411 put_bits(pb, 8, lossless ? 0 : chroma_matrix);
417 put_bits(pb, 8, lossless ? 0 : chroma_matrix);
419 if (components == 4) {
446 if (components == 4) {
468 uint8_t *buf = pb->
buf + start;
469 int align= (-(size_t)(buf))&3;
480 if(buf[
i]==0xFF) ff_count++;
485 v= *(uint32_t*)(&buf[
i]);
486 acc= (((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
487 v= *(uint32_t*)(&buf[
i+4]);
488 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
489 v= *(uint32_t*)(&buf[
i+8]);
490 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
491 v= *(uint32_t*)(&buf[
i+12]);
492 acc+=(((v & (v>>4))&0x0F0F0F0F)+0x01010101)&0x10101010;
500 if(buf[
i]==0xFF) ff_count++;
503 if(ff_count==0)
return;
507 for(
i=
size-1; ff_count;
i--){
521 const uint8_t *bits_table,
522 const uint8_t *val_table)
528 for (
int i = 1;
i <= 16;
i++) {
529 int nb = bits_table[
i];
530 for (
int j = 0; j < nb; j++) {
531 int sym = val_table[k++];
533 huff_code[sym] =
code;
548 const uint8_t huff_size[],
const uint16_t huff_code[])
553 put_bits(pb, huff_size[0], huff_code[0]);
563 put_bits(pb, huff_size[nbits], huff_code[nbits]);
578 "Non full-range YUV is non-standard, set strict_std_compliance "
579 "to at most unofficial to use it.\n");
SwsAArch64OpImplParams params
static double val(void *priv, double ch)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
void ff_put_string(PutBitContext *pb, const char *string, int terminate_string)
Put the string string in the bitstream.
static const uint8_t *BS_FUNC align(BSCTX *bc)
Skip bits to a byte boundary.
#define i(width, name, range_min, range_max)
#define EOI
End Of Image marker.
#define FF_COMPLIANCE_UNOFFICIAL
Allow unofficial extensions.
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
@ AV_FRAME_DATA_ICC_PROFILE
The data contains an ICC profile as an opaque octet buffer following the format described by ISO 1507...
@ AV_FRAME_DATA_GAIN_MAP_PARAMS
Parameters describing how to combine this gain map with its base image to form an alternate rendition...
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
FF_VISIBILITY_PUSH_HIDDEN const uint8_t ff_mjpeg_bits_dc_luminance[]
const uint8_t ff_mjpeg_val_ac_chrominance[]
const uint8_t ff_mjpeg_bits_ac_luminance[]
const uint8_t ff_mjpeg_bits_dc_chrominance[]
const uint8_t ff_mjpeg_bits_ac_chrominance[]
const uint8_t ff_mjpeg_val_dc[]
const uint8_t ff_mjpeg_val_ac_luminance[]
int ff_gain_map_params_check_xmp(const AVGainMapParams *p)
Returns 1 if the gain map parameters are compatible with the XMP-based encoding, or 0 otherwise.
int ff_gain_map_params_to_xmp(const AVGainMapParams *p, char *buf)
Serialize an AVGainMapParams as an Ultra HDR XMP packet.
int ff_gain_map_params_to_iso21496(const AVGainMapParams *p, uint8_t *buf)
Serialize an AVGainMapParams as an ISO 21496-1 gain map metadata blob.
Serialization of AVGainMapParams into the metadata blobs that image formats carry it in,...
#define FF_GAIN_MAP_XMP_MAX_LEN
#define FF_GAIN_MAP_XMP_IDENT
#define FF_GAIN_MAP_MAX_PAYLOAD_SIZE
Libavcodec version macros.
int av_gain_map_params_validate(const AVGainMapParams *p)
Returns >= 0 if the given AVGainMapParams struct contains valid data; or a negative AVERROR otherwise...
#define AV_ISO21496_IDENTIFIER
void av_log_once(void *avcl, int initial_level, int subsequent_level, int *state, const char *fmt,...)
#define MKTAG(a, b, c, d)
MJPEG encoder and decoder.
@ HUFFMAN_TABLE_OPTIMAL
Compute and use optimal Huffman tables.
static void put_marker(PutBitContext *p, enum JpegMarker code)
void ff_mjpeg_encode_dc(PutBitContext *pb, int val, const uint8_t huff_size[], const uint16_t huff_code[])
int ff_mjpeg_add_gain_map_size(AVCodecContext *avctx, struct MJpegContext *m, const AVFrame *frame, size_t *max_pkt_size)
void ff_mjpeg_init_hvsample(const AVCodecContext *avctx, int hsample[4], int vsample[4])
void ff_mjpeg_encode_picture_header(AVCodecContext *avctx, PutBitContext *pb, const AVFrame *frame, const struct MJpegContext *m, const uint8_t intra_matrix_permutation[64], int pred, const uint16_t luma_intra_matrix[64], const uint16_t chroma_intra_matrix[64], int use_slices)
static void jpeg_put_comments(AVCodecContext *avctx, PutBitContext *p, const AVFrame *frame, const struct MJpegContext *m)
int ff_mjpeg_add_icc_profile_size(AVCodecContext *avctx, const AVFrame *frame, size_t *max_pkt_size)
int ff_mjpeg_encode_check_pix_fmt(AVCodecContext *avctx)
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)
static int put_huffman_table(PutBitContext *p, int table_class, int table_id, const uint8_t *bits_table, const uint8_t *value_table)
static void jpeg_table_header(AVCodecContext *avctx, PutBitContext *p, const MJpegContext *m, const uint8_t intra_matrix_permutation[64], const uint16_t luma_intra_matrix[64], const uint16_t chroma_intra_matrix[64], int hsample[3], int use_slices, int matrices_differ)
static int want_gain_map_xmp(const struct MJpegContext *m, const AVGainMapParams *p)
void ff_mjpeg_encode_picture_trailer(PutBitContext *pb, int header_bits)
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.
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
@ AVCOL_RANGE_JPEG
Full range content.
@ 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_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...
static void put_sbits(PutBitContext *pb, int n, int32_t value)
static int put_bits_count(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 void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static int put_bytes_output(const PutBitContext *s)
static void skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
static const float pred[4]
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, ...).
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
int flags
AV_CODEC_FLAG_*.
Structure to hold side data for an AVFrame.
This structure describes decoded (raw) audio or video data.
Parameters describing how to combine a gain map rendition with its base rendition to recover the alte...
Rational number (pair of numerator and denominator).
Holds JPEG frame data and Huffman table data.
int force_duplicated_matrix
uint8_t bits_dc_luminance[17]
DC luminance Huffman bits.
uint8_t bits_ac_luminance[17]
AC luminance Huffman bits.
uint8_t val_ac_luminance[256]
AC luminance Huffman values.
uint8_t val_ac_chrominance[256]
AC chrominance Huffman values.
uint8_t bits_dc_chrominance[17]
DC chrominance Huffman bits.
uint8_t val_dc_luminance[12]
DC luminance Huffman values.
uint8_t bits_ac_chrominance[17]
AC chrominance Huffman bits.
uint8_t val_dc_chrominance[12]
DC chrominance Huffman values.