#include <gtk/gtk.h>#include <stdio.h>#include <string.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include "error.h"#include "kino_av_pipe.h"#include "endian_types.h"#include "rwpipe.h"#include "frame.h"#include "stringutils.h"Include dependency graph for kino_av_pipe.cc:

Go to the source code of this file.
Defines | |
| #define | SCALEBITS 8 |
| #define | ONE_HALF (1 << (SCALEBITS - 1)) |
| #define | FIX(x) ((int) ((x) * (1L<<SCALEBITS) + 0.5)) |
Typedefs | |
| typedef * | RIFFChunk |
| typedef * | FORMATChunk |
| typedef * | DATAChunk |
| typedef * | WAVStruct |
Functions | |
| static RIFFChunk | RIFFChunk_Init () |
| static FORMATChunk | FORMATChunk_Init (short channels, int rate, int bytespersample) |
| static DATAChunk | DATAChunk_Init () |
| static void | WAVStruct_WriteHeader (WAVStruct wav) |
| static WAVStruct | WAVStruct_Init (char *output, short channels, int frequency, short bytespersample) |
| static int | WAVStruct_WriteData (WAVStruct wav, void *data, int length) |
| static void | WAVStruct_Close (WAVStruct wav) |
| static void | frame_YUV422_to_YUV420P (uint8_t **output, uint8_t *input, int width, int height) |
| Pilfered directly from MJPEG - converts YUV422 to YUV420P. | |
| static void | frame_RGB24_to_YUV420P (uint8_t **output, uint8_t *input, int width, int height) |
|
|
Definition at line 531 of file kino_av_pipe.cc. Referenced by frame_RGB24_to_YUV420P(). |
|
|
Definition at line 530 of file kino_av_pipe.cc. Referenced by frame_RGB24_to_YUV420P(). |
|
|
Definition at line 529 of file kino_av_pipe.cc. Referenced by frame_RGB24_to_YUV420P(). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 107 of file kino_av_pipe.cc. Referenced by WAVStruct_Init(). 00108 {
00109 DATAChunk data = ( DATAChunk ) malloc( sizeof( DATAChunkType ) );
00110 memset( data, 0, sizeof( DATAChunkType ) );
00111 memcpy( data->data, "data", 4 );
00112 return data;
00113 }
|
|
||||||||||||||||
|
Definition at line 92 of file kino_av_pipe.cc. Referenced by WAVStruct_Init(). 00093 {
00094 FORMATChunk format = ( FORMATChunk ) malloc( sizeof( FORMATChunkType ) );
00095 memset( format, 0, sizeof( FORMATChunkType ) );
00096 memcpy( format->format, "fmt ", 4 );
00097 format->length = 0x10;
00098 format->filler = 0x01;
00099 format->channels = channels;
00100 format->rate = rate;
00101 format->bytespersecond = rate * channels * bytespersample;
00102 format->bytespersample = bytespersample * channels;
00103 format->bitspersample = bytespersample * 8;
00104 return format;
00105 }
|
|
||||||||||||||||||||
|
Definition at line 533 of file kino_av_pipe.cc. References FIX, ONE_HALF, and SCALEBITS. Referenced by KinoDeinterlacedMJPEGVideoPipe::OutputVideoFrame(). 00534 {
00535 int wrap, wrap3, x, y;
00536 int r, g, b, r1, g1, b1;
00537 uint8_t *p;
00538
00539 uint8_t *lum = output[ 0 ];
00540 uint8_t *cb = output[ 1 ];
00541 uint8_t *cr = output[ 2 ];
00542
00543 wrap = width;
00544 wrap3 = width * 3;
00545 //wrap3 = 0;
00546 p = input;
00547 for ( y = 0;y < height;y += 2 )
00548 {
00549 for ( x = 0;x < width;x += 2 )
00550 {
00551 r = p[ 0 ];
00552 g = p[ 1 ];
00553 b = p[ 2 ];
00554 r1 = r;
00555 g1 = g;
00556 b1 = b;
00557 lum[ width ] = lum[ 0 ] = ( FIX( 0.29900 ) * r + FIX( 0.58700 ) * g +
00558 FIX( 0.11400 ) * b + ONE_HALF ) >> SCALEBITS;
00559 r = p[ 3 ];
00560 g = p[ 4 ];
00561 b = p[ 5 ];
00562 r1 += r;
00563 g1 += g;
00564 b1 += b;
00565 lum[ width + 1 ] = lum[ 1 ] = ( FIX( 0.29900 ) * r + FIX( 0.58700 ) * g +
00566 FIX( 0.11400 ) * b + ONE_HALF ) >> SCALEBITS;
00567 lum += wrap;
00568
00569 cb[ 0 ] = ( ( - FIX( 0.16874 ) * r1 - FIX( 0.33126 ) * g1 +
00570 FIX( 0.50000 ) * b1 + 4 * ONE_HALF - 1 ) >> ( SCALEBITS + 1 ) ) + 128;
00571 cr[ 0 ] = ( ( FIX( 0.50000 ) * r1 - FIX( 0.41869 ) * g1 -
00572 FIX( 0.08131 ) * b1 + 4 * ONE_HALF - 1 ) >> ( SCALEBITS + 1 ) ) + 128;
00573
00574 cb++;
00575 cr++;
00576 p += 6;
00577 lum += -wrap + 2;
00578 }
00579 p += wrap3;
00580 lum += wrap;
00581 }
00582 }
|
|
||||||||||||||||||||
|
Pilfered directly from MJPEG - converts YUV422 to YUV420P.
Definition at line 497 of file kino_av_pipe.cc. Referenced by KinoMJPEGVideoPipe::OutputVideoFrame(). 00498 {
00499 int i, j, w2;
00500 uint8_t *y, *cb, *cr;
00501
00502 w2 = width / 2;
00503 y = output[ 0 ];
00504 cb = output[ 1 ];
00505 cr = output[ 2 ];
00506
00507 for ( i = 0; i < height; i += 2 )
00508 {
00509 /* process two scanlines (one from each field, interleaved) */
00510 for ( j = 0; j < w2; j++ )
00511 {
00512 /* packed YUV 422 is: Y[i] U[i] Y[i+1] V[i] */
00513 *( y++ ) = *( input++ );
00514 *( cb++ ) = *( input++ );
00515 *( y++ ) = *( input++ );
00516 *( cr++ ) = *( input++ );
00517 }
00518 /* process next two scanlines (one from each field, interleaved) */
00519 for ( j = 0; j < w2; j++ )
00520 {
00521 /* skip every second line for U and V */
00522 *( y++ ) = *( input++ );
00523 input++;
00524 *( y++ ) = *( input++ );
00525 input++;
00526 }
00527 }
00528 }
|
|
|
Definition at line 83 of file kino_av_pipe.cc. Referenced by WAVStruct_Init(). 00084 {
00085 RIFFChunk chunk = ( RIFFChunk ) malloc( sizeof( RIFFChunkType ) );
00086 memcpy( chunk->riff, "RIFF", 4 );
00087 chunk->length = 4 + sizeof( FORMATChunkType ) + sizeof( DATAChunkType );
00088 memcpy( chunk->type, "WAVE", 4 );
00089 return chunk;
00090 }
|
|
|
Definition at line 152 of file kino_av_pipe.cc. References WAVStruct_WriteHeader(). Referenced by WAVExport::CloseAudio(). 00153 {
00154 if ( !wav->isapipe )
00155 {
00156 rewind( wav->file );
00157 WAVStruct_WriteHeader( wav );
00158 fclose( wav->file );
00159 }
00160 else
00161 {
00162 pclose( wav->file );
00163 }
00164 free( wav->riff );
00165 free( wav->format );
00166 free( wav->data );
00167 free( wav );
00168 }
|
|
||||||||||||||||||||
|
Definition at line 128 of file kino_av_pipe.cc. References DATAChunk_Init(), FORMATChunk_Init(), RIFFChunk_Init(), and WAVStruct_WriteHeader(). Referenced by WAVExport::OpenAudio(). 00129 {
00130 WAVStruct wav = ( WAVStruct ) malloc( sizeof( WAVStructType ) );
00131 wav->riff = RIFFChunk_Init();
00132 wav->format = FORMATChunk_Init( channels, frequency, bytespersample );
00133 wav->data = DATAChunk_Init();
00134 wav->isapipe = output[ 0 ] == '|';
00135 if ( wav->isapipe )
00136 wav->file = popen( output + 1, "w" );
00137 else
00138 wav->file = fopen( output, "w" );
00139 WAVStruct_WriteHeader( wav );
00140 return wav;
00141 }
|
|
||||||||||||||||
|
Definition at line 143 of file kino_av_pipe.cc. Referenced by WAVExport::OutputAudioFrame(). 00144 {
00145 wav->riff->length += length;
00146 wav->data->length += length;
00147 int written = fwrite( data, length, 1, wav->file );
00148 fflush( wav->file );
00149 return written == 1;
00150 }
|
|
|
Definition at line 115 of file kino_av_pipe.cc. Referenced by WAVStruct_Close(), and WAVStruct_Init(). 00116 {
00117 if ( wav->isapipe )
00118 {
00119 wav->riff->length |= 0x7ffff000;
00120 wav->data->length |= 0x7ffff000;
00121 }
00122 fwrite( wav->riff, sizeof( RIFFChunkType ), 1, wav->file );
00123 fwrite( wav->format, sizeof( FORMATChunkType ), 1, wav->file );
00124 fwrite( wav->data, sizeof( DATAChunkType ), 1, wav->file );
00125 fflush( wav->file );
00126 }
|
1.4.2