FFmpeg
cbs_jpeg_syntax_template.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
20  JPEGRawFrameHeader *current)
21 {
22  int err, i;
23 
24  HEADER("Frame Header");
25 
26  u(16, Lf, 8, 8 + 3 * JPEG_MAX_COMPONENTS);
27 
28  u(8, P, 2, 16);
29  u(16, Y, 0, JPEG_MAX_HEIGHT);
30  u(16, X, 1, JPEG_MAX_WIDTH);
31  u(8, Nf, 1, JPEG_MAX_COMPONENTS);
32 
33  for (i = 0; i < current->Nf; i++) {
34  us(8, C[i], i, 0, JPEG_MAX_COMPONENTS);
35  us(4, H[i], i, 1, 4);
36  us(4, V[i], i, 1, 4);
37  us(8, Tq[i], i, 0, 3);
38  }
39 
40  return 0;
41 }
42 
44  JPEGRawQuantisationTable *current)
45 {
46  int err, i;
47 
48  u(4, Pq, 0, 1);
49  u(4, Tq, 0, 3);
50 
51  if (current->Pq) {
52  for (i = 0; i < 64; i++)
53  us(16, Q[i], i, 1, 255);
54  } else {
55  for (i = 0; i < 64; i++)
56  us(8, Q[i], i, 1, 255);
57  }
58 
59  return 0;
60 }
61 
64 {
65  int err, i, n;
66 
67  HEADER("Quantisation Tables");
68 
69  u(16, Lq, 2, 2 + 4 * 65);
70  n = current->Lq / 65;
71 
72  for (i = 0; i < n; i++)
73  CHECK(FUNC(quantisation_table)(ctx, rw, &current->table[i]));
74 
75  return 0;
76 }
77 
79  JPEGRawHuffmanTable *current)
80 {
81  int err, i, j, ij;
82 
83  u(4, Tc, 0, 1);
84  u(4, Th, 0, 3);
85 
86  for (i = 0; i < 16; i++)
87  us(8, L[i], i, 0, 224);
88 
89  ij = 0;
90  for (i = 0; i < 16; i++) {
91  for (j = 0; j < current->L[i]; j++) {
92  if (ij >= 224)
93  return AVERROR_INVALIDDATA;
94  us(8, V[ij], ij, 0, 255);
95  ++ij;
96  }
97  }
98 
99  return 0;
100 }
101 
104 {
105  int err, i, j, n;
106 
107  HEADER("Huffman Tables");
108 
109  u(16, Lh, 2, 2 + 8 * (1 + 16 + 256));
110 
111  n = 2;
112  for (i = 0; n < current->Lh; i++) {
113  if (i >= 8)
114  return AVERROR_INVALIDDATA;
115 
116  CHECK(FUNC(huffman_table)(ctx, rw, &current->table[i]));
117 
118  ++n;
119  for (j = 0; j < 16; j++)
120  n += 1 + current->table[i].L[j];
121  }
122 
123  return 0;
124 }
125 
127  JPEGRawScanHeader *current)
128 {
129  int err, j;
130 
131  HEADER("Scan");
132 
133  u(16, Ls, 6, 6 + 2 * JPEG_MAX_COMPONENTS);
134 
135  u(8, Ns, 1, 4);
136  for (j = 0; j < current->Ns; j++) {
137  us(8, Cs[j], j, 0, JPEG_MAX_COMPONENTS);
138  us(4, Td[j], j, 0, 3);
139  us(4, Ta[j], j, 0, 3);
140  }
141 
142  u(8, Ss, 0, 63);
143  u(8, Se, 0, 63);
144  u(4, Ah, 0, 13);
145  u(4, Al, 0, 15);
146 
147  return 0;
148 }
149 
151  JPEGRawApplicationData *current)
152 {
153  int err, i;
154 
155  HEADER("Application Data");
156 
157  u(16, Lp, 2, 65535);
158 
159  if (current->Lp > 2) {
160 #ifdef READ
161  current->Ap_ref = av_buffer_alloc(current->Lp - 2);
162  if (!current->Ap_ref)
163  return AVERROR(ENOMEM);
164  current->Ap = current->Ap_ref->data;
165 #endif
166 
167  for (i = 0; i < current->Lp - 2; i++)
168  us(8, Ap[i], i, 0, 255);
169  }
170 
171  return 0;
172 }
173 
175  JPEGRawComment *current)
176 {
177  int err, i;
178 
179  HEADER("Comment");
180 
181  u(16, Lc, 2, 65535);
182 
183  if (current->Lc > 2) {
184 #ifdef READ
185  current->Cm_ref = av_buffer_alloc(current->Lc - 2);
186  if (!current->Cm_ref)
187  return AVERROR(ENOMEM);
188  current->Cm = current->Cm_ref->data;
189 #endif
190 
191  for (i = 0; i < current->Lc - 2; i++)
192  us(8, Cm[i], i, 0, 255);
193  }
194 
195  return 0;
196 }
av_buffer_alloc
AVBufferRef * av_buffer_alloc(int size)
Allocate an AVBuffer of the given size using av_malloc().
Definition: buffer.c:67
AVERROR
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
n
int n
Definition: avisynth_c.h:760
u
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:252
JPEG_MAX_HEIGHT
@ JPEG_MAX_HEIGHT
Definition: cbs_jpeg.h:48
HEADER
#define HEADER(name)
Definition: cbs_av1.c:537
CodedBitstreamContext
Context structure for coded bitstream operations.
Definition: cbs.h:168
application_data
static int FUNC() application_data(CodedBitstreamContext *ctx, RWContext *rw, JPEGRawApplicationData *current)
Definition: cbs_jpeg_syntax_template.c:150
JPEGRawQuantisationTable
Definition: cbs_jpeg.h:87
CHECK
CHECK(-1) CHECK(-2) }} }} CHECK(1) CHECK(2) }} }} } if(diff0+diff1 > 0) temp -
JPEGRawQuantisationTableSpecification
Definition: cbs_jpeg.h:93
us
#define us(width, name, range_min, range_max, subs,...)
Definition: cbs_h2645.c:266
C
s EdgeDetect Foobar g libavfilter vf_edgedetect c libavfilter vf_foobar c edit libavfilter and add an entry for foobar following the pattern of the other filters edit libavfilter allfilters and add an entry for foobar following the pattern of the other filters configure make j< whatever > ffmpeg ffmpeg i you should get a foobar png with Lena edge detected That s your new playground is ready Some little details about what s going which in turn will define variables for the build system and the C
Definition: writing_filters.txt:58
scan_header
static int FUNC() scan_header(CodedBitstreamContext *ctx, RWContext *rw, JPEGRawScanHeader *current)
Definition: cbs_jpeg_syntax_template.c:126
JPEG_MAX_COMPONENTS
@ JPEG_MAX_COMPONENTS
Definition: cbs_jpeg.h:46
ctx
AVFormatContext * ctx
Definition: movenc.c:48
H
F H1 F F H1 F F F F H1<-F-------F-------F v v v H2 H3 H2 ^ ^ ^ F-------F-------F-> H1<-F-------F-------F|||||||||F H1 F|||||||||F H1 Funavailable fullpel samples(outside the picture for example) shall be equalto the closest available fullpel sampleSmaller pel interpolation:--------------------------if diag_mc is set then points which lie on a line between 2 vertically, horizontally or diagonally adjacent halfpel points shall be interpolatedlinearly with rounding to nearest and halfway values rounded up.points which lie on 2 diagonals at the same time should only use the onediagonal not containing the fullpel point F--> O q O<--h1-> O q O<--F v \/v \/v O O O O O O O|/|\|q q q q q|/|\|O O O O O O O ^/\ ^/\ ^ h2--> O q O<--h3-> O q O<--h2 v \/v \/v O O O O O O O|\|/|q q q q q|\|/|O O O O O O O ^/\ ^/\ ^ F--> O q O<--h1-> O q O<--Fthe remaining points shall be bilinearly interpolated from theup to 4 surrounding halfpel and fullpel points, again rounding should be tonearest and halfway values rounded upcompliant Snow decoders MUST support 1-1/8 pel luma and 1/2-1/16 pel chromainterpolation at leastOverlapped block motion compensation:-------------------------------------FIXMELL band prediction:===================Each sample in the LL0 subband is predicted by the median of the left, top andleft+top-topleft samples, samples outside the subband shall be considered tobe 0. To reverse this prediction in the decoder apply the following.for(y=0;y< height;y++){ for(x=0;x< width;x++){ sample[y][x]+=median(sample[y-1][x], sample[y][x-1], sample[y-1][x]+sample[y][x-1]-sample[y-1][x-1]);}}sample[-1][ *]=sample[ *][-1]=0;width, height here are the width and height of the LL0 subband not of the finalvideoDequantization:===============FIXMEWavelet Transform:==================Snow supports 2 wavelet transforms, the symmetric biorthogonal 5/3 integertransform and an integer approximation of the symmetric biorthogonal 9/7daubechies wavelet.2D IDWT(inverse discrete wavelet transform) --------------------------------------------The 2D IDWT applies a 2D filter recursively, each time combining the4 lowest frequency subbands into a single subband until only 1 subbandremains.The 2D filter is done by first applying a 1D filter in the vertical directionand then applying it in the horizontal one. --------------- --------------- --------------- ---------------|LL0|HL0|||||||||||||---+---|HL1||L0|H0|HL1||LL1|HL1|||||LH0|HH0|||||||||||||-------+-------|-> L1 H1 LH1 HH1 LH1 HH1 LH1 HH1 this can end with a L or a H
Definition: snow.txt:555
V
#define V
Definition: avdct.c:30
huffman_table
static int FUNC() huffman_table(CodedBitstreamContext *ctx, RWContext *rw, JPEGRawHuffmanTable *current)
Definition: cbs_jpeg_syntax_template.c:78
quantisation_table
static int FUNC() quantisation_table(CodedBitstreamContext *ctx, RWContext *rw, JPEGRawQuantisationTable *current)
Definition: cbs_jpeg_syntax_template.c:43
JPEGRawHuffmanTableSpecification
Definition: cbs_jpeg.h:105
P
#define P
Y
#define Y
Definition: boxblur.h:38
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
JPEGRawApplicationData
Definition: cbs_jpeg.h:110
comment
static int FUNC() comment(CodedBitstreamContext *ctx, RWContext *rw, JPEGRawComment *current)
Definition: cbs_jpeg_syntax_template.c:174
dht
static int FUNC() dht(CodedBitstreamContext *ctx, RWContext *rw, JPEGRawHuffmanTableSpecification *current)
Definition: cbs_jpeg_syntax_template.c:102
L
#define L(x)
Definition: vp56_arith.h:36
frame_header
Definition: truemotion1.c:87
FUNC
#define FUNC(a)
Definition: bit_depth_template.c:104
dqt
static int FUNC() dqt(CodedBitstreamContext *ctx, RWContext *rw, JPEGRawQuantisationTableSpecification *current)
Definition: cbs_jpeg_syntax_template.c:62
JPEGRawFrameHeader
Definition: cbs_jpeg.h:53
JPEG_MAX_WIDTH
@ JPEG_MAX_WIDTH
Definition: cbs_jpeg.h:49
JPEGRawComment
Definition: cbs_jpeg.h:116
JPEGRawHuffmanTable
Definition: cbs_jpeg.h:98
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
RWContext
#define RWContext
Definition: cbs_av1.c:666
JPEGRawScanHeader
Definition: cbs_jpeg.h:66