Go to the documentation of this file.
36 #define RGBA(r,g,b,a) (((unsigned)(a) << 24) | ((r) << 16) | ((g) << 8) | (b))
37 #define MAX_EPOCH_PALETTES 8 // Max 8 allowed per PGS epoch
38 #define MAX_EPOCH_OBJECTS 64 // Max 64 allowed per PGS epoch
39 #define MAX_OBJECT_REFS 2 // Max objects per display set
106 for (
i = 0;
i <
ctx->objects.count;
i++) {
108 ctx->objects.object[
i].rle_buffer_size = 0;
109 ctx->objects.object[
i].rle_remaining_len = 0;
111 ctx->objects.count = 0;
112 ctx->palettes.count = 0;
119 for (
i = 0;
i < objects->
count;
i++) {
130 for (
i = 0;
i < palettes->
count;
i++) {
162 const uint8_t *buf,
unsigned int buf_size)
165 int pixel_count, line_count;
167 rle_bitmap_end = buf + buf_size;
177 while (buf < rle_bitmap_end && line_count < rect->
h) {
181 color = bytestream_get_byte(&buf);
185 flags = bytestream_get_byte(&buf);
188 run = (
run << 8) + bytestream_get_byte(&buf);
189 color =
flags & 0x80 ? bytestream_get_byte(&buf) : 0;
192 if (
run > 0 && pixel_count + run <= rect->
w *
rect->
h) {
200 if (pixel_count %
rect->
w > 0) {
211 if (pixel_count < rect->
w *
rect->
h) {
232 const uint8_t *buf,
int buf_size)
245 id = bytestream_get_be16(&buf);
252 object = &
ctx->objects.object[
ctx->objects.count++];
260 sequence_desc = bytestream_get_byte(&buf);
262 if (!(sequence_desc & 0x80)) {
268 object->rle_data_len += buf_size;
269 object->rle_remaining_len -= buf_size;
279 rle_bitmap_len = bytestream_get_be24(&buf) - 2*2;
281 if (buf_size > rle_bitmap_len) {
283 "Buffer dimension %d larger than the expected RLE data %d\n",
284 buf_size, rle_bitmap_len);
289 width = bytestream_get_be16(&buf);
290 height = bytestream_get_be16(&buf);
304 object->rle_data_len = 0;
305 object->rle_remaining_len = 0;
309 memcpy(object->
rle, buf, buf_size);
310 object->rle_data_len = buf_size;
311 object->rle_remaining_len = rle_bitmap_len - buf_size;
327 const uint8_t *buf,
int buf_size)
332 const uint8_t *buf_end = buf + buf_size;
336 int r,
g,
b, r_add, g_add, b_add;
339 id = bytestream_get_byte(&buf);
346 palette = &
ctx->palettes.palette[
ctx->palettes.count++];
353 while (buf < buf_end) {
354 color_id = bytestream_get_byte(&buf);
355 y = bytestream_get_byte(&buf);
356 cr = bytestream_get_byte(&buf);
357 cb = bytestream_get_byte(&buf);
358 alpha = bytestream_get_byte(&buf);
369 ff_dlog(avctx,
"Color %d := (%d,%d,%d,%d)\n", color_id,
r,
g,
b,
alpha);
389 const uint8_t *buf,
int buf_size,
394 const uint8_t *buf_end = buf + buf_size;
397 int w = bytestream_get_be16(&buf);
398 int h = bytestream_get_be16(&buf);
400 ctx->presentation.pts =
pts;
402 ff_dlog(avctx,
"Video Dimensions %dx%d\n",
412 ctx->presentation.id_number = bytestream_get_be16(&buf);
422 state = bytestream_get_byte(&buf) >> 6;
431 ctx->presentation.palette_id = bytestream_get_byte(&buf);
432 ctx->presentation.object_count = bytestream_get_byte(&buf);
435 "Invalid number of presentation objects %d\n",
436 ctx->presentation.object_count);
437 ctx->presentation.object_count = 2;
444 for (
i = 0;
i <
ctx->presentation.object_count;
i++)
447 if (buf_end - buf < 8) {
449 ctx->presentation.object_count =
i;
453 ctx->presentation.objects[
i].id = bytestream_get_be16(&buf);
454 ctx->presentation.objects[
i].window_id = bytestream_get_byte(&buf);
455 ctx->presentation.objects[
i].composition_flag = bytestream_get_byte(&buf);
457 ctx->presentation.objects[
i].x = bytestream_get_be16(&buf);
458 ctx->presentation.objects[
i].y = bytestream_get_be16(&buf);
461 if (
ctx->presentation.objects[
i].composition_flag & 0x80) {
462 ctx->presentation.objects[
i].crop_x = bytestream_get_be16(&buf);
463 ctx->presentation.objects[
i].crop_y = bytestream_get_be16(&buf);
464 ctx->presentation.objects[
i].crop_w = bytestream_get_be16(&buf);
465 ctx->presentation.objects[
i].crop_h = bytestream_get_be16(&buf);
468 ff_dlog(avctx,
"Subtitle Placement x=%d, y=%d\n",
469 ctx->presentation.objects[
i].x,
ctx->presentation.objects[
i].y);
471 if (
ctx->presentation.objects[
i].x > avctx->
width ||
472 ctx->presentation.objects[
i].y > avctx->
height) {
473 av_log(avctx,
AV_LOG_ERROR,
"Subtitle out of video bounds. x = %d, y = %d, video width = %d, video height = %d.\n",
474 ctx->presentation.objects[
i].x,
475 ctx->presentation.objects[
i].y,
477 ctx->presentation.objects[
i].x = 0;
478 ctx->presentation.objects[
i].y = 0;
499 const uint8_t *buf,
int buf_size)
508 memset(sub, 0,
sizeof(*sub));
519 if (!
ctx->presentation.object_count)
529 ctx->presentation.palette_id);
533 for (
i = 0;
i <
ctx->presentation.object_count;
i++) {
549 ctx->presentation.objects[
i].id);
557 if (
ctx->presentation.objects[
i].composition_flag & 0x40)
597 if (!
ctx->forced_subs_only ||
ctx->presentation.objects[
i].composition_flag & 0x40)
606 for (j = 0; j < 4; j++) {
608 rect->pict.linesize[j] =
rect->linesize[j];
621 int buf_size = avpkt->
size;
628 ff_dlog(avctx,
"PGS sub packet:\n");
630 for (
i = 0;
i < buf_size;
i++) {
645 buf_end = buf + buf_size;
648 while (buf < buf_end) {
649 segment_type = bytestream_get_byte(&buf);
650 segment_length = bytestream_get_be16(&buf);
652 ff_dlog(avctx,
"Segment Length %d, Segment Type %x\n", segment_length, segment_type);
658 switch (segment_type) {
690 segment_type, segment_length);
700 buf += segment_length;
706 #define OFFSET(x) offsetof(PGSSubContext, x)
707 #define SD AV_OPT_FLAG_SUBTITLE_PARAM | AV_OPT_FLAG_DECODING_PARAM
709 {
"forced_subs_only",
"Only show forced subtitles",
OFFSET(forced_subs_only),
AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1,
SD},
#define FF_ENABLE_DEPRECATION_WARNINGS
static av_cold int init(AVCodecContext *avctx)
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 double cb(void *priv, double x, double y)
static av_cold int init_decoder(AVCodecContext *avctx)
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
static const AVOption options[]
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
#define YUV_TO_RGB1_CCIR(cb1, cr1)
@ AV_CODEC_ID_HDMV_PGS_SUBTITLE
static int parse_presentation_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size, int64_t pts)
Parse the presentation segment packet.
static PGSSubObject * find_object(int id, PGSSubObjects *objects)
int x
top left corner of pict, undefined when pict is not set
static int display_end_segment(AVCodecContext *avctx, void *data, const uint8_t *buf, int buf_size)
Parse the display segment packet.
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int parse_object_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
Parse the picture segment packet.
PGSSubPalette palette[MAX_EPOCH_PALETTES]
#define YUV_TO_RGB1_CCIR_BT709(cb1, cr1)
int y
top left corner of pict, undefined when pict is not set
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int64_t pts
Same as packet pts, in AV_TIME_BASE.
PGSSubObject object[MAX_EPOCH_OBJECTS]
int w
width of pict, undefined when pict is not set
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
static int decode(AVCodecContext *avctx, void *data, int *got_sub_ptr, AVPacket *avpkt)
AVCodec ff_pgssub_decoder
const char * av_default_item_name(void *ptr)
Return the context name.
uint8_t * data[4]
data+linesize for the bitmap of this subtitle.
#define YUV_TO_RGB2_CCIR(r, g, b, y1)
#define AV_EF_EXPLODE
abort decoding on minor error detection
static PGSSubPalette * find_palette(int id, PGSSubPalettes *palettes)
PGSSubPresentation presentation
#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]
#define AV_NOPTS_VALUE
Undefined timestamp value.
uint32_t end_display_time
#define AV_SUBTITLE_FLAG_FORCED
@ SUBTITLE_BITMAP
A bitmap, pict will be set.
#define MAX_EPOCH_PALETTES
unsigned int rle_remaining_len
#define i(width, name, range_min, range_max)
unsigned int rle_data_len
PGSSubObjectRef objects[MAX_OBJECT_REFS]
int nb_colors
number of colors in pict, undefined when pict is not set
#define av_malloc_array(a, b)
void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size)
Same behaviour av_fast_malloc but the buffer has additional AV_INPUT_BUFFER_PADDING_SIZE at the end w...
static int decode_rle(AVCodecContext *avctx, AVSubtitleRect *rect, const uint8_t *buf, unsigned int buf_size)
Decode the RLE data.
#define MAX_EPOCH_OBJECTS
const char * name
Name of the codec implementation.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
@ AV_PIX_FMT_PAL8
8 bits with AV_PIX_FMT_RGB32 palette
int h
height of pict, undefined when pict is not set
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
main external API structure.
static av_cold int close_decoder(AVCodecContext *avctx)
static int parse_palette_segment(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
Parse the palette segment packet.
#define FF_DISABLE_DEPRECATION_WARNINGS
int ff_set_dimensions(AVCodecContext *s, int width, int height)
Check that the provided frame dimensions are valid and set them on the codec context.
static const int16_t alpha[]
This structure stores compressed data.
static double cr(void *priv, double x, double y)
int width
picture width / height.
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static void flush_cache(AVCodecContext *avctx)
uint32_t start_display_time
static const AVClass pgsdec_class
unsigned int rle_buffer_size