Log in

View Full Version : create my own hints


OvejaNegra
2nd March 2011, 21:25
is there a way to create / add my own hints to a video frame like dgdecode or tivtc does?



if not possible, i was thinkin on adding a black bar of 16pixels widht to the left of the video and put colored sections (each color at certain position has a meaning) and read those colors later, and of course crop that bar before encoding, but i dont know how to doit.

anyhelp?

thanks

IanB
5th March 2011, 03:04
Hint data is steganographed (http://en.wikipedia.org/wiki/Steganography) into the bottom bit of first 64 pixels of the luma plane.

From dgdecode154src\AVISynthAPI.cpp :- hint = 0;
if (m_decoder.FrameList[raw].pf == 1) hint |= PROGRESSIVE;
hint |= ((m_decoder.GOPList[gop]->matrix & 7) << COLORIMETRY_SHIFT);
PutHintingData(frame->GetWritePtr(PLANAR_Y), hint);
From dgdecode154src\Utilities.cpp :-#include <windows.h>

#define MAGIC_NUMBER (0xdeadbeef)

bool PutHintingData(unsigned char *video, unsigned int hint)
{
unsigned char *p;
unsigned int i, magic_number = MAGIC_NUMBER;
bool error = false;

p = video;
for (i = 0; i < 32; i++)
{
*p &= ~1;
*p++ |= ((magic_number & (1 << i)) >> i);
}
for (i = 0; i < 32; i++)
{
*p &= ~1;
*p++ |= ((hint & (1 << i)) >> i);
}
return error;
}

bool GetHintingData(unsigned char *video, unsigned int *hint)
{
unsigned char *p;
unsigned int i, magic_number = 0;
bool error = false;

p = video;
for (i = 0; i < 32; i++)
{
magic_number |= ((*p++ & 1) << i);
}
if (magic_number != MAGIC_NUMBER)
{
error = true;
}
else
{
*hint = 0;
for (i = 0; i < 32; i++)
{
*hint |= ((*p++ & 1) << i);
}
}
return error;
}

TheFluff
6th March 2011, 07:23
There's also FieldHint() and Telecidehints() if you don't want to write a hinting filter yourself.