#include "avcodec.h"
#include "get_bits.h"
#include "bytestream.h"
+#include "internal.h"
#include "libavutil/colorspace.h"
#define DVBSUB_PAGE_SEGMENT 0x10
#define cm (ff_crop_tab + MAX_NEG_CROP)
-#ifdef DEBUG
-#if 0
-static void png_save(const char *filename, uint8_t *bitmap, int w, int h,
- uint32_t *rgba_palette)
-{
- int x, y, v;
- FILE *f;
- char fname[40], fname2[40];
- char command[1024];
-
- snprintf(fname, 40, "%s.ppm", filename);
-
- f = fopen(fname, "w");
- if (!f) {
- perror(fname);
- return;
- }
- fprintf(f, "P6\n"
- "%d %d\n"
- "%d\n",
- w, h, 255);
- for(y = 0; y < h; y++) {
- for(x = 0; x < w; x++) {
- v = rgba_palette[bitmap[y * w + x]];
- putc((v >> 16) & 0xff, f);
- putc((v >> 8) & 0xff, f);
- putc((v >> 0) & 0xff, f);
- }
- }
- fclose(f);
-
-
- snprintf(fname2, 40, "%s-a.pgm", filename);
-
- f = fopen(fname2, "w");
- if (!f) {
- perror(fname2);
- return;
- }
- fprintf(f, "P5\n"
- "%d %d\n"
- "%d\n",
- w, h, 255);
- for(y = 0; y < h; y++) {
- for(x = 0; x < w; x++) {
- v = rgba_palette[bitmap[y * w + x]];
- putc((v >> 24) & 0xff, f);
- }
- }
- fclose(f);
-
- snprintf(command, 1024, "pnmtopng -alpha %s %s > %s.png 2> /dev/null", fname2, fname, filename);
- system(command);
-
- snprintf(command, 1024, "rm %s %s", fname, fname2);
- system(command);
-}
-#endif
-
-static void png_save2(const char *filename, uint32_t *bitmap, int w, int h)
-{
- int x, y, v;
- FILE *f;
- char fname[40], fname2[40];
- char command[1024];
-
- snprintf(fname, sizeof(fname), "%s.ppm", filename);
-
- f = fopen(fname, "w");
- if (!f) {
- perror(fname);
- return;
- }
- fprintf(f, "P6\n"
- "%d %d\n"
- "%d\n",
- w, h, 255);
- for(y = 0; y < h; y++) {
- for(x = 0; x < w; x++) {
- v = bitmap[y * w + x];
- putc((v >> 16) & 0xff, f);
- putc((v >> 8) & 0xff, f);
- putc((v >> 0) & 0xff, f);
- }
- }
- fclose(f);
-
-
- snprintf(fname2, sizeof(fname2), "%s-a.pgm", filename);
-
- f = fopen(fname2, "w");
- if (!f) {
- perror(fname2);
- return;
- }
- fprintf(f, "P5\n"
- "%d %d\n"
- "%d\n",
- w, h, 255);
- for(y = 0; y < h; y++) {
- for(x = 0; x < w; x++) {
- v = bitmap[y * w + x];
- putc((v >> 24) & 0xff, f);
- }
- }
- fclose(f);
-
- snprintf(command, sizeof(command), "pnmtopng -alpha %s %s > %s.png 2> /dev/null", fname2, fname, filename);
- system(command);
-
- snprintf(command, sizeof(command), "rm %s %s", fname, fname2);
- system(command);
-}
-#endif
-
#define RGBA(r,g,b,a) (((unsigned)(a) << 24) | ((r) << 16) | ((g) << 8) | (b))
typedef struct DVBSubCLUT {
/* Should already be null */
if (ctx->object_list)
- av_log(0, AV_LOG_ERROR, "Memory deallocation error!\n");
+ av_log(NULL, AV_LOG_ERROR, "Memory deallocation error!\n");
}
static av_cold int dvbsub_init_decoder(AVCodecContext *avctx)
}
if (get_bits(&gb, 6))
- av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n");
+ av_log(NULL, AV_LOG_ERROR, "DVBSub error: line overflow\n");
(*srcbuf) += (get_bits_count(&gb) + 7) >> 3;
}
if (get_bits(&gb, 8))
- av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n");
+ av_log(NULL, AV_LOG_ERROR, "DVBSub error: line overflow\n");
(*srcbuf) += (get_bits_count(&gb) + 7) >> 3;
}
if (*(*srcbuf)++)
- av_log(0, AV_LOG_ERROR, "DVBSub error: line overflow\n");
+ av_log(NULL, AV_LOG_ERROR, "DVBSub error: line overflow\n");
return pixels_read;
}
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
uint8_t *map_table;
- av_dlog(avctx, "DVB pixel block size %d, %s field:\n", buf_size,
+ ff_dlog(avctx, "DVB pixel block size %d, %s field:\n", buf_size,
top_bottom ? "bottom" : "top");
for (i = 0; i < buf_size; i++) {
if (i % 16 == 0)
- av_dlog(avctx, "0x%8p: ", buf+i);
+ ff_dlog(avctx, "0x%8p: ", buf+i);
- av_dlog(avctx, "%02x ", buf[i]);
+ ff_dlog(avctx, "%02x ", buf[i]);
if (i % 16 == 15)
- av_dlog(avctx, "\n");
+ ff_dlog(avctx, "\n");
}
if (i % 16)
- av_dlog(avctx, "\n");
+ ff_dlog(avctx, "\n");
if (region == 0)
return;
int y, cr, cb, alpha;
int r, g, b, r_add, g_add, b_add;
- av_dlog(avctx, "DVB clut packet:\n");
+ ff_dlog(avctx, "DVB clut packet:\n");
for (i=0; i < buf_size; i++) {
- av_dlog(avctx, "%02x ", buf[i]);
+ ff_dlog(avctx, "%02x ", buf[i]);
if (i % 16 == 15)
- av_dlog(avctx, "\n");
+ ff_dlog(avctx, "\n");
}
if (i % 16)
- av_dlog(avctx, "\n");
+ ff_dlog(avctx, "\n");
clut_id = *buf++;
buf += 1;
YUV_TO_RGB1_CCIR(cb, cr);
YUV_TO_RGB2_CCIR(r, g, b, y);
- av_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha);
+ ff_dlog(avctx, "clut %d := (%d,%d,%d,%d)\n", entry_id, r, g, b, alpha);
if (depth & 0x80)
clut->clut4[entry_id] = RGBA(r,g,b,255 - alpha);
region->bgcolor = (((*buf++) >> 2) & 3);
}
- av_dlog(avctx, "Region %d, (%dx%d)\n", region_id, region->width, region->height);
+ ff_dlog(avctx, "Region %d, (%dx%d)\n", region_id, region->width, region->height);
if (fill) {
memset(region->pbuf, region->bgcolor, region->buf_size);
- av_dlog(avctx, "Fill region (%d)\n", region->bgcolor);
+ ff_dlog(avctx, "Fill region (%d)\n", region->bgcolor);
}
delete_region_display_list(ctx, region);
ctx->time_out = *buf++;
page_state = ((*buf++) >> 2) & 3;
- av_dlog(avctx, "Page time out %ds, state %d\n", ctx->time_out, page_state);
+ ff_dlog(avctx, "Page time out %ds, state %d\n", ctx->time_out, page_state);
if (page_state == 2) {
delete_state(ctx);
ctx->display_list = display;
ctx->display_list_size++;
- av_dlog(avctx, "Region %d, (%d,%d)\n", region_id, display->x_pos, display->y_pos);
+ ff_dlog(avctx, "Region %d, (%d,%d)\n", region_id, display->x_pos, display->y_pos);
}
while (tmp_display_list) {
#ifdef DEBUG
-static void save_display_set(DVBSubContext *ctx)
+static void png_save(const char *filename, uint32_t *bitmap, int w, int h)
+{
+ int x, y, v;
+ FILE *f;
+ char fname[40], fname2[40];
+ char command[1024];
+
+ snprintf(fname, sizeof(fname), "%s.ppm", filename);
+
+ f = fopen(fname, "w");
+ if (!f) {
+ perror(fname);
+ return;
+ }
+ fprintf(f, "P6\n"
+ "%d %d\n"
+ "%d\n",
+ w, h, 255);
+ for(y = 0; y < h; y++) {
+ for(x = 0; x < w; x++) {
+ v = bitmap[y * w + x];
+ putc((v >> 16) & 0xff, f);
+ putc((v >> 8) & 0xff, f);
+ putc((v >> 0) & 0xff, f);
+ }
+ }
+ fclose(f);
+
+
+ snprintf(fname2, sizeof(fname2), "%s-a.pgm", filename);
+
+ f = fopen(fname2, "w");
+ if (!f) {
+ perror(fname2);
+ return;
+ }
+ fprintf(f, "P5\n"
+ "%d %d\n"
+ "%d\n",
+ w, h, 255);
+ for(y = 0; y < h; y++) {
+ for(x = 0; x < w; x++) {
+ v = bitmap[y * w + x];
+ putc((v >> 24) & 0xff, f);
+ }
+ }
+ fclose(f);
+
+ snprintf(command, sizeof(command), "pnmtopng -alpha %s %s > %s.png 2> /dev/null", fname2, fname, filename);
+ if (system(command) != 0) {
+ printf("Error running pnmtopng\n");
+ return;
+ }
+
+ snprintf(command, sizeof(command), "rm %s %s", fname, fname2);
+ if (system(command) != 0) {
+ printf("Error removing %s and %s\n", fname, fname2);
+ return;
+ }
+}
+
+static int save_display_set(DVBSubContext *ctx)
{
DVBSubRegion *region;
DVBSubRegionDisplay *display;
snprintf(filename, sizeof(filename), "dvbs.%d", fileno_index);
- png_save2(filename, pbuf, width, height);
+ png_save(filename, pbuf, width, height);
av_free(pbuf);
}
fileno_index++;
+ return 0;
}
-#endif
+#endif /* DEBUG */
static int dvbsub_parse_display_definition_segment(AVCodecContext *avctx,
const uint8_t *buf,
rect->h = region->height;
rect->nb_colors = 16;
rect->type = SUBTITLE_BITMAP;
- rect->pict.linesize[0] = region->width;
+ rect->linesize[0] = region->width;
clut = get_clut(ctx, region->clut);
break;
}
- rect->pict.data[1] = av_mallocz(AVPALETTE_SIZE);
- if (!rect->pict.data[1]) {
+ rect->data[1] = av_mallocz(AVPALETTE_SIZE);
+ if (!rect->data[1]) {
av_free(sub->rects);
return AVERROR(ENOMEM);
}
- memcpy(rect->pict.data[1], clut_table, (1 << region->depth) * sizeof(uint32_t));
+ memcpy(rect->data[1], clut_table, (1 << region->depth) * sizeof(uint32_t));
- rect->pict.data[0] = av_malloc(region->buf_size);
- if (!rect->pict.data[0]) {
- av_free(rect->pict.data[1]);
+ rect->data[0] = av_malloc(region->buf_size);
+ if (!rect->data[0]) {
+ av_free(rect->data[1]);
av_free(sub->rects);
return AVERROR(ENOMEM);
}
- memcpy(rect->pict.data[0], region->pbuf, region->buf_size);
+ memcpy(rect->data[0], region->pbuf, region->buf_size);
+
+#if FF_API_AVPICTURE
+FF_DISABLE_DEPRECATION_WARNINGS
+{
+ int j;
+ for (j = 0; j < 4; j++) {
+ rect->pict.data[j] = rect->data[j];
+ rect->pict.linesize[j] = rect->linesize[j];
+ }
+}
+FF_ENABLE_DEPRECATION_WARNINGS
+#endif
i++;
}
int segment_length;
int i;
- av_dlog(avctx, "DVB sub packet:\n");
+ ff_dlog(avctx, "DVB sub packet:\n");
for (i=0; i < buf_size; i++) {
- av_dlog(avctx, "%02x ", buf[i]);
+ ff_dlog(avctx, "%02x ", buf[i]);
if (i % 16 == 15)
- av_dlog(avctx, "\n");
+ ff_dlog(avctx, "\n");
}
if (i % 16)
- av_dlog(avctx, "\n");
+ ff_dlog(avctx, "\n");
if (buf_size <= 6 || *buf != 0x0f) {
- av_dlog(avctx, "incomplete or broken packet");
+ ff_dlog(avctx, "incomplete or broken packet");
return AVERROR_INVALIDDATA;
}
p += 2;
if (p_end - p < segment_length) {
- av_dlog(avctx, "incomplete or broken packet");
+ ff_dlog(avctx, "incomplete or broken packet");
return -1;
}
*data_size = ret;
break;
default:
- av_dlog(avctx, "Subtitling segment type 0x%x, page id %d, length %d\n",
+ ff_dlog(avctx, "Subtitling segment type 0x%x, page id %d, length %d\n",
segment_type, page_id, segment_length);
break;
}