mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-01-09 10:45:27 +00:00
libcaption: implement eia608_to_text
This commit is contained in:
parent
a7180e3995
commit
6267e00c20
3 changed files with 38 additions and 8 deletions
|
@ -23,6 +23,7 @@
|
|||
/**********************************************************************************************/
|
||||
#include "eia608.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -231,14 +232,16 @@ eia608_from_utf8_2 (const utf8_char_t * c1, const utf8_char_t * c2)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void
|
||||
eia608_dump (uint16_t cc_data)
|
||||
|
||||
int
|
||||
eia608_to_text (char *buf, ssize_t size, uint16_t cc_data)
|
||||
{
|
||||
eia608_style_t style;
|
||||
const char *text = 0;
|
||||
char char1[5], char2[5];
|
||||
char1[0] = char2[0] = 0;
|
||||
int row, col, chan, underline;
|
||||
int ret;
|
||||
|
||||
if (!eia608_parity_varify (cc_data)) {
|
||||
text = "parity failed";
|
||||
|
@ -260,11 +263,9 @@ eia608_dump (uint16_t cc_data)
|
|||
} else if (eia608_is_norpak (cc_data)) {
|
||||
text = "norpak";
|
||||
} else if (eia608_is_preamble (cc_data)) {
|
||||
text = "preamble";
|
||||
eia608_parse_preamble (cc_data, &row, &col, &style, &chan, &underline);
|
||||
fprintf (stderr, "preamble %d %d %d %d %d\n", row, col, style, chan,
|
||||
underline);
|
||||
|
||||
ret = snprintf(buf, size, "cc %04X (%04X) '%s' '%s' (preamble: row: %d col: %d style: %d chan: %d underline: %d)",
|
||||
cc_data, eia608_parity_strip (cc_data), char1, char2, row, col, style, chan, underline);
|
||||
} else if (eia608_is_control (cc_data)) {
|
||||
switch (eia608_parse_control (cc_data, &chan)) {
|
||||
|
||||
|
@ -352,6 +353,23 @@ eia608_dump (uint16_t cc_data)
|
|||
text = "unhandled";
|
||||
}
|
||||
|
||||
fprintf (stderr, "cc %04X (%04X) '%s' '%s' (%s)\n", cc_data,
|
||||
eia608_parity_strip (cc_data), char1, char2, text);
|
||||
if (text != 0) {
|
||||
ret = snprintf (buf, size, "cc %04X (%04X) '%s' '%s' (%s)", cc_data, eia608_parity_strip (cc_data), char1, char2, text);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
eia608_dump (uint16_t cc_data)
|
||||
{
|
||||
char *text = NULL;
|
||||
int bufsz;
|
||||
|
||||
bufsz = eia608_to_text (NULL, 0, cc_data);
|
||||
text = malloc(bufsz + 1);
|
||||
eia608_to_text (text, bufsz + 1, cc_data);
|
||||
fprintf (stderr, "%s\n", text);
|
||||
|
||||
free (text);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include "eia608_charmap.h"
|
||||
#include "utf8.h"
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -201,6 +202,10 @@ int eia608_to_utf8(uint16_t c, int* chan, utf8_char_t* char1, utf8_char_t* char2
|
|||
\param
|
||||
*/
|
||||
void eia608_dump(uint16_t cc_data);
|
||||
/*! \brief
|
||||
\param
|
||||
*/
|
||||
int eia608_to_text (char *buf, ssize_t size, uint16_t cc_data);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -712,6 +712,13 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn eia608_dump(cc_data: u16);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn eia608_to_text(
|
||||
buf: *mut ::std::os::raw::c_char,
|
||||
s: usize,
|
||||
cc_data: u16,
|
||||
) -> ::std::os::raw::c_int;
|
||||
}
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct xds_t {
|
||||
|
|
Loading…
Reference in a new issue