<div dir="ltr"><div><br></div><div><br></div><div>Author: greeshmab <<a href="mailto:greeshmabalabadra@gmail.com">greeshmabalabadra@gmail.com</a>>  2015-03-24 10:27:46</div><div>Committer: greeshmab <<a href="mailto:greeshmabalabadra@gmail.com">greeshmabalabadra@gmail.com</a>>  2015-03-24 10:27:46</div><div>Parent: 039c69d648bd9bb481fbd29868b8565952098d70 (demux: avi: improve broken index offset heuristic (fix #14120))</div><div>Branch: master</div><div>Follows: </div><div>Precedes: </div><div><br></div><div>    Added basic features of CIA-708 from wiki page</div><div><br></div><div>------------------------------ modules/codec/cc.c ------------------------------</div><div>index 91e35ee..89754f6 100644</div><div>@@ -1132,3 +1132,253 @@ static char *Eia608Text( eia608_t *h, bool b_html )</div><div>         Eia608Strlcat( psz, "</text>", i_size );</div><div>     return psz;</div><div> }</div><div>+</div><div>+ </div><div>+ </div><div>+</div><div>+//Based on the Eia708 Wikipedia page</div><div>+//For SetPenAttributes function, Code is based on CCExtractor code</div><div>+</div><div>+enum eia708_Caption_Commands{</div><div>+    ETX = 0x03,  //EndOfText</div><div>+    CW0 = 0x80,  //SetCurrentWindow0–7</div><div>+    CW1 = 0x81,</div><div>+    CW2 = 0x82,</div><div>+    CW3 = 0x83,</div><div>+    CW4 = 0x84,</div><div>+    CW5 = 0x85,</div><div>+    CW6 = 0x86,</div><div>+    CW7 = 0x87,</div><div>+    CLW = 0x88,  //ClearWindows</div><div>+    DSW = 0x89,  //DisplayWindows</div><div>+    HDW = 0x8A,  //HideWindows</div><div>+    TGW = 0x8B,  //ToggleWindows</div><div>+    DLW = 0x8C,  //DeleteWindows</div><div>+    DLY = 0x8D,  //Delay</div><div>+    DLC = 0x8E,  //DelayCancel</div><div>+    RST = 0x8F,  //Reset    </div><div>+    SPA = 0x90,  //SetPenAttributes</div><div>+    SPC = 0x91,  //SetPenColor </div><div>+    SPL = 0x92,  //SetPenLocation </div><div>+    SWA = 0x97,</div><div>+    DF0 = 0x98,  //DefineWindow0–7</div><div>+    DF1 = 0x99,</div><div>+    DF2=0x9A,</div><div>+    DF3=0x9B,</div><div>+    DF4=0x9C,</div><div>+    DF5=0x9D,</div><div>+    DF6=0x9E,</div><div>+    DF7=0x9F     //  priority, anchor number, anchor vertical, anchor horizontal, row count, column count, locked, visible, centered, style ID</div><div>+};</div><div>+</div><div>+/*The SetPenAttributes command specifies how certain attributes of subsequent </div><div>+characters are to be rendered in the current window, until the next SetPenAttributes command</div><div>+*/</div><div>+</div><div>+enum eia708_PenAttribs_Size{</div><div>+    penSize_Small = 0,</div><div>+    penSize_Standard = 1,</div><div>+    penSize_Large = 2,</div><div>+    penSize_IllegalVal = 3</div><div>+};</div><div>+</div><div>+enum eia708_PenAttribs_Offset{</div><div>+    PenOffset_Subscript = 0,</div><div>+    PenOffset_Normal = 1,</div><div>+    PenOffset_Superscript = 2,</div><div>+    PenOffset_IllegalVal = 3</div><div>+};</div><div>+</div><div>+enum eia708_PenAttribs_TextTag{</div><div>+    PenTextTag_Dialog=0,</div><div>+    PenTextTag_Source_or_speaker_id=1,</div><div>+    PenTextTag_Electronically_reproduced_voice=2,</div><div>+    PenTextTag_Dialog_in_other_language=3,</div><div>+    PenTextTag_Voiceover=4,</div><div>+    PenTextTag_Audible_translation=5,</div><div>+    PenTextTag_Subtitle_translation=6,</div><div>+    PenTextTag_Voice_quality_description=7,</div><div>+    PenTextTag_Song_lyrics=8,</div><div>+    PenTextTag_Sound_effect_description=9,</div><div>+    PenTextTag_Musical_score_description=10,</div><div>+    PenTextTag_Oath=11,</div><div>+    PenTextTag_Undefined_0=12,</div><div>+    PenTextTag_Undefined_1=13,</div><div>+    PenTextTag_Undefined_2=14,</div><div>+    PenTextTag_Invisible=15 </div><div>+};</div><div>+</div><div>+enum eia708_PenAttribs_FontTag{</div><div>+    PenFontTag_Default=0, </div><div>+    PenFontTag_Monospaced_serif=1,</div><div>+    PenFontTag_Proportional_serif=2,</div><div>+    PenFontTag_Monospaced_sanserif=3,</div><div>+    PenFontTag_Proportional_sanserif=4,</div><div>+    PenFontTag_Casual=5,</div><div>+    PenFontTag_Cursive=6,</div><div>+    PenFontTag_Smallcaps=7</div><div>+};</div><div>+</div><div>+enum eia708_PenAttribs_EdgeType{</div><div>+    PenEdgeType_None=0,</div><div>+    PenEdgeType_Raised=1,</div><div>+    PenEdgeType_Depressed=2,</div><div>+    PenEdgeType_Uniform=3,</div><div>+    PenEdgeType_Left_drop_shadow=4,</div><div>+    PenEdgeType_Right_drop_shadow=5,</div><div>+    PenEdgeType_Illegal_val0=6,</div><div>+    PenEdgeType_Illegal_val1=7</div><div>+};</div><div>+</div><div>+enum eia708_PenAttribs_Underline{</div><div>+    PenUnderLine_No = 0,</div><div>+    PenUnderline_Yes = 1</div><div>+};</div><div>+</div><div>+enum eia708_PenAttribs_Italic{</div><div>+    PenItalic_No = 0,</div><div>+    PenItalic_Yes = 1</div><div>+};</div><div>+</div><div>+enum eia708_PenColor_Opacity{</div><div>+    PenOpacity_SOLID=0,</div><div>+    PenOpacity_FLASH=1,</div><div>+    PenOpacity_TRANSLUCENT=2,</div><div>+    PenOpacity_TRANSPARENT=3</div><div>+};</div><div>+</div><div>+typedef struct eia708_PenColor</div><div>+{</div><div>+    int fg_color;</div><div>+    int fg_opacity;</div><div>+    int bg_color;</div><div>+    int bg_opacity;</div><div>+    int edge_color;</div><div>+} eia708_PenColor;</div><div>+</div><div>+typedef struct eia708_PenAttribs</div><div>+{</div><div>+    int PenSize;</div><div>+    int Offset;</div><div>+    int TextTag;</div><div>+    int FontTag;</div><div>+    int EdgeType;</div><div>+    int UnderLine;</div><div>+    int Italic;</div><div>+} eia708_PenAttribs;</div><div>+</div><div>+enum eia708_WindowAttribs_Justify{</div><div>+    WindowJustify_LEFT=0, </div><div>+    WindowJustify_RIGHT=1,</div><div>+    WindowJustify_CENTER=2,</div><div>+    WindowJustify_FULL=3</div><div>+};</div><div>+</div><div>+enum eia708_WindowAttribs_AnchorID{</div><div>+    WindowAnchorID_UPPER_LEFT=0,</div><div>+    WindowAnchorID_UPPER_CENTER=1,</div><div>+    WindowAnchorID_UPPER_RIGHT=2,</div><div>+    WindowAnchorID_MIDDLE_LEFT=3,</div><div>+    WindowAnchorID_MIDDLE_CENTER=4,</div><div>+    WindowAnchorID_MIDDLE_RIGHT=5,</div><div>+    WindowAnchorID_LOWER_LEFT=6,</div><div>+    WindowAnchorID_LOWER_CENTER=7,</div><div>+    WindowAnchorID_LOWER_RIGHT=8 </div><div>+};</div><div>+</div><div>+typedef struct eia708_WindowAttribs</div><div>+{</div><div>+    int fill_color;</div><div>+    int fill_opacity;</div><div>+    int border_color;</div><div>+    int border_type01;</div><div>+    int justify;</div><div>+    int scroll_dir;</div><div>+    int print_dir;</div><div>+    int word_wrap;</div><div>+    int border_type;</div><div>+    int display_eff;</div><div>+    int effect_dir;</div><div>+    int effect_speed;</div><div>+} eia708_WindowAttribs;</div><div>+</div><div>+</div><div>+typedef struct eia708_window</div><div>+{</div><div>+    int is_defined;</div><div>+    int number; // Handy, in case we only have a pointer to the window</div><div>+    int priority;</div><div>+    int col_lock;</div><div>+    int row_lock;</div><div>+    int visible;</div><div>+    int null;</div><div>+    int anchor_vertical;</div><div>+    int relative_pos;</div><div>+    int anchor_horizontal;</div><div>+    int row_count;</div><div>+    int anchor_ID;</div><div>+    int col_count;</div><div>+    int pen_style;</div><div>+    int win_style;</div><div>+    uint8_t Window_commands[8]; // Commands used to create this window </div><div>+    eia708_WindowAttribs attribs;  // SetWindowAttributes, SetPenAttributes, SetPenColor, </div><div>+    eia708_PenAttribs pen;</div><div>+    eia708_PenColor PenColor;</div><div>+    int pen_row;     //Pen Location for SetPenLocation</div><div>+    int pen_column;</div><div>+} eia708_window;</div><div>+</div><div>+//Couldn't figure out the structure of eia708 service packet/block.</div><div>+</div><div>+typedef struct{</div><div>+    eia708_window windows[10];</div><div>+    int current_window;</div><div>+}eia708_t;</div><div>+</div><div>+static void eia708_SetPenAttributes (eia708_t *service, uint8_t *data)</div><div>+{</div><div>+    //based on ccextractor code</div><div>+    if (service->current_window==-1)</div><div>+    {</div><div>+        // Handle by creating window</div><div>+        return;</div><div>+    }</div><div>+</div><div>+    service->windows[service->current_window].pen.PenSize   = (data[1]) & 0x3;</div><div>+    service->windows[service->current_window].pen.Offset    = (data[1]>>2) & 0x3;</div><div>+    service->windows[service->current_window].pen.TextTag   = (data[1]>>4) & 0xf;</div><div>+    service->windows[service->current_window].pen.FontTag   = (data[2]) & 0x7;</div><div>+    service->windows[service->current_window].pen.EdgeType  = (data[2]>>3) & 0x7;</div><div>+    service->windows[service->current_window].pen.UnderLine = (data[2]>>4) & 0x1;</div><div>+    service->windows[service->current_window].pen.Italic    = (data[2]>>5) & 0x1;</div><div>+}</div><div>+</div><div>+</div><div>+static void eia708_SetPenColor (eia708_t *service, uint8_t *data)</div><div>+{</div><div>+</div><div>+    if (service->current_window==-1)</div><div>+    {</div><div>+        // Handle by creating window</div><div>+        return;</div><div>+    }</div><div>+    service->windows[service->current_window].PenColor.fg_color   = (data[1]) & 0x3f;</div><div>+    service->windows[service->current_window].PenColor.fg_opacity = (data[1]>>6) & 0x03;</div><div>+    service->windows[service->current_window].PenColor.bg_color   = (data[2]   ) & 0x3f;</div><div>+    service->windows[service->current_window].PenColor.bg_opacity = (data[2]>>6) & 0x03;</div><div>+    service->windows[service->current_window].PenColor.edge_color = (data[3]>>6) & 0x3f;</div><div>+}</div><div>+</div><div>+static void eia708_SetPenLocation (eia708_t *service, uint8_t *data)</div><div>+{</div><div>+    if (service->current_window==-1)</div><div>+    { </div><div>+        // Handle by creating window</div><div>+        return;</div><div>+    }</div><div>+    service->windows[service->current_window].pen_row    = data[1] & 0x0f;</div><div>+    service->windows[service->current_window].pen_column = data[2] & 0x3f;</div><div>+}</div><div>+</div><div>+</div><div>+</div><div><br></div><div><div class="gmail_signature"><div dir="ltr"><div><div><div><span style="color:rgb(7,55,99)"><font><span style="font-family:arial,helvetica,sans-serif"><span></span><a></a><span></span>Greeshma</span></font></span></div></div></div></div></div></div>
</div>