Frame Class Reference

#include <frame.h>

List of all members.

Public Member Functions

 Frame ()
 constructor
 ~Frame ()
bool GetSSYBPack (int packNum, Pack &pack) const
 gets a subcode data packet
bool GetVAUXPack (int packNum, Pack &pack) const
 gets a video auxiliary data packet
bool GetAAUXPack (int packNum, Pack &pack) const
 gets an audio auxiliary data packet
bool GetTimeCode (TimeCode &timeCode) const
 gets the timecode information of this frame
bool GetRecordingDate (struct tm &recDate) const
 gets the date and time of recording of this frame
string GetRecordingDate (void) const
bool GetAudioInfo (AudioInfo &info) const
 gets the audio properties of this frame
bool GetVideoInfo (VideoInfo &info) const
int GetFrameSize (void) const
 gets the size of the frame
float GetFrameRate (void) const
 gets the frame rate of the video
bool IsPAL (void) const
 checks whether the frame is in PAL or NTSC format
bool IsNewRecording (void) const
 checks whether this frame is the first in a new recording
bool IsNormalSpeed (void) const
 checks whether this frame is playing at normal speed
bool IsComplete (void) const
 check whether we have received as many bytes as expected for this frame
int ExtractAudio (void *sound) const
 retrieves the audio data from the frame
void SetPreferredQuality ()
int ExtractAudio (int16_t **channels) const
 retrieves the audio data from the frame
void ExtractHeader (void)
void Deinterlace (uint8_t *pdst, uint8_t *psrc, int stride, int height)
int ExtractRGB (void *rgb)
int ExtractPreviewRGB (void *rgb)
int ExtractYUV (void *yuv)
int ExtractYUV420 (uint8_t *yuv, uint8_t *output[3])
int ExtractPreviewYUV (void *yuv)
bool IsWide (void) const
 Get the frame aspect ratio.
int GetWidth ()
 Get the frame image width.
int GetHeight ()
 Get the frame image height.
void SetRecordingDate (time_t *datetime, int frame)
 Set the RecordingDate of the frame.
void SetTimeCode (int frame)
 Set the TimeCode of the frame.
bool EncodeAudio (AudioInfo &info, int16_t **channels)
void GetUpperField (void *image, int bpp)
void GetLowerField (void *image, int bpp)

Static Public Member Functions

static int CalculateNumberSamples (int frequency, int iteration)

Public Attributes

unsigned char data [144000]
 enough space to hold a PAL frame
int bytesInFrame
 the number of bytes written to the frame
AVCodecContext libavcodec
dv_decoder_t * decoder
int16_t * audio_buffers [4]

Static Private Attributes

static bool maps_initialized = false
 flag for initializing the lookup maps once at startup
static int palmap_ch1 [2000]
 lookup tables for collecting the shuffled audio data
static int palmap_ch2 [2000]
static int palmap_2ch1 [2000]
static int palmap_2ch2 [2000]
static int ntscmap_ch1 [2000]
static int ntscmap_ch2 [2000]
static int ntscmap_2ch1 [2000]
static int ntscmap_2ch2 [2000]
static short compmap [4096]


Constructor & Destructor Documentation

Frame::Frame (  ) 

constructor

All Frame objects share a set of lookup maps, which are initalized once (we are using a variant of the Singleton pattern).

Frame::~Frame (  ) 


Member Function Documentation

int Frame::CalculateNumberSamples ( int  frequency,
int  iteration 
) [static]

void Frame::Deinterlace ( uint8_t *  pdst,
uint8_t *  psrc,
int  stride,
int  height 
)

bool Frame::EncodeAudio ( AudioInfo info,
int16_t **  channels 
)

int Frame::ExtractAudio ( int16_t **  channels  )  const

retrieves the audio data from the frame

The DV frame contains audio data mixed in the video data blocks, which can be retrieved easily using this function.

The audio data consists of 16 bit, two channel audio samples (a 16 bit word for channel 1, followed by a 16 bit word for channel 2 etc.)

Parameters:
channels an array of buffers of audio data, one per channel, up to four channels
Returns:
the number of bytes put into the buffer, or 0 if no audio data could be retrieved

int Frame::ExtractAudio ( void *  sound  )  const

retrieves the audio data from the frame

The DV frame contains audio data mixed in the video data blocks, which can be retrieved easily using this function.

The audio data consists of 16 bit, two channel audio samples (a 16 bit word for channel 1, followed by a 16 bit word for channel 2 etc.)

Parameters:
sound a pointer to a buffer that holds the audio data
Returns:
the number of bytes put into the buffer, or 0 if no audio data could be retrieved

void Frame::ExtractHeader ( void   ) 

int Frame::ExtractPreviewRGB ( void *  rgb  ) 

int Frame::ExtractPreviewYUV ( void *  yuv  ) 

int Frame::ExtractRGB ( void *  rgb  ) 

int Frame::ExtractYUV ( void *  yuv  ) 

int Frame::ExtractYUV420 ( uint8_t *  yuv,
uint8_t *  output[3] 
)

bool Frame::GetAAUXPack ( int  packNum,
Pack pack 
) const

gets an audio auxiliary data packet

Every DIF block in the audio section contains 5 bytes audio auxiliary data and 72 bytes of audio data. The function searches through all DIF blocks although AAUX packets are only allowed in certain defined DIF blocks.

Parameters:
packNum the AAUX package id to return
pack a reference to the variable where the result is stored
Returns:
true for success, false if no pack could be found

bool Frame::GetAudioInfo ( AudioInfo info  )  const

gets the audio properties of this frame

get the sampling frequency and the number of samples in this particular DV frame (which can vary)

Parameters:
info the AudioInfo record
Returns:
true, if audio properties could be determined

float Frame::GetFrameRate ( void   )  const

gets the frame rate of the video

Depending on the type (PAL or NTSC) of the frame, the frame rate is returned

Returns:
frames per second

int Frame::GetFrameSize ( void   )  const

gets the size of the frame

Depending on the type (PAL or NTSC) of the frame, the length of the frame is returned

Returns:
the length of the frame in Bytes

int Frame::GetHeight (  ) 

Get the frame image height.

Returns:
the height in pixels.

void Frame::GetLowerField ( void *  image,
int  bpp 
)

string Frame::GetRecordingDate ( void   )  const

bool Frame::GetRecordingDate ( struct tm &  recDate  )  const

gets the date and time of recording of this frame

Returns a struct tm with date and time of recording of this frame.

This code courtesy of Andy (http://www.videox.net/)

Parameters:
recDate the time and date of recording of this frame
Returns:
true for success, false if no date or time information could be found

bool Frame::GetSSYBPack ( int  packNum,
Pack pack 
) const

gets a subcode data packet

This function returns a SSYB packet from the subcode data section.

Parameters:
packNum the SSYB package id to return
pack a reference to the variable where the result is stored
Returns:
true for success, false if no pack could be found

bool Frame::GetTimeCode ( TimeCode timeCode  )  const

gets the timecode information of this frame

Returns a string with the timecode of this frame. The timecode is the relative location of this frame on the tape, and is defined by hour, minute, second and frame (within the last second).

Parameters:
timeCode the TimeCode struct
Returns:
true for success, false if no timecode information could be found

void Frame::GetUpperField ( void *  image,
int  bpp 
)

bool Frame::GetVAUXPack ( int  packNum,
Pack pack 
) const

gets a video auxiliary data packet

Every DIF block in the video auxiliary data section contains 15 video auxiliary data packets, for a total of 45 VAUX packets. As the position of a VAUX packet is fixed, we could directly look it up, but I choose to walk through all data as with the other routines.

Parameters:
packNum the VAUX package id to return
pack a reference to the variable where the result is stored
Returns:
true for success, false if no pack could be found

bool Frame::GetVideoInfo ( VideoInfo info  )  const

int Frame::GetWidth (  ) 

Get the frame image width.

Returns:
the width in pixels.

bool Frame::IsComplete ( void   )  const

check whether we have received as many bytes as expected for this frame

Returns:
true if this frames is completed, false otherwise

bool Frame::IsNewRecording ( void   )  const

checks whether this frame is the first in a new recording

To determine this, the function looks at the recStartPoint bit in AAUX pack 51.

Returns:
true if this frame is the start of a new recording

bool Frame::IsNormalSpeed ( void   )  const

checks whether this frame is playing at normal speed

To determine this, the function looks at the speed bit in AAUX pack 51.

Returns:
true if this frame is playing at normal speed

bool Frame::IsPAL ( void   )  const

checks whether the frame is in PAL or NTSC format

Todo:
function can't handle "empty" frame
Returns:
true for PAL frame, false for a NTSC frame

bool Frame::IsWide ( void   )  const

Get the frame aspect ratio.

Indicates whether frame aspect ration is normal (4:3) or wide (16:9).

Returns:
true if the frame is wide (16:9), false if unknown or normal.

void Frame::SetPreferredQuality (  ) 

void Frame::SetRecordingDate ( time_t *  datetime,
int  frame 
)

Set the RecordingDate of the frame.

This updates the calendar date and time and the timecode. However, timecode is derived from the time in the datetime parameter and frame number. Use SetTimeCode for more control over timecode.

Parameters:
datetime A simple time value containing the RecordingDate and time information. The time in this structure is automatically incremented by one second depending on the frame parameter and updatded.
frame A zero-based running frame sequence/serial number. This is used both in the timecode as well as a timestamp on dif block headers.

void Frame::SetTimeCode ( int  frame  ) 

Set the TimeCode of the frame.

This function takes a zero-based frame counter and automatically derives the timecode.

Parameters:
frame The frame counter.


Member Data Documentation

int16_t* Frame::audio_buffers[4]

int Frame::bytesInFrame

the number of bytes written to the frame

short Frame::compmap [static, private]

unsigned char Frame::data[144000]

enough space to hold a PAL frame

dv_decoder_t* Frame::decoder

AVCodecContext Frame::libavcodec

bool Frame::maps_initialized = false [static, private]

flag for initializing the lookup maps once at startup

int Frame::ntscmap_2ch1 [static, private]

int Frame::ntscmap_2ch2 [static, private]

int Frame::ntscmap_ch1 [static, private]

int Frame::ntscmap_ch2 [static, private]

int Frame::palmap_2ch1 [static, private]

int Frame::palmap_2ch2 [static, private]

int Frame::palmap_ch1 [static, private]

lookup tables for collecting the shuffled audio data

int Frame::palmap_ch2 [static, private]


The documentation for this class was generated from the following files:
Generated on Tue Jan 22 17:07:31 2008 for MUAN by  doxygen 1.4.7