Go to the documentation of this file.
24 #define HEADER(name) do { \
25 ff_cbs_trace_header(ctx, name); \
28 #define CHECK(call) do { \
34 #define SUBSCRIPTS(subs, ...) (subs > 0 ? ((int[subs + 1]){ subs, __VA_ARGS__ }) : NULL)
36 #define u(width, name, range_min, range_max) \
37 xu(width, name, range_min, range_max, 0, )
38 #define us(width, name, sub, range_min, range_max) \
39 xu(width, name, range_min, range_max, 1, sub)
43 #define READWRITE read
44 #define RWContext GetBitContext
45 #define FUNC(name) cbs_jpeg_read_ ## name
47 #define xu(width, name, range_min, range_max, subs, ...) do { \
49 CHECK(ff_cbs_read_unsigned(ctx, rw, width, #name, \
50 SUBSCRIPTS(subs, __VA_ARGS__), \
51 &value, range_min, range_max)); \
52 current->name = value; \
64 #define READWRITE write
65 #define RWContext PutBitContext
66 #define FUNC(name) cbs_jpeg_write_ ## name
68 #define xu(width, name, range_min, range_max, subs, ...) do { \
69 uint32_t value = current->name; \
70 CHECK(ff_cbs_write_unsigned(ctx, rw, width, #name, \
71 SUBSCRIPTS(subs, __VA_ARGS__), \
72 value, range_min, range_max)); \
92 int start, end, marker, next_start, next_marker;
93 int err,
i, j, length;
103 "beginning of image.\n",
i);
108 "no SOI marker found.\n");
111 marker = frag->
data[
i];
114 "marker is %02x, should be SOI.\n", marker);
120 "no image content found.\n");
123 marker = frag->
data[
i];
133 if (frag->
data[
i] != 0xff)
137 frag->
data[
i] == 0xff;
i++);
139 if (frag->
data[
i] == 0x00)
141 next_marker = frag->
data[
i];
150 "truncated at %02x marker.\n", marker);
156 "truncated at %02x marker segment.\n", marker);
159 end = start + length;
162 if (frag->
data[
i] != 0xff) {
166 frag->
data[
i] == 0xff;
i++);
170 next_marker = frag->
data[
i];
179 if (length > end - start)
188 memcpy(
data, frag->
data + start, length);
189 for (
i = start + length, j = length;
i < end;
i++, j++) {
190 if (frag->
data[
i] == 0xff) {
191 while (frag->
data[
i] == 0xff)
204 data_size = end - start;
209 data, data_size, data_ref);
213 marker = next_marker;
215 }
while (next_marker != -1);
236 err = cbs_jpeg_read_frame_header(
ctx, &gbc, unit->
content);
242 err = cbs_jpeg_read_application_data(
ctx, &gbc, unit->
content);
250 err = cbs_jpeg_read_scan_header(
ctx, &gbc, &scan->
header);
265 switch (unit->
type) {
266 #define SEGMENT(marker, func) \
267 case JPEG_MARKER_ ## marker: \
269 err = cbs_jpeg_read_ ## func(ctx, &gbc, unit->content); \
293 err = cbs_jpeg_write_scan_header(
ctx, pbc, &scan->
header);
320 err = cbs_jpeg_write_frame_header(
ctx, pbc, unit->
content);
323 err = cbs_jpeg_write_application_data(
ctx, pbc, unit->
content);
325 switch (unit->
type) {
326 #define SEGMENT(marker, func) \
327 case JPEG_MARKER_ ## marker: \
328 err = cbs_jpeg_write_ ## func(ctx, pbc, unit->content); \
365 if (unit->
data[
sp] == 0xff)
397 if (unit->
data[
sp] == 0xff) {
#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
uint8_t * data
The data buffer.
void * content
Pointer to the decomposed form of this unit.
static int get_bits_count(const GetBitContext *s)
Context structure for coded bitstream operations.
#define CBS_UNIT_RANGE_POD(range_start, range_end, structure)
CodedBitstreamUnitType type
Codec-specific type of this unit.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
Coded bitstream unit structure.
static int cbs_jpeg_write_segment(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
#define SEGMENT(marker, func)
#define CBS_UNIT_TYPE_INTERNAL_REF(type, structure, ref_field)
static int put_bits_left(PutBitContext *s)
uint8_t * data
Pointer to the directly-parsable bitstream form of this unit.
CodedBitstreamUnit * units
Pointer to an array of units of length nb_units_allocated.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const CodedBitstreamUnitTypeDescriptor cbs_jpeg_unit_types[]
Coded bitstream fragment structure, combining one or more units.
size_t data_size
The number of bytes in the bitstream.
static int cbs_jpeg_assemble_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_cbs_append_unit_data(CodedBitstreamFragment *frag, CodedBitstreamUnitType type, uint8_t *data, size_t data_size, AVBufferRef *data_buf)
Add a new unit to a fragment with the given data bitstream.
static int cbs_jpeg_write_scan(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
size_t data_size
The number of bytes in the bitstream (including any padding bits in the final byte).
#define CBS_UNIT_RANGE_INTERNAL_REF(range_start, range_end, structure, ref_field)
static int cbs_jpeg_read_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
uint8_t * data
Pointer to the bitstream form of this fragment.
const CodedBitstreamType ff_cbs_type_jpeg
static const uint8_t header[24]
#define CBS_UNIT_TYPE_POD(type_, structure)
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
AVBufferRef * data_ref
A reference to the buffer containing data.
#define i(width, name, range_min, range_max)
static int put_bits_count(PutBitContext *s)
static int cbs_jpeg_split_fragment(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag, int header)
#define CBS_UNIT_TYPE_END_OF_LIST
static int FUNC() comment(CodedBitstreamContext *ctx, RWContext *rw, JPEGRawComment *current)
static int FUNC() dht(CodedBitstreamContext *ctx, RWContext *rw, JPEGRawHuffmanTableSpecification *current)
int ff_cbs_alloc_unit_content(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit)
Allocate a new internal content buffer matching the type of the unit.
#define AV_INPUT_BUFFER_PADDING_SIZE
static int cbs_jpeg_write_unit(CodedBitstreamContext *ctx, CodedBitstreamUnit *unit, PutBitContext *pbc)
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 skip_put_bytes(PutBitContext *s, int n)
Skip the given number of bytes.
static int FUNC() dqt(CodedBitstreamContext *ctx, RWContext *rw, JPEGRawQuantisationTableSpecification *current)
A reference to a data buffer.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
AVBufferRef * data_ref
A reference to the buffer containing data.
int nb_units
Number of units in this fragment.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16