[vlc-devel] [PATCH] cc.c : Added basic features of CIA-708 to cc.c

greeshma greeshmabalabadra at gmail.com
Thu Mar 26 16:21:03 CET 2015


Greeshma


On Tue, Mar 24, 2015 at 10:06 PM, Francois Cartegnie <fcvlcdev at free.fr>
wrote:

> Le 24/03/2015 15:36, Devin Heitmueller a écrit :
> > - I believe we're currently only feeding the EIA-608 bytes to the cc
> > decoder currently.  If we wanted to support EIA-708, the MPEG2 demux
> > would need to be modified to create additional decoder instances and
> > feed those bytes instead.
>
> Since that's embedded in the MPEG2 stream, that's instanciated by the ES
> when mpegvideo decoders/packetizers are providing p_dec->pf_get_cc.
> That one returning extracted/collected data from the mpeg2 user data.
> Demuxer itself has no knowledge of CC (as opposed to the mp4 demux).
>
> The CC decoder, instanciated from an arbitrary, by channel, fourcc, then
> also gather and decodes.
>
> For 708 support, we need to be able to pass more parameters, either
> through get_cc or additional call.
>
> We also need to collect DTV cc stream at packetizer & mpeg decoder level.
> Currently, cc_types > 2 are skipped. DTV being 3.
>
> > EIA-608 (or the reverse) if both are present?  Do we have some global
> > configuration option which dictates which decoder gets used?
>
> none
>
> > - Adding support for some of these features could exacerbate known
> > performance issues in the existing SPU renderer.  There are some
> > assumptions made with regards to things such as font size and
> > positioning which could cause a significant reduction in compositing
> > performance if we provide more flexibility as allowed by EIA-708.  I
> > can get into more specifics on this in a separate email.
>
> We're already doing this for MP4/tx3g, except positioning.
>
Francois
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>


Hello,

The caption commands are added and few functions are handled accordingly.
Still working on the functions which needs window bitmap.

>From 002db1dde968a73fbcfeda25b2cbf97d3ca6379b Mon Sep 17 00:00:00 2001
From: greeshmab <greeshmabalabadra at gmail.com>
Date: Thu, 26 Mar 2015 20:48:00 +0530
Subject: [PATCH] Caption commands added and functions handled

---
 modules/codec/cc.c | 166
+++++++++++++++++++++++++++++++++++++++++++++++++++--
 modules/codec/cc.h |   8 +++
 2 files changed, 170 insertions(+), 4 deletions(-)

diff --git a/modules/codec/cc.c b/modules/codec/cc.c
index 89754f6..9d5ea1f 100644
--- a/modules/codec/cc.c
+++ b/modules/codec/cc.c
@@ -1328,11 +1328,16 @@ typedef struct eia708_window
     int pen_column;
 } eia708_window;

-//Couldn't figure out the structure of eia708 service packet/block.
-
-typedef struct{
-    eia708_window windows[10];
+typedef struct eia708_t
+{
+    e708Window windows[10];
     int current_window;
+    int inited;
+    tvscreen tv[2]; // Current and previous "screenfuls", note that we
switch between them
+    int cur_tv; // 1 or 2 rather than 0 or 1, to at least be consistent
with the decoder
+    tvscreen *tv; // Pointer to the current TV buffer
+    char *filename; // Where we are going to write our output
+    int fh; // Handle to output file. -1 if not yet open
 }eia708_t;

 static void eia708_SetPenAttributes (eia708_t *service, uint8_t *data)
@@ -1381,4 +1386,157 @@ static void eia708_SetPenLocation (eia708_t
*service, uint8_t *data)
 }


+const char *eia708_Caption_Commands_C0[32]=
+{
+    "NUL", // 0 = NUL
+    NULL,  // 1 = Reserved
+    NULL,  // 2 = Reserved
+    "ETX", // 3 = ETX
+    NULL,  // 4 = Reserved
+    NULL,  // 5 = Reserved
+    NULL,  // 6 = Reserved
+    NULL,  // 7 = Reserved
+    "BS",  // 8 = Backspace
+    NULL,  // 9 = Reserved
+    NULL,  // A = Reserved
+    NULL,  // B = Reserved
+    "FF",  // C = FF
+    "CR",  // D = CR
+    "HCR", // E = HCR
+    NULL,  // F = Reserved
+    "EXT1",// 0x10 = EXT1,
+    NULL,  // 0x11 = Reserved
+    NULL,  // 0x12 = Reserved
+    NULL,  // 0x13 = Reserved
+    NULL,  // 0x14 = Reserved
+    NULL,  // 0x15 = Reserved
+    NULL,  // 0x16 = Reserved
+    NULL,  // 0x17 = Reserved
+    "P16", // 0x18 = P16
+    NULL,  // 0x19 = Reserved
+    NULL,  // 0x1A = Reserved
+    NULL,  // 0x1B = Reserved
+    NULL,  // 0x1C = Reserved
+    NULL,  // 0x1D = Reserved
+    NULL,  // 0x1E = Reserved
+    NULL,  // 0x1F = Reserved
+};
+
+struct eia708_Caption_Commands eia708_C1[28]=
+{
+    {CW0,"CW0","SetCurrentWindow0",     1},
+    {CW1,"CW1","SetCurrentWindow1",     1},
+    {CW2,"CW2","SetCurrentWindow2",     1},
+    {CW3,"CW3","SetCurrentWindow3",     1},
+    {CW4,"CW4","SetCurrentWindow4",     1},
+    {CW5,"CW5","SetCurrentWindow5",     1},
+    {CW6,"CW6","SetCurrentWindow6",     1},
+    {CW7,"CW7","SetCurrentWindow7",     1},
+    {CLW,"CLW","ClearWindows",          2},
+    {DSW,"DSW","DisplayWindows",        2},
+    {HDW,"HDW","HideWindows",           2},
+    {TGW,"TGW","ToggleWindows",         2},
+    {DLW,"DLW","DeleteWindows",         2},
+    {DLY,"DLY","Delay",                 2},
+    {DLC,"DLC","DelayCancel",           1},
+    {RST,"RST","Reset",                 1},
+    {SPA,"SPA","SetPenAttributes",      3},
+    {SPC,"SPC","SetPenColor",           4},
+    {SPL,"SPL","SetPenLocation",        3},
+    {SWA,"SWA","SetWindowAttributes",   5},
+    {DF0,"DF0","DefineWindow0",         7},
+    {DF1,"DF0","DefineWindow1",         7},
+    {DF2,"DF0","DefineWindow2",         7},
+    {DF3,"DF0","DefineWindow3",         7},
+    {DF4,"DF0","DefineWindow4",         7},
+    {DF5,"DF0","DefineWindow5",         7},
+    {DF6,"DF0","DefineWindow6",         7},
+    {DF7,"DF0","DefineWindow7",         7}
+};
+
+void eia708_CW_func_SetCurrentWindow (eia708_t *decoder, int new_window)
+{
+    if (decoder->windows[new_window].is_defined)
+        decoder->current_window=new_window;
+}
+
+void eia708_service_reset(eia708_t *decoder)
+{
+    for (int j=0;j<10;j++)
+    {
+        decoder->windows[j].is_defined=0;
+        decoder->windows[j].visible=0;
+        decoder->windows[j].is_empty=1;
+        memset (decoder->windows[j].commands, 0, sizeof
(decoder->windows[j].commands));
+    }
+    decoder->current_window=-1;
+    //Handle TV Screen
+    decoder->inited=1;
+}

+void eia708_SWA_func_SetWindowAttributes (eia708_t *decoder, uint8_t *data)
+{
+    if (decoder->current_window==-1)
+        return;
+    decoder->windows[decoder->current_window].attribs.fill_color=(data[1]
  ) & 0x3f;
+
 decoder->windows[decoder->current_window].attribs.fill_opacity=(data[1]>>6)
& 0x03;
+
 decoder->windows[decoder->current_window].attribs.border_color=(data[2]
) & 0x3f;
+
 decoder->windows[decoder->current_window].attribs.border_type01=(data[2]>>6)
& 0x03;
+    decoder->windows[decoder->current_window].attribs.justify=(data[3]   )
& 0x03;
+
 decoder->windows[decoder->current_window].attribs.scroll_dir=(data[3]>>2)
& 0x03;
+
 decoder->windows[decoder->current_window].attribs.print_dir=(data[3]>>4) &
0x03;
+
 decoder->windows[decoder->current_window].attribs.word_wrap=(data[3]>>6) &
0x01;
+
 decoder->windows[decoder->current_window].attribs.border_type=(data[3]>>5)
| border_type01;
+    decoder->windows[decoder->current_window].attribs.display_eff=(data[4]
  ) & 0x03;
+
 decoder->windows[decoder->current_window].attribs.effect_dir=(data[4]>>2)
& 0x03;
+
 decoder->windows[decoder->current_window].attribs.effect_speed=(data[4]>>4)
& 0x0f;
+}
+
+// Captioning Commands Control Codes C1
+int eia708_Caption_C1_funcs (eia708_t *decoder, uint8_t *data, int
data_length)
+{
+    struct eia708_Caption_Commands tempCom=eia708_C1[data[0]-0x80];
+
+    switch (com.code)
+    {
+        case CW0: /* SetCurrentWindow */
+        case CW1:
+        case CW2:
+        case CW3:
+        case CW4:
+        case CW5:
+        case CW6:
+        case CW7:
+            eia708_CW_func_SetCurrentWindow (decoder, tempCom.code-CW0);
/* Window 0 to 7 */
+            break;
+        /*
+            other cases i.e CLW,DSW,HDW,DLW,DLY,DLC,TGW deals with windows
bitmap,still working on it
+        */
+        case RST:
+            eia708_service_reset(decoder);
+            break;
+        case SPA:
+            eia708_SetPenAttributes (decoder, data);
+            break;
+        case SPC:
+            eia708_SetPenColor (decoder, data);
+            break;
+        case SPL:
+            heia708_SetPenLocation (decoder, data);
+            break;
+        case SWA:
+            eia708_SWA_func_SetWindowAttributes (decoder, data);
+            break;
+        case DF0:
+        case DF1:
+        case DF2:
+        case DF3:
+        case DF4:
+        case DF5:
+        case DF6:
+        case DF7:
+            //Define window
+            break;
+    }
+    return com.length;
+}
diff --git a/modules/codec/cc.h b/modules/codec/cc.h
index e824780..de2ddfc 100644
--- a/modules/codec/cc.h
+++ b/modules/codec/cc.h
@@ -279,5 +279,13 @@ static inline void cc_Extract( cc_data_t *c, bool
b_top_field_first, const uint8
     }
 }

+struct eia708_Caption_Commands
+{
+    int code;
+    const char *name;
+    const char *description;
+    int length;
+};
+
 #endif /* _CC_H */

-- 
2.1.4
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20150326/6bbe1f25/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Caption-commands-added-and-functions-handled.patch
Type: text/x-patch
Size: 7165 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20150326/6bbe1f25/attachment.bin>


More information about the vlc-devel mailing list