28 #include "libavutil/opt.h"
33 #if CONFIG_CLJR_DECODER
35 void *
data,
int *got_frame,
39 int buf_size = avpkt->
size;
51 "Resolution larger than buffer size. Invalid header?\n");
62 for (y = 0; y < avctx->
height; y++) {
66 for (x = 0; x < avctx->
width; x += 4) {
67 luma[3] = (
get_bits(&gb, 5)*33) >> 2;
68 luma[2] = (
get_bits(&gb, 5)*33) >> 2;
69 luma[1] = (
get_bits(&gb, 5)*33) >> 2;
70 luma[0] = (
get_bits(&gb, 5)*33) >> 2;
99 #if CONFIG_CLJR_ENCODER
100 typedef struct CLJRContext {
116 const AVFrame *p,
int *got_packet)
122 static const uint32_t ordered_dither[2][2] =
124 { 0x10400000, 0x104F0000 },
125 { 0xCB2A0000, 0xCB250000 },
136 for (y = 0; y < avctx->
height; y++) {
140 for (x = 0; x < avctx->
width; x += 4) {
141 switch (a->dither_type) {
142 case 0: dither = 0x492A0000;
break;
143 case 1: dither = dither * 1664525 + 1013904223;
break;
144 case 2: dither = ordered_dither[ y&1 ][ (x>>2)&1 ];
break;
146 put_bits(&pb, 5, (249*(luma[3] + (dither>>29) )) >> 11);
147 put_bits(&pb, 5, (249*(luma[2] + ((dither>>26)&7))) >> 11);
148 put_bits(&pb, 5, (249*(luma[1] + ((dither>>23)&7))) >> 11);
149 put_bits(&pb, 5, (249*(luma[0] + ((dither>>20)&7))) >> 11);
151 put_bits(&pb, 6, (253*(*(cb++) + ((dither>>18)&3))) >> 10);
152 put_bits(&pb, 6, (253*(*(cr++) + ((dither>>16)&3))) >> 10);
164 #define OFFSET(x) offsetof(CLJRContext, x)
165 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
171 static const AVClass cljr_class = {
183 .priv_data_size =
sizeof(CLJRContext),
188 .priv_class = &cljr_class,
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.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define LIBAVUTIL_VERSION_INT
static av_cold int init(AVCodecContext *avctx)
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.
static double cb(void *priv, double x, double y)
const char * av_default_item_name(void *ctx)
Return the context name.
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 char * name
Name of the codec implementation.
#define CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
static av_cold int decode_init(AVCodecContext *avctx)
bitstream reader API header.
const OptionDef options[]
static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
#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. ...
static const uint8_t dither[8][8]
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Libavcodec external API header.
AVPixelFormat
Pixel format.
int flags
A combination of AV_PKT_FLAG values.
static int put_bits_count(PutBitContext *s)
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
static av_cold int encode_init(AVCodecContext *avctx)
int AC3_NAME() encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
main external API structure.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Describe the class of an AVClass context structure.
AVFrame * coded_frame
the picture in the bitstream
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
common internal api header.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
#define AVERROR_INVALIDDATA
int key_frame
1 -> keyframe, 0-> not
int frame_number
Frame counter, set by libavcodec.
static double cr(void *priv, double x, double y)
This structure stores compressed data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.