Go to the documentation of this file.
31 uint32_t global_palette[16];
37 #define PUTNIBBLE(val)\
40 *q++ = bitbuf | ((val) & 0x0f);\
46 const uint8_t *bitmap,
int linesize,
51 unsigned int bitbuf = 0;
57 for (y = 0; y <
h; ++y) {
68 }
else if (
len < 0x10) {
71 }
else if (
len < 0x40) {
75 }
else if (
x+
len ==
w) {
101 int alpha_a = 8, alpha_b = 8;
103 for (
i = 24;
i >= 0;
i -= 8) {
104 d = alpha_a * (
int)((
a >>
i) & 0xFF) -
105 alpha_b * (
int)((
b >>
i) & 0xFF);
121 unsigned count[256] = { 0 };
122 uint32_t *palette = (uint32_t *)
r->data[1];
124 int x, y,
i, j, match, d, best_d,
av_uninit(best_j);
127 for (y = 0; y <
r->h; y++) {
128 for (
x = 0;
x <
r->w;
x++)
130 p +=
r->linesize[0] -
r->w;
132 for (
i = 0;
i < 256;
i++) {
137 match =
color < 0x33000000 ? 0 :
color < 0xCC000000 ? 1 : 17;
140 for (j = 0; j < 16; j++) {
150 hits[match] += count[
i];
155 int out_alpha[4],
unsigned hits[33])
158 int i, j, bright,
mult;
160 int selected[4] = { 0 };
161 uint32_t pseudopal[33] = { 0 };
162 uint32_t refcolor[3] = { 0x00000000, 0xFFFFFFFF, 0xFF000000 };
168 for (
i = 0;
i < 16;
i++) {
169 if (!(hits[1 +
i] + hits[17 +
i]))
173 for (j = 0; j < 3; j++, color >>= 8)
174 bright += (
color & 0xFF) < 0x40 || (
color & 0xFF) >= 0xC0;
176 hits[ 1 +
i] *=
mult;
177 hits[17 +
i] *=
mult;
181 for (
i = 0;
i < 4;
i++) {
182 for (j = 0; j < 33; j++)
183 if (hits[j] > hits[selected[
i]])
185 hits[selected[
i]] = 0;
190 for (
i = 0;
i < 16;
i++) {
194 for (
i = 0;
i < 3;
i++) {
196 for (j =
i + 1; j < 4; j++) {
199 FFSWAP(
int, selected[
i], selected[j]);
206 for (
i = 0;
i < 4;
i++) {
207 out_palette[
i] = selected[
i] ? (selected[
i] - 1) & 0xF : 0;
208 out_alpha [
i] = !selected[
i] ? 0 : selected[
i] < 17 ? 0x80 : 0xFF;
213 const uint32_t palette[],
214 const int out_palette[],
unsigned int const out_alpha[])
218 uint32_t pseudopal[4];
220 for (
i = 0;
i < 4;
i++)
221 pseudopal[
i] = (out_alpha[
i] << 24) |
223 for (
i = 0;
i < 256;
i++) {
225 for (j = 0; j < 4; j++) {
241 q = dst->
data[0] + (
src->x - dst->
x) +
243 for (y = 0; y <
src->h; y++) {
244 for (
x = 0;
x <
src->w;
x++)
245 *(q++) = cmap[*(p++)];
246 p +=
src->linesize[0] -
src->w;
252 uint8_t *outbuf,
int outbuf_size,
257 int offset1, offset2;
258 int i, rects =
h->num_rects,
ret;
259 unsigned global_palette_hits[33] = { 0 };
268 if (rects == 0 || !
h->rects)
270 for (
i = 0;
i < rects;
i++)
276 for (
i = 0;
i < rects;
i++)
284 for (
i = 0;
i < rects;
i++)
285 if (!
h->rects[
i]->data[0]) {
288 for (j = 0; j < 4; j++) {
290 rect->linesize[j] =
rect->pict.linesize[j];
296 vrect = *
h->rects[0];
303 int xmin =
h->rects[0]->x, xmax = xmin +
h->rects[0]->w;
304 int ymin =
h->rects[0]->y, ymax = ymin +
h->rects[0]->h;
305 for (
i = 1;
i < rects;
i++) {
306 xmin =
FFMIN(xmin,
h->rects[
i]->x);
307 ymin =
FFMIN(ymin,
h->rects[
i]->y);
308 xmax =
FFMAX(xmax,
h->rects[
i]->x +
h->rects[
i]->w);
309 ymax =
FFMAX(ymax,
h->rects[
i]->y +
h->rects[
i]->h);
313 vrect.w = xmax - xmin;
314 vrect.h = ymax - ymin;
319 global_palette_hits[0] = vrect.w * vrect.h;
320 for (
i = 0;
i < rects;
i++)
321 global_palette_hits[0] -=
h->rects[
i]->w *
h->rects[
i]->h;
324 for (
i = 0;
i < rects;
i++)
326 select_palette(avctx, out_palette, out_alpha, global_palette_hits);
329 if (!(vrect_data =
av_calloc(vrect.w, vrect.h)))
331 vrect.data [0] = vrect_data;
332 vrect.linesize[0] = vrect.w;
333 for (
i = 0;
i < rects;
i++) {
335 out_palette, out_alpha);
338 for (
i = 0;
i < 4;
i++)
342 out_palette, out_alpha);
346 for (
i = 0;
i < 4;
i++)
349 out_palette[
i], out_alpha[
i] >> 4);
354 offset1 = q - outbuf;
356 if ((q - outbuf) + vrect.w * vrect.h / 2 + 17 + 21 > outbuf_size) {
362 vrect.w, (vrect.h + 1) >> 1, cmap);
363 offset2 = q - outbuf;
365 vrect.w, vrect.h >> 1, cmap);
376 bytestream_put_be16(&qq, q - outbuf);
379 bytestream_put_be16(&q, (
h->start_display_time*90) >> 10);
380 bytestream_put_be16(&q, (q - outbuf) + 8 + 12 + 2);
382 *q++ = (out_palette[3] << 4) | out_palette[2];
383 *q++ = (out_palette[1] << 4) | out_palette[0];
385 *q++ = (out_alpha[3] & 0xF0) | (out_alpha[2] >> 4);
386 *q++ = (out_alpha[1] & 0xF0) | (out_alpha[0] >> 4);
389 x2 = vrect.x + vrect.w - 1;
390 y2 = vrect.y + vrect.h - 1;
395 *q++ = (vrect.x << 4) | ((x2 >> 8) & 0xf);
399 *q++ = (vrect.y << 4) | ((y2 >> 8) & 0xf);
404 bytestream_put_be16(&q, offset1);
405 bytestream_put_be16(&q, offset2);
407 *q++ = forced ? 0x00 : 0x01;
411 bytestream_put_be16(&q, (
h->end_display_time*90) >> 10);
412 bytestream_put_be16(&q, (q - outbuf) - 2 );
417 bytestream_put_be16(&qq, q - outbuf);
430 static const uint32_t default_palette[16] = {
431 0x000000, 0x0000FF, 0x00FF00, 0xFF0000,
432 0xFFFF00, 0xFF00FF, 0x00FFFF, 0xFFFFFF,
433 0x808000, 0x8080FF, 0x800080, 0x80FF80,
434 0x008080, 0xFF8080, 0x555555, 0xAAAAAA,
450 for (
i = 0;
i < 16;
i++)
462 unsigned char *buf,
int buf_size,
472 #define OFFSET(x) offsetof(DVDSubtitleContext, x)
473 #define SE AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_ENCODING_PARAM
476 {
"even_rows_fix",
"Make number of rows even (workaround for some players)",
OFFSET(even_rows_fix),
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1,
SE},
static const AVOption options[]
int avpriv_bprint_to_extradata(AVCodecContext *avctx, struct AVBPrint *buf)
Finalize buf into extradata and set its size appropriately.
#define FF_ENABLE_DEPRECATION_WARNINGS
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 const AVClass dvdsubenc_class
static void copy_rectangle(AVSubtitleRect *dst, AVSubtitleRect *src, int cmap[])
#define FFSWAP(type, a, b)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
void ff_dvdsub_parse_palette(uint32_t *palette, const char *p)
uint32_t global_palette[16]
static void count_colors(AVCodecContext *avctx, unsigned hits[33], const AVSubtitleRect *r)
Count colors used in a rectangle, quantizing alpha and grouping by nearest global palette entry.
static void select_palette(AVCodecContext *avctx, int out_palette[4], int out_alpha[4], unsigned hits[33])
int x
top left corner of pict, undefined when pict is not set
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo x
#define AV_BPRINT_SIZE_AUTOMATIC
#define AVERROR_BUFFER_TOO_SMALL
Buffer too small.
static int16_t mult(Float11 *f1, Float11 *f2)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int encode_dvd_subtitles(AVCodecContext *avctx, uint8_t *outbuf, int outbuf_size, const AVSubtitle *h)
int y
top left corner of pict, undefined when pict is not set
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
#define PTRDIFF_SPECIFIER
@ AV_CODEC_ID_DVD_SUBTITLE
const char * av_default_item_name(void *ptr)
Return the context name.
uint8_t * data[4]
data+linesize for the bitmap of this subtitle.
static int dvdsub_encode(AVCodecContext *avctx, unsigned char *buf, int buf_size, const AVSubtitle *sub)
static void build_color_map(AVCodecContext *avctx, int cmap[], const uint32_t palette[], const int out_palette[], unsigned int const out_alpha[])
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
#define AV_SUBTITLE_FLAG_FORCED
@ SUBTITLE_BITMAP
A bitmap, pict will be set.
#define i(width, name, range_min, range_max)
static void dvd_encode_rle(uint8_t **pq, const uint8_t *bitmap, int linesize, int w, int h, const int cmap[256])
static int color_distance(uint32_t a, uint32_t b)
const char * name
Name of the codec implementation.
AVCodec ff_dvdsub_encoder
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
FFmpeg Automated Testing Environment ************************************Introduction Using FATE from your FFmpeg source directory Submitting the results to the FFmpeg result aggregation server Uploading new samples to the fate suite FATE makefile targets and variables Makefile targets Makefile variables Examples Introduction **************FATE is an extended regression suite on the client side and a means for results aggregation and presentation on the server side The first part of this document explains how you can use FATE from your FFmpeg source directory to test your ffmpeg binary The second part describes how you can run FATE to submit the results to FFmpeg’s FATE server In any way you can have a look at the publicly viewable FATE results by visiting this as it can be seen if some test on some platform broke with their recent contribution This usually happens on the platforms the developers could not test on The second part of this document describes how you can run FATE to submit your results to FFmpeg’s FATE server If you want to submit your results be sure to check that your combination of OS and compiler is not already listed on the above mentioned website In the third part you can find a comprehensive listing of FATE makefile targets and variables Using FATE from your FFmpeg source directory **********************************************If you want to run FATE on your machine you need to have the samples in place You can get the samples via the build target fate rsync Use this command from the top level source this will cause FATE to fail NOTE To use a custom wrapper to run the pass ‘ target exec’ to ‘configure’ or set the TARGET_EXEC Make variable Submitting the results to the FFmpeg result aggregation server ****************************************************************To submit your results to the server you should run fate through the shell script ‘tests fate sh’ from the FFmpeg sources This script needs to be invoked with a configuration file as its first argument tests fate sh path to fate_config A configuration file template with comments describing the individual configuration variables can be found at ‘doc fate_config sh template’ Create a configuration that suits your based on the configuration template The ‘slot’ configuration variable can be any string that is not yet but it is suggested that you name it adhering to the following pattern ‘ARCH OS COMPILER COMPILER VERSION’ The configuration file itself will be sourced in a shell therefore all shell features may be used This enables you to setup the environment as you need it for your build For your first test runs the ‘fate_recv’ variable should be empty or commented out This will run everything as normal except that it will omit the submission of the results to the server The following files should be present in $workdir as specified in the configuration it may help to try out the ‘ssh’ command with one or more ‘ v’ options You should get detailed output concerning your SSH configuration and the authentication process The only thing left is to automate the execution of the fate sh script and the synchronisation of the samples directory Uploading new samples to the fate suite *****************************************If you need a sample uploaded send a mail to samples request This is for developers who have an account on the fate suite server If you upload new please make sure they are as small as space on each network bandwidth and so on benefit from smaller test cases Also keep in mind older checkouts use existing sample that means in practice generally do not remove or overwrite files as it likely would break older checkouts or releases Also all needed samples for a commit should be ideally before the push If you need an account for frequently uploading samples or you wish to help others by doing that send a mail to ffmpeg devel rsync vauL Duo ug o o w
void av_bprintf(AVBPrint *buf, const char *fmt,...)
main external API structure.
static int dvdsub_init(AVCodecContext *avctx)
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
#define FF_DISABLE_DEPRECATION_WARNINGS
int width
picture width / height.
int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx)
Check if the given dimension of an image is valid, meaning that all bytes of the image can be address...