ret = AVERROR(ENOMEM);
goto fail;
}
- memcpy(rect->data[1], clut_table, (1 << region->depth) * sizeof(uint32_t));
+ memcpy(rect->data[1], clut_table, (1 << region->depth) * sizeof(*clut_table));
rect->data[0] = av_malloc(region->buf_size);
if (!rect->data[0]) {
clut = get_clut(ctx, clut_id);
if (!clut) {
- clut = av_malloc(sizeof(DVBSubCLUT));
+ clut = av_malloc(sizeof(*clut));
if (!clut)
return AVERROR(ENOMEM);
- memcpy(clut, &default_clut, sizeof(DVBSubCLUT));
+ memcpy(clut, &default_clut, sizeof(*clut));
clut->id = clut_id;
clut->version = -1;
region = get_region(ctx, region_id);
if (!region) {
- region = av_mallocz(sizeof(DVBSubRegion));
+ region = av_mallocz(sizeof(*region));
if (!region)
return AVERROR(ENOMEM);
object = get_object(ctx, object_id);
if (!object) {
- object = av_mallocz(sizeof(DVBSubObject));
+ object = av_mallocz(sizeof(*object));
if (!object)
return AVERROR(ENOMEM);
object->type = (*buf) >> 6;
- display = av_mallocz(sizeof(DVBSubObjectDisplay));
+ display = av_mallocz(sizeof(*display));
if (!display)
return AVERROR(ENOMEM);
}
if (!display) {
- display = av_mallocz(sizeof(DVBSubRegionDisplay));
+ display = av_mallocz(sizeof(*display));
if (!display)
return AVERROR(ENOMEM);
}
display_def->width = bytestream_get_be16(&buf) + 1;
display_def->height = bytestream_get_be16(&buf) + 1;
if (!avctx->width || !avctx->height) {
- avctx->width = display_def->width;
- avctx->height = display_def->height;
+ int ret = ff_set_dimensions(avctx, display_def->width, display_def->height);
+ if (ret < 0)
+ return ret;
}
if (info_byte & 1<<3) { // display_window_flag
}
static int dvbsub_decode(AVCodecContext *avctx,
- void *data, int *data_size,
+ void *data, int *got_sub_ptr,
AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int ret = 0;
switch (segment_type) {
case DVBSUB_PAGE_SEGMENT:
- ret = dvbsub_parse_page_segment(avctx, p, segment_length, sub, data_size);
+ ret = dvbsub_parse_page_segment(avctx, p, segment_length, sub, got_sub_ptr);
got_segment |= 1;
break;
case DVBSUB_REGION_SEGMENT:
got_dds = 1;
break;
case DVBSUB_DISPLAY_SEGMENT:
- ret = dvbsub_display_end_segment(avctx, p, segment_length, sub, data_size);
+ ret = dvbsub_display_end_segment(avctx, p, segment_length, sub, got_sub_ptr);
if (got_segment == 15 && !got_dds && !avctx->width && !avctx->height) {
// Default from ETSI EN 300 743 V1.3.1 (7.2.1)
avctx->width = 720;
// segments then we need no further data.
if (got_segment == 15) {
av_log(avctx, AV_LOG_DEBUG, "Missing display_end_segment, emulating\n");
- dvbsub_display_end_segment(avctx, p, 0, sub, data_size);
+ dvbsub_display_end_segment(avctx, p, 0, sub, got_sub_ptr);
}
end:
if(ret < 0) {
- *data_size = 0;
+ *got_sub_ptr = 0;
avsubtitle_free(sub);
return ret;
} else {
}
#define DS AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_SUBTITLE_PARAM
+#define OFFSET(x) offsetof(DVBSubContext, x)
static const AVOption options[] = {
- {"compute_edt", "compute end of time using pts or timeout", offsetof(DVBSubContext, compute_edt), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DS},
- {"compute_clut", "compute clut when not available(-1) or always(1) or never(0)", offsetof(DVBSubContext, compute_clut), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, DS},
- {"dvb_substream", "", offsetof(DVBSubContext, substream), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, DS},
+ {"compute_edt", "compute end of time using pts or timeout", OFFSET(compute_edt), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DS},
+ {"compute_clut", "compute clut when not available(-1) or always(1) or never(0)", OFFSET(compute_clut), AV_OPT_TYPE_BOOL, {.i64 = -1}, -1, 1, DS},
+ {"dvb_substream", "", OFFSET(substream), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 63, DS},
{NULL}
};
static const AVClass dvbsubdec_class = {