History

avdevice/decklink_dec: extract NTSC VANC

This changes how NTSC VANC is extracted from the buffer. In NTSC the vanc data is interleaved between luma and chroma, and not just the luma as in high definition resolutions. In my testing this allows a decklink card encoding valid NTSC closed captions to pass the caption data to the x264 encoder. Updated with reviews from Devin Heitmueller and Marton Balint.

Ray Tiley committed 8 years ago

Commit c837cd31 parent ce6ce591 file · +20 −3Browse files

Showing the changes to libavdevice/decklink_dec.cpp (1 of 1 file). Show all

Unified · Split

libavdevice/decklink_dec.cpp+20−3
@@ -149,6 +149,17 @@ static void extract_luma_from_v210(uint16_t *dst, const uint8_t *src, int width) · 148 unmodified lines
149 }149 }
150}150}
151 151
152static void unpack_v210(uint16_t *dst, const uint8_t *src, int width)
153{
154 int i;
155 for (i = 0; i < width * 2 / 3; i++) {
156 *dst++ = src[0] + ((src[1] & 3) << 8);
157 *dst++ = (src[1] >> 2) + ((src[2] & 15) << 6);
158 *dst++ = (src[2] >> 4) + ((src[3] & 63) << 4);
159 src += 4;
160 }
161}
162
152static uint8_t calc_parity_and_line_offset(int line)163static uint8_t calc_parity_and_line_offset(int line)
153{164{
154 uint8_t ret = (line < 313) << 5;165 uint8_t ret = (line < 313) << 5;
@@ -752,9 +763,15 @@ HRESULT decklink_input_callback::VideoInputFrameArrived( · 597 unmodified lines
752 for (i = vanc_line_numbers[idx].vanc_start; i <= vanc_line_numbers[idx].vanc_end; i++) {763 for (i = vanc_line_numbers[idx].vanc_start; i <= vanc_line_numbers[idx].vanc_end; i++) {
753 uint8_t *buf;764 uint8_t *buf;
754 if (vanc->GetBufferForVerticalBlankingLine(i, (void**)&buf) == S_OK) {765 if (vanc->GetBufferForVerticalBlankingLine(i, (void**)&buf) == S_OK) {
755 uint16_t luma_vanc[MAX_WIDTH_VANC];766 uint16_t vanc[MAX_WIDTH_VANC];
756 extract_luma_from_v210(luma_vanc, buf, videoFrame->GetWidth());767 size_t vanc_size = videoFrame->GetWidth();
757 txt_buf = get_metadata(avctx, luma_vanc, videoFrame->GetWidth(),768 if (ctx->bmd_mode == bmdModeNTSC && videoFrame->GetWidth() * 2 <= MAX_WIDTH_VANC) {
769 vanc_size = vanc_size * 2;
770 unpack_v210(vanc, buf, videoFrame->GetWidth());
771 } else {
772 extract_luma_from_v210(vanc, buf, videoFrame->GetWidth());
773 }
774 txt_buf = get_metadata(avctx, vanc, vanc_size,
758 txt_buf, sizeof(txt_buf0) - (txt_buf - txt_buf0), &pkt);775 txt_buf, sizeof(txt_buf0) - (txt_buf - txt_buf0), &pkt);
759 }776 }
760 if (i == vanc_line_numbers[idx].field0_vanc_end)777 if (i == vanc_line_numbers[idx].field0_vanc_end)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t