25 #include "librsvg-2.0/librsvg/rsvg.h"
42 RsvgDimensionData unscaled_dimensions, dimensions;
43 cairo_surface_t *image;
44 cairo_t *crender =
NULL;
49 handle = rsvg_handle_new_from_data(pkt->
data, pkt->
size, &error);
56 rsvg_handle_get_dimensions(handle, &dimensions);
57 rsvg_handle_get_dimensions(handle, &unscaled_dimensions);
58 dimensions.width = s->
width ? s->
width : dimensions.width;
59 dimensions.height = s->
height ? s->
height : dimensions.height;
61 double default_ar = unscaled_dimensions.width/(double)unscaled_dimensions.height;
63 dimensions.width =
lrintf(dimensions.height * default_ar);
65 dimensions.height =
lrintf(dimensions.width / default_ar);
77 image = cairo_image_surface_create_for_data(frame->
data[0], CAIRO_FORMAT_ARGB32,
80 if (cairo_surface_status(image) != CAIRO_STATUS_SUCCESS)
83 crender = cairo_create(image);
85 cairo_set_source_rgba(crender, 0.0, 0.0, 0.0, 1.0f);
86 cairo_paint_with_alpha(crender, 0.0f);
88 cairo_scale(crender, dimensions.width / (
double)unscaled_dimensions.width,
89 dimensions.height / (
double)unscaled_dimensions.height);
91 rsvg_handle_render_cairo(handle, crender);
93 cairo_destroy(crender);
94 cairo_surface_destroy(image);
95 g_object_unref(handle);
102 #define OFFSET(x) offsetof(LibRSVGContext, x)
103 #define DEC (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
This structure describes decoded (raw) audio or video data.
ptrdiff_t const GLvoid * data
#define LIBAVUTIL_VERSION_INT
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.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#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. ...
const char * name
Name of the codec implementation.
enum AVPictureType pict_type
Picture type of the frame.
int width
picture width / height.
static void error(const char *err)
Libavcodec external API header.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
main external API structure.
static const AVClass librsvg_decoder_class
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
Describe the class of an AVClass context structure.
static const AVOption options[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
common internal api header.
AVCodec ff_librsvg_decoder
#define AV_CODEC_CAP_LOSSLESS
Codec is lossless.
static int librsvg_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *pkt)
int key_frame
1 -> keyframe, 0-> not
This structure stores compressed data.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.