aboutsummaryrefslogtreecommitdiffhomepage
path: root/sub/av_sub.c
diff options
context:
space:
mode:
authorGravatar mplayer-svn <svn@mplayerhq.hu>2012-04-22 21:52:39 +0000
committerGravatar wm4 <wm4@nowhere>2012-08-03 03:34:38 +0200
commit0dc290269d925bd3bc7ed63a1b63edc13e8b2ab1 (patch)
tree6b26a34cbfb4b039556b38a5483a71cb9f5abef0 /sub/av_sub.c
parent7e87c0e76a69918296161f77c0cf337650d249c1 (diff)
av_sub, spudec: support multiple rectangles
av_sub: support multiple rectangles. The "packet_t" structure is renamed with a prefix, because it is used a public header. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34872 b3059339-0415-0410-9bf9-f77b7e298cf2 Author: cigaes
Diffstat (limited to 'sub/av_sub.c')
-rw-r--r--sub/av_sub.c52
1 files changed, 42 insertions, 10 deletions
diff --git a/sub/av_sub.c b/sub/av_sub.c
index 3a9e1b4f26..56acfc63ca 100644
--- a/sub/av_sub.c
+++ b/sub/av_sub.c
@@ -32,6 +32,47 @@ void reset_avsub(struct sh_sub *sh)
}
}
+static void avsub_to_spudec(AVSubtitleRect **rects, int num_rects,
+ double pts, double endpts)
+{
+ int i, xmin = INT_MAX, ymin = INT_MAX, xmax = INT_MIN, ymax = INT_MIN;
+ struct spu_packet_t *packet;
+
+ if (num_rects == 1) {
+ spudec_set_paletted(vo_spudec,
+ rects[0]->pict.data[0],
+ rects[0]->pict.linesize[0],
+ rects[0]->pict.data[1],
+ rects[0]->x,
+ rects[0]->y,
+ rects[0]->w,
+ rects[0]->h,
+ pts,
+ endpts);
+ return;
+ }
+ for (i = 0; i < num_rects; i++) {
+ xmin = FFMIN(xmin, rects[i]->x);
+ ymin = FFMIN(ymin, rects[i]->y);
+ xmax = FFMAX(xmax, rects[i]->x + rects[i]->w);
+ ymax = FFMAX(ymax, rects[i]->y + rects[i]->h);
+ }
+ packet = spudec_packet_create(xmin, ymin, xmax - xmin, ymax - ymin);
+ if (!packet)
+ return;
+ spudec_packet_clear(packet);
+ for (i = 0; i < num_rects; i++)
+ spudec_packet_fill(packet,
+ rects[i]->pict.data[0],
+ rects[i]->pict.linesize[0],
+ rects[i]->pict.data[1],
+ rects[i]->x - xmin,
+ rects[i]->y - ymin,
+ rects[i]->w,
+ rects[i]->h);
+ spudec_packet_send(vo_spudec, packet, pts, endpts);
+}
+
/**
* Decode a subtitle packet via libavcodec.
* \return < 0 on error, > 0 if further processing is needed
@@ -96,16 +137,7 @@ int decode_avsub(struct sh_sub *sh, uint8_t *data, int size,
case SUBTITLE_BITMAP:
if (!vo_spudec)
vo_spudec = spudec_new_scaled(NULL, ctx->width, ctx->height, NULL, 0);
- spudec_set_paletted(vo_spudec,
- sub.rects[0]->pict.data[0],
- sub.rects[0]->pict.linesize[0],
- sub.rects[0]->pict.data[1],
- sub.rects[0]->x,
- sub.rects[0]->y,
- sub.rects[0]->w,
- sub.rects[0]->h,
- pts,
- endpts);
+ avsub_to_spudec(sub.rects, sub.num_rects, pts, endpts);
vo_osd_changed(OSDTYPE_SPU);
break;
default: