changeset 32457:f4822d5572f5

Move av_sub.[ch] to the sub directory.
author cigaes
date Wed, 27 Oct 2010 16:42:23 +0000
parents 728bd5c2aea7
children ab8fb38f28b1
files Makefile av_sub.c av_sub.h mpcommon.c sub/av_sub.c sub/av_sub.h
diffstat 6 files changed, 149 insertions(+), 149 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Wed Oct 27 16:38:51 2010 +0000
+++ b/Makefile	Wed Oct 27 16:42:23 2010 +0000
@@ -99,7 +99,6 @@
 
 SRCS_COMMON-$(FASTMEMCPY)            += libvo/aclib.c
 SRCS_COMMON-$(FFMPEG)                += av_opts.c                   \
-                                        av_sub.c                    \
                                         libaf/af_lavcresample.c     \
                                         libmpcodecs/ad_ffmpeg.c     \
                                         libmpcodecs/vd_ffmpeg.c     \
@@ -109,6 +108,7 @@
                                         libmpcodecs/vf_screenshot.c \
                                         libmpdemux/demux_lavf.c     \
                                         stream/stream_ffmpeg.c      \
+                                        sub/av_sub.c                \
 
 # These filters use private headers and do not work with shared FFmpeg.
 SRCS_COMMON-$(FFMPEG_A)              += libaf/af_lavcac3enc.c    \
--- a/av_sub.c	Wed Oct 27 16:38:51 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include "libavcodec/avcodec.h"
-#include "libmpdemux/stheader.h"
-#include "libvo/sub.h"
-#include "sub/spudec.h"
-#include "av_sub.h"
-
-void reset_avsub(struct sh_sub *sh)
-{
-    if (sh->context) {
-        avcodec_close(sh->context);
-        av_freep(&sh->context);
-    }
-}
-
-/**
- * Decode a subtitle packet via libavcodec.
- * \return < 0 on error, > 0 if further processing is needed
- */
-int decode_avsub(struct sh_sub *sh, uint8_t **data, int *size,
-                 double *pts, double *endpts)
-{
-    AVCodecContext *ctx = sh->context;
-    enum CodecID cid = CODEC_ID_NONE;
-    int new_type = 0;
-    int res;
-    int got_sub;
-    AVSubtitle sub;
-    AVPacket pkt;
-
-    switch (sh->type) {
-    case 'b':
-        cid = CODEC_ID_DVB_SUBTITLE; break;
-    case 'p':
-        cid = CODEC_ID_HDMV_PGS_SUBTITLE; break;
-    case 'x':
-        cid = CODEC_ID_XSUB; break;
-    }
-
-    av_init_packet(&pkt);
-    pkt.data = *data;
-    pkt.size = *size;
-    pkt.pts = *pts * 1000;
-    if (*pts != MP_NOPTS_VALUE && *endpts != MP_NOPTS_VALUE)
-        pkt.convergence_duration = (*endpts - *pts) * 1000;
-    if (!ctx) {
-        AVCodec *sub_codec;
-        avcodec_init();
-        avcodec_register_all();
-        ctx = avcodec_alloc_context();
-        sub_codec = avcodec_find_decoder(cid);
-        if (!ctx || !sub_codec || avcodec_open(ctx, sub_codec) < 0) {
-            mp_msg(MSGT_SUBREADER, MSGL_FATAL,
-                   "Could not open subtitle decoder\n");
-            av_freep(&ctx);
-            return -1;
-        }
-        sh->context = ctx;
-    }
-    res = avcodec_decode_subtitle2(ctx, &sub, &got_sub, &pkt);
-    if (res < 0)
-        return res;
-    if (*pts != MP_NOPTS_VALUE) {
-        if (sub.end_display_time > sub.start_display_time)
-            *endpts = *pts + sub.end_display_time / 1000.0;
-        *pts += sub.start_display_time / 1000.0;
-    }
-    if (got_sub && sub.num_rects > 0) {
-        switch (sub.rects[0]->type) {
-        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);
-            vo_osd_changed(OSDTYPE_SPU);
-            break;
-        case SUBTITLE_TEXT:
-            *data = strdup(sub.rects[0]->text);
-            *size = strlen(*data);
-            new_type = 't';
-            break;
-        case SUBTITLE_ASS:
-            *data = strdup(sub.rects[0]->ass);
-            *size = strlen(*data);
-            new_type = 'a';
-            break;
-        }
-    }
-    if (got_sub)
-        avsubtitle_free(&sub);
-    return new_type;
-}
--- a/av_sub.h	Wed Oct 27 16:38:51 2010 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifndef MPLAYER_AV_SUB_H
-#define MPLAYER_AV_SUB_H
-
-#include <stdint.h>
-
-struct sh_sub;
-
-void reset_avsub(struct sh_sub *sh);
-int decode_avsub(struct sh_sub *sh, uint8_t **data, int *size,
-                 double *pts, double *endpts);
-
-#endif /* MPLAYER_AV_SUB_H */
--- a/mpcommon.c	Wed Oct 27 16:38:51 2010 +0000
+++ b/mpcommon.c	Wed Oct 27 16:42:23 2010 +0000
@@ -37,7 +37,7 @@
 #include "sub/spudec.h"
 #include "version.h"
 #include "vobsub.h"
-#include "av_sub.h"
+#include "sub/av_sub.h"
 #include "libmpcodecs/dec_teletext.h"
 #include "libavutil/intreadwrite.h"
 #include "m_option.h"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sub/av_sub.c	Wed Oct 27 16:42:23 2010 +0000
@@ -0,0 +1,117 @@
+/*
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "libavcodec/avcodec.h"
+#include "libmpdemux/stheader.h"
+#include "libvo/sub.h"
+#include "sub/spudec.h"
+#include "sub/av_sub.h"
+
+void reset_avsub(struct sh_sub *sh)
+{
+    if (sh->context) {
+        avcodec_close(sh->context);
+        av_freep(&sh->context);
+    }
+}
+
+/**
+ * Decode a subtitle packet via libavcodec.
+ * \return < 0 on error, > 0 if further processing is needed
+ */
+int decode_avsub(struct sh_sub *sh, uint8_t **data, int *size,
+                 double *pts, double *endpts)
+{
+    AVCodecContext *ctx = sh->context;
+    enum CodecID cid = CODEC_ID_NONE;
+    int new_type = 0;
+    int res;
+    int got_sub;
+    AVSubtitle sub;
+    AVPacket pkt;
+
+    switch (sh->type) {
+    case 'b':
+        cid = CODEC_ID_DVB_SUBTITLE; break;
+    case 'p':
+        cid = CODEC_ID_HDMV_PGS_SUBTITLE; break;
+    case 'x':
+        cid = CODEC_ID_XSUB; break;
+    }
+
+    av_init_packet(&pkt);
+    pkt.data = *data;
+    pkt.size = *size;
+    pkt.pts = *pts * 1000;
+    if (*pts != MP_NOPTS_VALUE && *endpts != MP_NOPTS_VALUE)
+        pkt.convergence_duration = (*endpts - *pts) * 1000;
+    if (!ctx) {
+        AVCodec *sub_codec;
+        avcodec_init();
+        avcodec_register_all();
+        ctx = avcodec_alloc_context();
+        sub_codec = avcodec_find_decoder(cid);
+        if (!ctx || !sub_codec || avcodec_open(ctx, sub_codec) < 0) {
+            mp_msg(MSGT_SUBREADER, MSGL_FATAL,
+                   "Could not open subtitle decoder\n");
+            av_freep(&ctx);
+            return -1;
+        }
+        sh->context = ctx;
+    }
+    res = avcodec_decode_subtitle2(ctx, &sub, &got_sub, &pkt);
+    if (res < 0)
+        return res;
+    if (*pts != MP_NOPTS_VALUE) {
+        if (sub.end_display_time > sub.start_display_time)
+            *endpts = *pts + sub.end_display_time / 1000.0;
+        *pts += sub.start_display_time / 1000.0;
+    }
+    if (got_sub && sub.num_rects > 0) {
+        switch (sub.rects[0]->type) {
+        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);
+            vo_osd_changed(OSDTYPE_SPU);
+            break;
+        case SUBTITLE_TEXT:
+            *data = strdup(sub.rects[0]->text);
+            *size = strlen(*data);
+            new_type = 't';
+            break;
+        case SUBTITLE_ASS:
+            *data = strdup(sub.rects[0]->ass);
+            *size = strlen(*data);
+            new_type = 'a';
+            break;
+        }
+    }
+    if (got_sub)
+        avsubtitle_free(&sub);
+    return new_type;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sub/av_sub.h	Wed Oct 27 16:42:23 2010 +0000
@@ -0,0 +1,30 @@
+/*
+ * This file is part of MPlayer.
+ *
+ * MPlayer is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * MPlayer is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with MPlayer; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef MPLAYER_AV_SUB_H
+#define MPLAYER_AV_SUB_H
+
+#include <stdint.h>
+
+struct sh_sub;
+
+void reset_avsub(struct sh_sub *sh);
+int decode_avsub(struct sh_sub *sh, uint8_t **data, int *size,
+                 double *pts, double *endpts);
+
+#endif /* MPLAYER_AV_SUB_H */