Subversion Repositories cinelerra

Compare Revisions

Ignore whitespace Rev 659 → Rev 660

/branches/automake-1_1_5/hvirtual/configure
1,3 → 1,5
#!/bin/sh
 
# configuration is being done in a script because starting with GCC-3.2
# the compiler flags are changing too much between minor releases to detect
# with Makefile scripts alone. For now it just tells you if you have the
6,6 → 8,8
ERROR=0
 
# test for nasm
OBJDIR=`arch`
TOPDIR=`pwd`
 
if [ `arch` == i686 ];
then
15,11 → 19,18
if [ "$HAVE_NASM" == "n" ];
then echo " *** Nasm is required. Download it from nasm.sourceforge.net";
ERROR=1
exit 1
fi
 
fi
 
if [ -x /usr/bin/yasm -o -x /usr/local/bin/yasm ]; then HAVE_YASM=y; else HAVE_YASM=n; fi
 
if [ $HAVE_YASM == n ];
then echo " *** Yasm is required. Download it from www.tortall.net/projects/yasm/";
ERROR=1
fi
 
 
# test for videodev2.h
 
rm -f a.out
60,14 → 71,63
if [ $HAVE_GCC == n ];
then echo " *** GCC 3.2.2 or greater is required. Download it from gcc.gnu.org";
ERROR=1
fi
 
 
if [ $ERROR == 1 ];
then echo "Giving up and going to a movie."
exit 1
fi
 
 
# fix ffmpeg for mmx
cd quicktime/ffmpeg* && ./configure && cd ../..
 
 
 
# fix libraries
echo CONFIGURING QUICKTIME
cd quicktime* && ./configure && cd ..
 
echo CONFIGURING LIBMPEG3
cd libmpeg3* && ./configure && cd ..
 
echo CONFIGURING FFTW
cd fftw* && CFLAGS=-fPIC ./configure && cd ..
 
echo CONFIGURING MJPEGTOOLS
ALSA_PATH=`expr $TOPDIR/alsa-lib*` && \
cd mjpegtools* && CFLAGS="-I$ALSA_PATH/include -L$ALSA_PATH/$OBJDIR" ./configure --enable-shared=no && cd ..
 
echo CONFIGURING SNDFILE
cd libsndfile* && chmod a+x configure && ./configure && cd ..
 
echo CONFIGURING RAW1394
cd libraw1394* && \
./configure --enable-shared=no && \
ln -sf src libraw1394 && \
cd ..
 
echo CONFIGURING AVC1394
cd libavc1394* && \
RAW1394_PATH=`expr $TOPDIR/libraw1394*` && \
PKG_CONFIG_PATH=$RAW1394_PATH CFLAGS=-I$RAW1394_PATH/ LDFLAGS=-L$RAW1394_PATH/src/.libs ./configure --enable-shared=no && \
cd ..
 
echo CONFIGURING IEC61883
cd libiec61883* && \
RAW1394_PATH=`expr $TOPDIR/libraw1394*` && \
PKG_CONFIG_PATH=$RAW1394_PATH CFLAGS=-I$RAW1394_PATH/ LDFLAGS=-L$RAW1394_PATH/src/.libs ./configure --enable-shared=no && \
cd ..
 
echo CONFIGURING THEORA
ALSA_PATH=`expr $TOPDIR/alsa-lib*` && \
LIBOGG_PATH=`expr $TOPDIR/quicktime/libogg*` && \
LIBVORBIS_PATH=`expr $TOPDIR/quicktime/libvorbis*` && \
cd libtheora* && \
PKG_CONFIG_PATH=$LIBOGG_PATH:$LIBVORBIS_PATH CFLAGS="-I$LIBOGG_PATH/include -I$ALSA_PATH -L$ALSA_PATH/$OBJDIR -L$LIBOGG_PATH/src -I$LIBVORBIS_PATH/include -L$LIBVORBIS_PATH/lib" ./configure --enable-shared=no && \
cd ..
 
 
 
# write configuration header
echo "Writing hvirtual_config.h"
cat > hvirtual_config.h << EOF
/branches/automake-1_1_5/hvirtual/plugin_config
5,11 → 5,12
-fPIC
 
$(shell echo $(CFLAGS) > ../$(OBJDIR)/c_flags)
$(shell echo $(LFLAGS) > ../$(OBJDIR)/l_flags)
 
 
$(OUTPUT): $(OBJS)
@echo LD $(OUTPUT)
@$(LDLINKER) -o $(OUTPUT) $(OBJS)
@$(LDLINKER) -o $(OUTPUT) $(OBJS) `cat ../$(OBJDIR)/l_flags`
@echo STRIP $(OUTPUT)
@strip $(OUTPUT)
 
21,6 → 22,7
clean:
find \( -name core -o -name '*.o' -o -name '*.a' \) -exec rm -f {} \;
rm -f $(OUTPUT)
rm -rf $(OBJDIR)
 
wc:
cat *.C *.h | wc
/branches/automake-1_1_5/hvirtual/global_config
1,5 → 1,3
AVC_DIR := libavc1394-0.4.1
LIBRAW_DIR := libraw1394-0.9.0
HAVE_ALSA := y
HAVE_XFT := n
HAVE_ESOUND := y
34,8 → 32,16
 
CC = g++
GCC = gcc
 
 
# libraries are stored in different directories depending on CPU
ifeq ($(OBJDIR), i686)
PLUGINDIR := /usr/lib/cinelerra
else
PLUGINDIR := /usr/lib64/cinelerra
endif
 
 
ifneq ($(HAVE_CFLAGS), y)
CFLAGS = -O2 -fomit-frame-pointer -falign-loops=2 -falign-jumps=2 -falign-functions=2
endif
/branches/automake-1_1_5/hvirtual/toolame-02l/audio_read.c
30,7 → 30,7
 
if (init) {
samples_to_read = num_samples;
init = FALSE;
// init = FALSE;
}
if (samples_to_read >= frame_size)
samples_read = frame_size;
/branches/automake-1_1_5/hvirtual/toolame-02l/toolame.c
97,17 → 97,17
int got_it = 0;
int result = 0;
 
//printf("toolame_buffer_read 1 %d %d %d\n", got_it, toolame_eof, toolame_error);
while(!got_it && !toolame_eof && !toolame_error)
{
//printf("toolame_buffer_read 2\n");
pthread_mutex_lock(&toolame_input_lock);
//printf("toolame_buffer_read 3\n");
// printf("toolame_buffer_read 1 size=%d n=%d eof=%d %d %d\n",
// size, n, toolame_eof, got_it, toolame_error);
if(toolame_eof || toolame_buffer_bytes >= size * n)
got_it = 1;
else
pthread_mutex_unlock(&toolame_output_lock);
}
 
result = size * n;
if(result > toolame_buffer_bytes)
result = toolame_buffer_bytes;
266,6 → 266,7
else
parse_args (argc, argv, &frame, &model, &num_samples, original_file_name,
encoded_file_name);
 
print_config (&frame, &model, original_file_name, encoded_file_name);
 
/* this will load the alloc tables and do some other stuff */
273,6 → 274,8
nch = frame.nch;
error_protection = header.error_protection;
 
 
 
while (get_audio (musicin, buffer, num_samples, nch, &header) > 0) {
if (glopts.verbosity > 1)
if (++frameNum % 10 == 0)
1023,9 → 1026,11
if ((header->bitrate_index = toolame_BitrateIndex (brate, header->version)) < 0)
err = 1;
 
 
/* All options are hunky dory, open the input audio file and
return to the main drag */
open_bit_stream_w (&bs, outPath, BUFFER_SIZE);
 
}
 
 
/branches/automake-1_1_5/hvirtual/quicktime/vbraudio.c
103,27 → 103,39
trak,
vbr->sample);
int size = quicktime_sample_size(trak, vbr->sample);
int new_allocation = vbr->input_size + size;
int result = 0;
 
if(vbr->input_buffer && vbr->input_allocation < size)
if(vbr->input_allocation < new_allocation)
{
free(vbr->input_buffer);
vbr->input_buffer = 0;
vbr->input_buffer = realloc(vbr->input_buffer, new_allocation);
vbr->input_allocation = new_allocation;
}
 
if(!vbr->input_buffer)
{
vbr->input_buffer = calloc(1, size);
vbr->input_allocation = size;
}
vbr->input_size = size;
 
quicktime_set_position(file, offset);
result = !quicktime_read_data(file, vbr->input_buffer, vbr->input_size);
result = !quicktime_read_data(file, vbr->input_buffer + vbr->input_size, size);
vbr->input_size += size;
vbr->sample++;
return result;
}
 
void quicktime_shift_vbr(quicktime_audio_map_t *atrack, int bytes)
{
quicktime_vbr_t *vbr = &atrack->vbr;
if(bytes >= vbr->input_size)
{
vbr->input_size = 0;
}
else
{
int i, j;
for(i = 0, j = bytes; j < vbr->input_size; i++, j++)
vbr->input_buffer[i] = vbr->input_buffer[j];
vbr->input_size -= bytes;
}
}
 
void quicktime_store_vbr_float(quicktime_audio_map_t *atrack,
float *samples,
int sample_count)
187,5 → 199,3
 
 
 
 
 
/branches/automake-1_1_5/hvirtual/quicktime/configure
1,3 → 1,5
#!/bin/sh
 
# configuration is being done in a script because starting with GCC-3.2
# the compiler flags are changing too much between minor releases to detect
# with Makefile scripts alone. For now it just tells you if you have the
6,19 → 8,24
ERROR=0
 
# test for nasm
 
if [ -x /usr/bin/nasm -o -x /usr/local/bin/nasm ]; then HAVE_NASM=y; else HAVE_NASM=n; fi
 
if [ $HAVE_NASM == n ];
then echo " *** Nasm is required. Download it from nasm.sourceforge.net";
# test for yasm
if [ -x /usr/bin/yasm -o -x /usr/local/bin/yasm ]; then HAVE_YASM=y; else HAVE_YASM=n; fi
 
if [ `arch` == i686 ];
then
if [ $HAVE_NASM == n ];
then echo " *** Nasm is required. Download it from nasm.sourceforge.net";
ERROR=1
fi
fi
 
if [ $HAVE_YASM == n ];
then echo " *** Yasm is required. Download it from www.tortall.net/projects/yasm/";
ERROR=1
fi
 
 
 
 
 
 
# test for -msse support
 
rm -f a.out
40,11 → 47,40
ERROR=1
fi
 
if [ $ERROR == 1 ];
then exit;
fi
 
# configure them all
 
# version 2.0 of faad2 produced defective Makefile
cd faad2* && ./configure && sed 's/ /\t/' Makefile > Makefile2 && mv -f Makefile2 Makefile && cd ..
 
cd faac* && ./configure && cd ..
 
cd ffmpeg* && ./configure && cd ..
 
cd x264* && ./configure --enable-pthread && cd ..
 
cd libdv* && ./configure --disable-gtk --enable-shared=no && cd ..
 
cd libogg* && ./configure && cd ..
 
LIBOGG_PATH=`expr libogg*` && \
cd libvorbis* && \
CFLAGS="-I../../$LIBOGG_PATH/include -L../../$LIBOGG_PATH/src/" ./configure --enable-shared=no&& \
cd ..
 
 
 
if [ `arch` == i686 ];
then
 
cd jpeg-mmx* && ./configure && cd ..
 
fi
 
 
# success
if [ $ERROR == 0 ];
then echo "Configured successfully. Type 'make' to build it.";
/branches/automake-1_1_5/hvirtual/quicktime/mpeg4.c
20,6 → 20,7
#include <pthread.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
 
#define FRAME_RATE_BASE 10000
 
101,8 → 102,6
int buffer_size;
} quicktime_mpeg4_codec_t;
 
int ffmpeg_initialized = 0;
pthread_mutex_t ffmpeg_lock = PTHREAD_MUTEX_INITIALIZER;
 
 
// Decore needs the user to specify handles
117,7 → 116,7
 
 
 
// Utilities for programs wishing to parse MPEG-4
// Direct copy routines
 
 
// Determine of the compressed frame is a keyframe for direct copy
127,6 → 126,7
int i;
 
if(quicktime_match_32(codec_id, QUICKTIME_DIVX) ||
quicktime_match_32(codec_id, QUICKTIME_MP4V) ||
quicktime_match_32(codec_id, QUICKTIME_HV60))
{
for(i = 0; i < size - 5; i++)
226,8 → 226,8
 
bit_store = 0;
bit_pos = 0;
vol_width = (int)((float)vol_width / 16 + 0.5) * 16;
vol_height = (int)((float)vol_height / 16 + 0.5) * 16;
vol_width = quicktime_quantize16(vol_width);
vol_height = quicktime_quantize16(vol_height);
 
 
putbits(&data,
249,7 → 249,6
 
 
 
 
putbits(&data,
&bit_pos,
&bit_store,
432,7 → 431,6
&bit_store);
 
 
 
/*
* for(i = 0; i < data - data_start; i++)
* for(j = 0x80; j >= 1; j /= 2)
456,14 → 454,36
double frame_rate)
{
unsigned char *start = data;
 
 
/*
* static unsigned char test[] =
* {
*
* 0x00, 0x00, 0x01, 0xb0, 0x01, 0x00, 0x00, 0x01, 0xb5, 0x89, 0x13,
* 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x20, 0x00, 0xc4, 0x8d,
* 0x8a, 0xee, 0x05, 0x28, 0x04, 0x5a, 0x14, 0x63, 0x00, 0x00, 0x01, 0xb2,
* 0x46, 0x46, 0x6d, 0x70, 0x65, 0x67, 0x43, 0x56, 0x53, 0x62, 0x34, 0x37,
* 0x35, 0x38
*
* };
* memcpy(data, test, sizeof(test));
*
* return sizeof(test);
*/
 
// From ffmpeg
// Advanced simple level 1
int profile_level = 0xf3;
int vo_version_id = 5;
// int profile_level = 0xf3;
 
int profile_level = 0x1;
// int vo_version_id = 5;
int vo_version_id = 1;
 
 
 
 
 
// VOS startcode
*data++ = 0x00;
*data++ = 0x00;
476,18 → 496,21
*data++ = 0x00;
*data++ = 0x01;
*data++ = 0xb5;
*data++ = (1 << 7) ||
(vo_version_id << 3) ||
*data++ = ((unsigned char)0x1 << 7) |
((unsigned char)vo_version_id << 3) |
// Priority
1;
// visual object type
*data++ = (1 << 4) ||
(unsigned char)1;
// visual object type video
*data++ = (0x1 << 4) |
// Video signal type
0;
*data++ = 0x40;
*data++ = 0xc0;
*data++ = 0xcf;
(0 << 3) |
// Stuffing
0x3;
 
// *data++ = 0x40;
// *data++ = 0xc0;
// *data++ = 0xcf;
 
// video object
int vol_size = quicktime_mpeg4_write_vol(data,
w,
521,17 → 544,7
int colormodel,
int track)
{
return (colormodel == BC_RGB888 ||
colormodel == BC_RGBA8888 ||
colormodel == BC_RGB161616 ||
colormodel == BC_RGBA16161616 ||
colormodel == BC_YUV888 ||
colormodel == BC_YUVA8888 ||
colormodel == BC_YUV161616 ||
colormodel == BC_YUVA16161616 ||
colormodel == BC_YUV420P ||
colormodel == BC_YUV422 ||
colormodel == BC_COMPRESSED);
return colormodel == BC_YUV420P;
}
 
 
550,11 → 563,15
}
 
 
static int init_decode(quicktime_mpeg4_codec_t *codec,
static int init_decode(quicktime_t *file,
quicktime_mpeg4_codec_t *codec,
quicktime_trak_t *trak,
int current_field,
int width_i,
int height_i)
{
quicktime_stsd_table_t *stsd_table = &trak->mdia.minf.stbl.stsd.table[0];
quicktime_esds_t *esds = &stsd_table->esds;
 
if(!ffmpeg_initialized)
{
571,10 → 588,26
return 1;
}
 
codec->decoder_context[current_field] = avcodec_alloc_context();
codec->decoder_context[current_field]->width = width_i;
codec->decoder_context[current_field]->height = height_i;
if(avcodec_open(codec->decoder_context[current_field],
AVCodecContext *context =
codec->decoder_context[current_field] =
avcodec_alloc_context();
context->width = width_i;
context->height = height_i;
 
 
if(esds->mpeg4_header && esds->mpeg4_header_size)
{
context->extradata = esds->mpeg4_header;
context->extradata_size = esds->mpeg4_header_size;
}
 
if(file->cpus > 1)
{
avcodec_thread_init(context, file->cpus);
context->thread_count = file->cpus;
}
 
if(avcodec_open(context,
codec->decoder[current_field]) < 0)
{
printf("init_decode: avcodec_open failed.\n");
588,7 → 621,8
quicktime_mpeg4_codec_t *codec,
int frame_number,
int current_field,
int track)
int track,
int drop_it)
{
 
int got_picture = 0;
600,17 → 634,28
quicktime_stsd_table_t *stsd_table = &trak->mdia.minf.stbl.stsd.table[0];
int width = trak->tkhd.track_width;
int height = trak->tkhd.track_height;
int width_i = (int)((float)width / 16 + 0.5) * 16;
int height_i = (int)((float)height / 16 + 0.5) * 16;
int width_i;
int height_i;
 
if(codec->ffmpeg_id == CODEC_ID_SVQ1)
{
width_i = quicktime_quantize32(width);
height_i = quicktime_quantize32(height);
}
else
{
width_i = quicktime_quantize16(width);
height_i = quicktime_quantize16(height);
}
 
 
quicktime_set_video_position(file, frame_number, track);
bytes = quicktime_frame_size(file, frame_number, track);
if(frame_number == 0)
{
header_bytes = stsd_table->mpeg4_header_size;
header_bytes = stsd_table->esds.mpeg4_header_size;
}
//printf("decode_wrapper 1 %p %d %d %d\n", stsd_table, frame_number, bytes, header_bytes);
 
if(!codec->work_buffer || codec->buffer_size < bytes + header_bytes)
{
620,9 → 665,8
}
if(header_bytes)
memcpy(codec->work_buffer, stsd_table->mpeg4_header, header_bytes);
memcpy(codec->work_buffer, stsd_table->esds.mpeg4_header, header_bytes);
 
//printf("decode_wrapper 1 %d %d\n", header_bytes, bytes);
if(!quicktime_read_data(file,
codec->work_buffer + header_bytes,
bytes))
646,6 → 690,10
 
// No way to determine if there was an error based on nonzero status.
// Need to test row pointers to determine if an error occurred.
if(drop_it)
codec->decoder_context[current_field]->skip_frame = AVDISCARD_NONREF;
else
codec->decoder_context[current_field]->skip_frame = AVDISCARD_DEFAULT;
result = avcodec_decode_video(codec->decoder_context[current_field],
&codec->picture[current_field],
&got_picture,
700,13 → 748,13
 
if(codec->ffmpeg_id == CODEC_ID_SVQ1)
{
width_i = (int)((float)width / 16 + 0.5) * 32;
height_i = (int)((float)height / 16 + 0.5) * 32;
width_i = quicktime_quantize32(width);
height_i = quicktime_quantize32(height);
}
else
{
width_i = (int)((float)width / 16 + 0.5) * 16;
height_i = (int)((float)height / 16 + 0.5) * 16;
width_i = quicktime_quantize16(width);
height_i = quicktime_quantize16(height);
}
 
pthread_mutex_lock(&ffmpeg_lock);
715,7 → 763,7
if(!codec->decode_initialized[current_field])
{
int current_frame = vtrack->current_position;
init_decode(codec, current_field, width_i, height_i);
init_decode(file, codec, trak, current_field, width_i, height_i);
// Must decode frame with stream header first but only the first frame in the
// field sequence has a stream header.
result = decode_wrapper(file,
723,7 → 771,8
codec,
current_field,
current_field,
track);
track,
0);
// Reset position because decode wrapper set it
quicktime_set_video_position(file, current_frame, track);
codec->decode_initialized[current_field] = 1;
735,7 → 784,6
{
int frame1, frame2 = vtrack->current_position, current_frame = frame2;
int do_i_frame = 1;
//printf("decode 2\n");
 
// Get first keyframe of same field
do
744,7 → 792,6
current_frame--,
track);
}while(frame1 > 0 && (frame1 % codec->total_fields) != current_field);
//printf("decode 3\n");
 
// Keyframe is before last decoded frame and current frame is after last decoded
// frame, so instead of rerendering from the last keyframe we can rerender from
752,7 → 799,6
if(frame1 < codec->last_frame[current_field] &&
frame2 > codec->last_frame[current_field])
{
//printf("decode 1 %d %d\n", frame1, frame2);
frame1 = codec->last_frame[current_field] + codec->total_fields;
do_i_frame = 0;
}
764,7 → 810,8
codec,
frame1,
current_field,
track);
track,
(frame1 < frame2));
 
 
// May need to do the first I frame twice.
775,7 → 822,8
codec,
frame1,
current_field,
track);
track,
0);
do_i_frame = 0;
}
frame1 += codec->total_fields;
793,7 → 841,8
codec,
vtrack->current_position,
current_field,
track);
track,
0);
}
pthread_mutex_unlock(&ffmpeg_lock);
 
890,8 → 939,8
quicktime_trak_t *trak = vtrack->track;
int width = trak->tkhd.track_width;
int height = trak->tkhd.track_height;
int width_i = (int)((float)width / 16 + 0.5) * 16;
int height_i = (int)((float)height / 16 + 0.5) * 16;
int width_i = quicktime_quantize16(width);
int height_i = quicktime_quantize16(height);
int result = 0;
int i;
int bytes = 0;
900,7 → 949,6
quicktime_atom_t chunk_atom;
 
 
//printf("encode 1\n");
 
 
 
911,9 → 959,8
if(!codec->encode_initialized[current_field])
{
// Encore section
if(codec->ffmpeg_id == CODEC_ID_MPEG4)
if(codec->ffmpeg_id == CODEC_ID_MPEG4 && codec->use_encore)
{
codec->use_encore = 1;
codec->encode_initialized[current_field] = 1;
codec->encode_handle[current_field] = encode_handle++;
codec->enc_param[current_field].x_dim = width_i;
937,19 → 984,6
ENC_OPT_INIT,
&codec->enc_param[current_field], NULL);
 
 
// Create esds header
if(!strcmp(((quicktime_codec_t*)vtrack->codec)->fourcc, QUICKTIME_MP4V))
{
unsigned char temp[256];
int size = write_mp4v_header(temp,
width,
height,
quicktime_frame_rate(file, track));
quicktime_set_mpeg4_header(&trak->mdia.minf.stbl.stsd.table[0],
temp,
size);
}
}
else
// ffmpeg section
972,37 → 1006,91
}
 
codec->encoder_context[current_field] = avcodec_alloc_context();
codec->encoder_context[current_field]->frame_rate = FRAME_RATE_BASE *
quicktime_frame_rate(file, track);
codec->encoder_context[current_field]->width = width_i;
codec->encoder_context[current_field]->height = height_i;
codec->encoder_context[current_field]->gop_size = codec->gop_size;
codec->encoder_context[current_field]->pix_fmt = PIX_FMT_YUV420P;
codec->encoder_context[current_field]->bit_rate = codec->bitrate;
codec->encoder_context[current_field]->bit_rate_tolerance = codec->bitrate_tolerance;
codec->encoder_context[current_field]->rc_eq = video_rc_eq;
codec->encoder_context[current_field]->qmin = 2;
codec->encoder_context[current_field]->qmax = 31;
codec->encoder_context[current_field]->max_qdiff = 3;
codec->encoder_context[current_field]->qblur = 0.5;
codec->encoder_context[current_field]->qcompress = 0.5;
codec->encoder_context[current_field]->me_method = ME_FULL;
AVCodecContext *context = codec->encoder_context[current_field];
 
printf("encode %d %d %d %d %d\n", codec->gop_size, codec->bitrate, codec->bitrate_tolerance, codec->fix_bitrate, codec->interlaced);
context->width = width_i;
context->height = height_i;
context->gop_size = codec->gop_size;
context->pix_fmt = PIX_FMT_YUV420P;
context->bit_rate = codec->bitrate / codec->total_fields;
context->bit_rate_tolerance = codec->bitrate_tolerance;
context->rc_eq = video_rc_eq;
context->rc_max_rate = 0;
context->rc_min_rate = 0;
context->rc_buffer_size = 0;
context->qmin =
(!codec->fix_bitrate ? codec->quantizer : 2);
context->qmax =
(!codec->fix_bitrate ? codec->quantizer : 31);
context->lmin = 2 * FF_QP2LAMBDA;
context->lmax = 31 * FF_QP2LAMBDA;
context->mb_lmin = 2 * FF_QP2LAMBDA;
context->mb_lmax = 31 * FF_QP2LAMBDA;
context->max_qdiff = 3;
context->qblur = 0.5;
context->qcompress = 0.5;
// It needs the time per frame, not the frame rate.
context->time_base.den = quicktime_frame_rate_n(file, track);
context->time_base.num = quicktime_frame_rate_d(file, track);
 
context->b_quant_factor = 1.25;
context->b_quant_offset = 1.25;
context->error_resilience = FF_ER_CAREFULL;
context->error_concealment = 3;
context->frame_skip_cmp = FF_CMP_DCTMAX;
context->ildct_cmp = FF_CMP_VSAD;
context->intra_dc_precision = 0;
context->intra_quant_bias = FF_DEFAULT_QUANT_BIAS;
context->inter_quant_bias = FF_DEFAULT_QUANT_BIAS;
context->i_quant_factor = -0.8;
context->i_quant_offset = 0.0;
context->mb_decision = FF_MB_DECISION_SIMPLE;
context->mb_cmp = FF_CMP_SAD;
context->me_sub_cmp = FF_CMP_SAD;
context->me_cmp = FF_CMP_SAD;
context->me_pre_cmp = FF_CMP_SAD;
context->me_method = ME_EPZS;
context->me_subpel_quality = 8;
context->me_penalty_compensation = 256;
context->me_range = 0;
context->me_threshold = 0;
context->mb_threshold = 0;
context->nsse_weight= 8;
context->profile= FF_PROFILE_UNKNOWN;
context->rc_buffer_aggressivity = 1.0;
context->level= FF_LEVEL_UNKNOWN;
context->flags |= CODEC_FLAG_H263P_UMV;
context->flags |= CODEC_FLAG_AC_PRED;
context->flags |= CODEC_FLAG_4MV;
// Not compatible with Win
// context->flags |= CODEC_FLAG_QPEL;
 
if(!codec->fix_bitrate)
if(file->cpus > 1)
{
codec->encoder_context[current_field]->flags |= CODEC_FLAG_QSCALE;
avcodec_thread_init(context, file->cpus);
context->thread_count = file->cpus;
}
 
if(!codec->fix_bitrate)
context->flags |= CODEC_FLAG_QSCALE;
 
if(codec->interlaced)
{
codec->encoder_context[current_field]->flags |= CODEC_FLAG_INTERLACED_DCT;
context->flags |= CODEC_FLAG_INTERLACED_DCT;
context->flags |= CODEC_FLAG_INTERLACED_ME;
}
 
avcodec_open(codec->encoder_context[current_field], codec->encoder[current_field]);
 
/*
* printf("encode gop_size=%d fix_bitrate=%d quantizer=%d\n",
* codec->gop_size,
* codec->fix_bitrate,
* codec->quantizer);
*/
avcodec_open(context, codec->encoder[current_field]);
 
avcodec_get_frame_defaults(&codec->picture[current_field]);
 
}
}
 
1084,6 → 1172,7
codec->p_count[current_field] = 0;
}
 
 
encore(codec->encode_handle[current_field],
0,
&encore_input,
1095,18 → 1184,19
else
// ffmpeg section
{
AVFrame pict_tmp;
AVCodecContext *context = codec->encoder_context[current_field];
AVFrame *picture = &codec->picture[current_field];
 
if(width_i == width &&
height_i == height &&
file->color_model == BC_YUV420P)
{
pict_tmp.data[0] = row_pointers[0];
pict_tmp.data[1] = row_pointers[1];
pict_tmp.data[2] = row_pointers[2];
pict_tmp.linesize[0] = width_i;
pict_tmp.linesize[1] = width_i / 2;
pict_tmp.linesize[2] = width_i / 2;
picture->data[0] = row_pointers[0];
picture->data[1] = row_pointers[1];
picture->data[2] = row_pointers[2];
picture->linesize[0] = width_i;
picture->linesize[1] = width_i / 2;
picture->linesize[2] = width_i / 2;
}
else
{
1137,22 → 1227,52
width, /* For planar use the luma rowspan */
width_i);
 
pict_tmp.data[0] = codec->temp_frame;
pict_tmp.data[1] = codec->temp_frame + width_i * height_i;
pict_tmp.data[2] = codec->temp_frame + width_i * height_i + width_i * height_i / 4;
pict_tmp.linesize[0] = width_i;
pict_tmp.linesize[1] = width_i / 2;
pict_tmp.linesize[2] = width_i / 2;
picture->data[0] = codec->temp_frame;
picture->data[1] = codec->temp_frame + width_i * height_i;
picture->data[2] = codec->temp_frame + width_i * height_i + width_i * height_i / 4;
picture->linesize[0] = width_i;
picture->linesize[1] = width_i / 2;
picture->linesize[2] = width_i / 2;
}
 
 
if(codec->quantizer >= 0)
pict_tmp.quality = codec->quantizer;
bytes = avcodec_encode_video(codec->encoder_context[current_field],
picture->pict_type = 0;
picture->quality = 0;
picture->pts = vtrack->current_position * quicktime_frame_rate_d(file, track);
picture->key_frame = 0;
bytes = avcodec_encode_video(context,
codec->work_buffer,
codec->buffer_size,
&pict_tmp);
is_keyframe = pict_tmp.key_frame;
picture);
is_keyframe = context->coded_frame && context->coded_frame->key_frame;
/*
* printf("encode current_position=%d is_keyframe=%d\n",
* vtrack->current_position,
* is_keyframe);
*/
 
if(!trak->mdia.minf.stbl.stsd.table[0].esds.mpeg4_header_size &&
!strcmp(((quicktime_codec_t*)vtrack->codec)->fourcc, QUICKTIME_MP4V))
{
unsigned char temp[1024];
unsigned char *ptr = temp;
for(i = 0; i < bytes - 4; i++)
{
if(!(codec->work_buffer[i] == 0x00 &&
codec->work_buffer[i + 1] == 0x00 &&
codec->work_buffer[i + 2] == 0x01 &&
codec->work_buffer[i + 3] == 0xb3))
{
*ptr++ = codec->work_buffer[i];
}
else
break;
}
quicktime_set_mpeg4_header(&trak->mdia.minf.stbl.stsd.table[0],
temp,
ptr - temp);
trak->mdia.minf.stbl.stsd.table[0].version = 0;
}
}
 
 
1170,11 → 1290,10
vtrack->current_chunk,
&chunk_atom,
1);
if(is_keyframe)
if(is_keyframe || vtrack->current_position == 0)
quicktime_insert_keyframe(file,
vtrack->current_position,
track);
//printf("encode 10\n");
 
vtrack->current_chunk++;
return result;
1185,7 → 1304,43
 
 
 
static void flush(quicktime_t *file, int track)
{
quicktime_video_map_t *track_map = &(file->vtracks[track]);
quicktime_trak_t *trak = track_map->track;
quicktime_mpeg4_codec_t *codec = ((quicktime_codec_t*)track_map->codec)->priv;
 
// Create header
if(!trak->mdia.minf.stbl.stsd.table[0].esds.mpeg4_header_size &&
!strcmp(((quicktime_codec_t*)track_map->codec)->fourcc, QUICKTIME_MP4V))
{
int width = trak->tkhd.track_width;
int height = trak->tkhd.track_height;
int width_i = quicktime_quantize16(width);
int height_i = quicktime_quantize16(height);
 
unsigned char temp[1024];
int size = write_mp4v_header(temp,
width_i,
height_i,
quicktime_frame_rate(file, track));
quicktime_set_mpeg4_header(&trak->mdia.minf.stbl.stsd.table[0],
temp,
size);
}
 
// Create udta
file->moov.udta.require = strdup("QuickTime 6.0 or greater");
file->moov.udta.require_len = strlen(file->moov.udta.require);
}
 
 
 
 
 
 
 
 
static int set_parameter(quicktime_t *file,
int track,
char *key,
1236,25 → 1391,26
codec->use_deblocking = *(int*)value;
}
else
if(quicktime_match_32(compressor, QUICKTIME_DIV3))
if(quicktime_match_32(compressor, QUICKTIME_DIV3) ||
quicktime_match_32(compressor, QUICKTIME_MP4V))
{
quicktime_mpeg4_codec_t *codec = ((quicktime_codec_t*)vtrack->codec)->priv;
if(!strcasecmp(key, "div3_bitrate"))
if(!strcasecmp(key, "ffmpeg_bitrate"))
codec->bitrate = *(int*)value;
else
if(!strcasecmp(key, "div3_bitrate_tolerance"))
if(!strcasecmp(key, "ffmpeg_bitrate_tolerance"))
codec->bitrate_tolerance = *(int*)value;
else
if(!strcasecmp(key, "div3_interlaced"))
if(!strcasecmp(key, "ffmpeg_interlaced"))
codec->interlaced = *(int*)value;
else
if(!strcasecmp(key, "div3_gop_size"))
if(!strcasecmp(key, "ffmpeg_gop_size"))
codec->gop_size = *(int*)value;
else
if(!strcasecmp(key, "div3_quantizer"))
if(!strcasecmp(key, "ffmpeg_quantizer"))
codec->quantizer = *(int*)value;
else
if(!strcasecmp(key, "div3_fix_bitrate"))
if(!strcasecmp(key, "ffmpeg_fix_bitrate"))
codec->fix_bitrate = *(int*)value;
}
return 0;
1315,6 → 1471,7
codec_base->delete_vcodec = delete_codec;
codec_base->decode_video = decode;
codec_base->encode_video = encode;
codec_base->flush = flush;
codec_base->reads_colormodel = reads_colormodel;
codec_base->writes_colormodel = writes_colormodel;
codec_base->set_parameter = set_parameter;
1357,6 → 1514,15
result->ffmpeg_id = CODEC_ID_MSMPEG4V3;
}
 
void quicktime_init_codec_div5(quicktime_video_map_t *vtrack)
{
quicktime_mpeg4_codec_t *result = init_common(vtrack,
QUICKTIME_DX50,
"DIVX",
"Mike Row Soft MPEG4 Version 5");
result->ffmpeg_id = CODEC_ID_MPEG4;
}
 
// Mike Rowe Soft MPEG-4
void quicktime_init_codec_div3lower(quicktime_video_map_t *vtrack)
{
1381,16 → 1547,17
{
quicktime_mpeg4_codec_t *result = init_common(vtrack,
QUICKTIME_DIVX,
"MPEG4",
"MPEG-4",
"Generic MPEG Four");
result->ffmpeg_id = CODEC_ID_MPEG4;
result->use_encore = 1;
}
 
void quicktime_init_codec_mpg4(quicktime_video_map_t *vtrack)
{
quicktime_mpeg4_codec_t *result = init_common(vtrack,
QUICKTIME_MPG4,
"MPEG4",
"MPEG-4",
"FFMPEG (msmpeg4)");
result->ffmpeg_id = CODEC_ID_MSMPEG4V1;
}
1399,7 → 1566,7
{
quicktime_mpeg4_codec_t *result = init_common(vtrack,
QUICKTIME_DX50,
"MPEG4",
"MPEG-4",
"FFMPEG (mpeg4)");
result->ffmpeg_id = CODEC_ID_MPEG4;
}
1412,6 → 1579,7
"MPEG4",
"Generic MPEG Four");
result->ffmpeg_id = CODEC_ID_MPEG4;
// result->use_encore = 1;
}
 
 
1438,17 → 1606,26
{
quicktime_mpeg4_codec_t *result = init_common(vtrack,
QUICKTIME_H263,
"h263",
"H.263",
"H.263");
result->ffmpeg_id = CODEC_ID_H263;
}
 
void quicktime_init_codec_xvid(quicktime_video_map_t *vtrack)
{
quicktime_mpeg4_codec_t *result = init_common(vtrack,
QUICKTIME_XVID,
"XVID",
"FFmpeg MPEG-4");
result->ffmpeg_id = CODEC_ID_MPEG4;
}
 
// field based MPEG-4
void quicktime_init_codec_hv60(quicktime_video_map_t *vtrack)
{
quicktime_mpeg4_codec_t *result = init_common(vtrack,
QUICKTIME_HV60,
"Heroine 60",
"Dual MPEG-4",
"MPEG 4 with alternating streams every other frame. (Not standardized)");
result->total_fields = 2;
result->ffmpeg_id = CODEC_ID_MPEG4;
/branches/automake-1_1_5/hvirtual/quicktime/mpeg4.h
14,6 → 14,8
extern void quicktime_init_codec_svq1(quicktime_video_map_t *);
extern void quicktime_init_codec_svq3(quicktime_video_map_t *);
extern void quicktime_init_codec_h263(quicktime_video_map_t *);
extern void quicktime_init_codec_xvid(quicktime_video_map_t *);
extern void quicktime_init_codec_div5(quicktime_video_map_t *vtrack);
 
 
#endif
/branches/automake-1_1_5/hvirtual/quicktime/Makefile
18,14 → 18,51
ENCORE_INCLUDE := $(ENCORE_DIR)/encore.h
#DECORE_INCLUDE := $(DECORE_DIR)/decore.h
MPEG3_DIR := $(shell expr ../libmpeg3* )
FAAD_DIR := faad2
FAAC_DIR := faac
OBJS :=
 
 
FFMPEG_DIR := ffmpeg.071405
FFMPEG_LIB := $(OBJDIR)/ffmpeg/
FFMPEG_INCLUDE := $(FFMPEG_DIR)/libavcodec
 
FAAD_DIR := faad2-2.0
FAAD_LIB := $(OBJDIR)/faad/
FAAD_INCLUDE := $(FAAD_DIR)/include/
 
FAAC_DIR := faac-1.24
FAAC_LIB := $(OBJDIR)/faac/
FAAC_INCLUDE := $(FAAC_DIR)/include/
 
X264_DIR := x264.071405
X264_LIB := $(OBJDIR)/x264
X264_INCLUDE := $(X264_DIR)
 
DV_DIR := libdv-0.104
DV_LIB := $(OBJDIR)/libdv
DV_INCLUDE := $(DV_DIR)
 
OGG_DIR := $(shell expr libogg* )
OGG_LIB := $(OBJDIR)/ogg
 
VORBIS_DIR := $(shell expr libvorbis* )
VORBIS_LIB := $(OBJDIR)/vorbis
 
ifeq ($(OBJDIR), i686)
 
JPEG_DIR := $(shell expr jpeg-mmx* )
JPEG_LIB := $(OBJDIR)/jpeg
JPEG_LIB2 := $(JPEG_DIR)/libjpeg-mmx.a
JPEG_INCLUDE := $(JPEG_DIR)
 
else
 
JPEG_DIR := jpeg
JPEG_LIB := $(OBJDIR)/jpeg
JPEG_LIB2 := $(JPEG_DIR)/libjpeg.a
JPEG_INCLUDE := $(JPEG_DIR)
 
endif
 
ifneq ($(HAVE_CFLAGS), y)
 
 
52,14 → 89,11
 
 
 
include Makefile.jpeg
include Makefile.vorbis
include Makefile.ffmpeg
#include Makefile.jpeg
#include Makefile.vorbis
include Makefile.lame
include Makefile.dv
#include Makefile.dv
include Makefile.encore50
include Makefile.faad
include Makefile.faac
 
 
 
68,14 → 102,8
#CFLAGS += -g
CFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
CFLAGS += -DHAVE_FIREWIRE
CFLAGS += -I. \
-I$(JPEG_DIR) \
-I$(MPEG3_DIR) \
-I$(LAME_DIR)/include
 
 
# $(OBJDIR)/div3.o \
# $(OBJDIR)/divx.o \
 
 
 
84,6 → 112,7
 
OBJS += \
$(OBJDIR)/atom.o \
$(OBJDIR)/avcc.o \
$(OBJDIR)/avi_hdrl.o \
$(OBJDIR)/avi_ix.o \
$(OBJDIR)/avi_idx1.o \
101,7 → 130,6
$(OBJDIR)/ctab.o \
$(OBJDIR)/dinf.o \
$(OBJDIR)/dref.o \
$(OBJDIR)/dv.o \
$(OBJDIR)/edts.o \
$(OBJDIR)/elst.o \
$(OBJDIR)/esds.o \
109,7 → 137,6
$(OBJDIR)/hdlr.o \
$(OBJDIR)/ima4.o \
$(OBJDIR)/jpeg.o \
$(OBJDIR)/jpeg_old.o \
$(OBJDIR)/libdv.o \
$(OBJDIR)/libmjpeg.o \
$(OBJDIR)/matrix.o \
122,6 → 149,9
$(OBJDIR)/mpeg4.o \
$(OBJDIR)/mvhd.o \
$(OBJDIR)/plugin.o \
$(OBJDIR)/qtdv.o \
$(OBJDIR)/qtffmpeg.o \
$(OBJDIR)/qth264.o \
$(OBJDIR)/qtpng.o \
$(OBJDIR)/qtmp3.o \
$(OBJDIR)/quicktime.o \
173,46 → 203,23
SHAREDOUTPUT = $(OBJDIR)/libquicktime.so
 
CFLAGS += \
-I. \
-I$(ENCORE_DIR) \
-I$(FAAC_INCLUDE) \
-I$(FAAD_INCLUDE) \
-I$(FFMPEG_INCLUDE) \
-DENCORE_INCLUDE=\"$(ENCORE_INCLUDE)\" \
-DLINUX
 
# -DDECORE_INCLUDE=\"$(DECORE_INCLUDE)\" \
# -I$(DECORE_DIR) \
# -D_DECORE
 
 
CFLAGS += \
-I$(X264_INCLUDE) \
-I$(DV_INCLUDE) \
-I$(JPEG_INCLUDE) \
-I$(MPEG3_DIR) \
-I$(LAME_DIR)/include \
-I$(OGG_DIR)/include \
-I$(VORBIS_DIR)/include \
-ffast-math \
-mno-ieee-fp \
-DHAVE_ALLOCA_H=1 \
-DHAVE_ALLOCA=1 \
-DHAVE_SQRTF=1 \
-DHAVE_LOGF=1 \
-DHAVE_EXPF=1 \
-DHAVE_ACOSF=1 \
-DHAVE_ATANF=1 \
-DHAVE_FREXPF=1 \
-DHAVE_RINTF=1 \
-DUSE_MEMORY_H \
-D_REENTRANT \
-DHAVE_ALLOCA=1 \
-DHAVE_ALLOCA_H=1 \
-DVORBIS_IEEE_FLOAT32 \
-DHAVE_DLFCN_H=1 \
-DSTDC_HEADERS=1 \
-DSIZEOF_SHORT=2 \
-DSIZEOF_INT=4 \
-DSIZEOF_LONG=4 \
-DSIZEOF_LONG_LONG=8 \
-DUSE_MEMORY_H
-mno-ieee-fp
 
CFLAGS += \
-I$(FFMPEG_DIR)/libavcodec/ \
-I$(FFMPEG_DIR)/libav
 
 
 
#DIRS += \
# $(OBJDIR)/$(DECORE_DIR)/intel_mmx/postprocess
 
235,20 → 242,73
 
$(shell if ! test -d $(OBJDIR) \; then mkdir -p $(DIRS) \; fi )
$(shell echo $(CFLAGS) > $(OBJDIR)/c_flags)
$(shell echo $(FFMPEG_CFLAGS) > $(OBJDIR)/ffmpeg_flags)
$(shell echo $(FAAD_CFLAGS) > $(OBJDIR)/faad_flags)
$(shell echo $(FAAC_CFLAGS) > $(OBJDIR)/faac_flags)
$(shell echo $(LAME_CFLAGS) > $(OBJDIR)/lame_flags)
$(shell echo $(OBJS) $(DV_OBJS) $(DVMMXOBJS) $(ENCOREMMX_OBJS) $(JPEG_NASM) $(JPEG_FAIL) $(FFMPEG_OBJS) $(FFMPEGIA32_OBJS) $(LAME_OBJS) $(FAAD_OBJS) $(FAAC_OBJS) > $(OBJDIR)/objs)
#$(shell echo $(OBJS) $(DV_OBJS) $(DVMMXOBJS) $(DECOREMMX_OBJS) $(ENCOREMMX_OBJS) $(JPEG_NASM) $(JPEG_FAIL) $(FFMPEG_OBJS) $(FFMPEGIA32_OBJS) $(LAME_OBJS) > $(OBJDIR)/objs)
$(shell echo $(OBJS) $(JPEG_LIB)/*.o $(DV_LIB)/*.o $(FAAD_LIB)/*.o $(FAAC_LIB)/*.o $(FFMPEG_LIB)/*.o $(X264_LIB)/*.o $(OGG_LIB)/*.o $(VORBIS_LIB)/*.o $(LAME_OBJS) > $(OBJDIR)/objs)
 
all: $(OBJDIR) $(OUTPUT)
 
#$(OUTPUT): $(DV_OBJS) $(DVMMXOBJ) $(OBJS) $(DVMMXOBJS) $(DECOREMMX_OBJS) $(ENCOREMMX_OBJS) $(JPEG_NASM) $(FFMPEG_OBJS) $(FFMPEGIA32_OBJS) $(LAME_OBJS) $(JPEG_FAIL)
$(OUTPUT): $(DV_OBJS) $(DVMMXOBJ) $(OBJS) $(DVMMXOBJS) $(ENCOREMMX_OBJS) $(JPEG_NASM) $(FFMPEG_OBJS) $(FFMPEGIA32_OBJS) $(LAME_OBJS) $(FAAD_OBJS) $(FAAC_OBJS) $(JPEG_FAIL)
$(OUTPUT): $(OBJS) $(ENCOREMMX_OBJS) $(JPEG_NASM) $(LAME_OBJS) $(FAAD_LIB) $(FAAC_LIB) $(FFMPEG_LIB) $(X264_LIB) $(DV_LIB) $(JPEG_LIB) $(OGG_LIB)/ $(VORBIS_LIB)
ar rcs $(OUTPUT) `cat $(OBJDIR)/objs`
 
# this is the only way we figured out to merge .a files
$(FFMPEG_LIB):
$(MAKE) -C $(FFMPEG_DIR) && \
mkdir -p $(FFMPEG_LIB) && \
cd $(FFMPEG_LIB) && \
ar x ../../$(FFMPEG_DIR)/libavcodec/libavcodec.a
 
$(FAAD_LIB):
$(MAKE) -C $(FAAD_DIR) && \
mkdir -p $(FAAD_LIB) && \
cd $(FAAD_LIB) && \
ar x ../../$(FAAD_DIR)/libfaad/.libs/libfaad.a
 
$(FAAC_LIB):
$(MAKE) -C $(FAAC_DIR) && \
mkdir -p $(FAAC_LIB) && \
cd $(FAAC_LIB) && \
ar x ../../$(FAAC_DIR)/libfaac/.libs/libfaac.a
 
$(DV_LIB):
$(MAKE) -C $(DV_DIR) && \
mkdir -p $(DV_LIB) && \
cd $(DV_LIB) && \
ar x ../../$(DV_DIR)/libdv/.libs/libdv.a
 
$(JPEG_LIB):
$(MAKE) -C $(JPEG_DIR) && \
mkdir -p $(JPEG_LIB) && \
cd $(JPEG_LIB) && \
ar x ../../$(JPEG_LIB2)
 
# need some trickery to get the duplicated filenames out
$(X264_LIB):
$(MAKE) -C $(X264_DIR) && \
mkdir -p $(X264_LIB) && \
cd $(X264_LIB) && \
ar x ../../$(X264_DIR)/libx264.a && \
mv predict.o predict2.o && \
mv cabac.o cabac2.o && \
mv macroblock.o macroblock2.o && \
mv set.o set2.o && \
ar xN 1 ../../$(X264_DIR)/libx264.a predict.o cabac.o macroblock.o set.o
 
$(OGG_LIB):
$(MAKE) -C $(OGG_DIR) && \
mkdir -p $(OGG_LIB) && \
cd $(OGG_LIB) && \
ar x ../../$(OGG_DIR)/src/.libs/libogg.a
 
$(VORBIS_LIB):
$(MAKE) -C $(VORBIS_DIR) && \
mkdir -p $(VORBIS_LIB) && \
cd $(VORBIS_LIB) && \
ar x ../../$(VORBIS_DIR)/lib/.libs/libvorbis.a && \
ar x ../../$(VORBIS_DIR)/lib/.libs/libvorbisenc.a && \
ar x ../../$(VORBIS_DIR)/lib/.libs/libvorbisfile.a
 
 
 
$(OBJDIR)/qtdump: $(OBJDIR)/dump.o $(OUTPUT)
$(CC) -o $(OBJDIR)/qtdump $(OBJDIR)/dump.o $(LIBS)
 
274,8 → 334,15
 
clean:
rm -rf $(OBJDIR)
rm -f $(DVMMXOBJ)
find \( -name 'core*' \
-o -name '*.lo' \
-o -name '*.o' \
-o -name '*.la' \
-o -name '*.a' \
-o -name '*.plugin' \
-o -name '*.so' \) -exec rm -f {} \; -prune
find \( -name $(OBJDIR) \) -exec rm -rf {} \; -prune
find \( -name .deps \) -exec rm -rf {} \; -prune
 
wc:
cat *.c *.h | wc
303,11 → 370,11
$(DV_OBJS):
$(CC) -c `cat $(OBJDIR)/c_flags` $(subst $(OBJDIR)/,, $*.c) -o $*.o
 
$(FAAD_OBJS):
$(CC) -c `cat $(OBJDIR)/faad_flags` $(subst $(OBJDIR)/,, $*.c) -o $*.o
#$(FAAD_OBJS):
# $(CC) -c `cat $(OBJDIR)/faad_flags` $(subst $(OBJDIR)/,, $*.c) -o $*.o
 
$(FAAC_OBJS):
$(CC) -c `cat $(OBJDIR)/faac_flags` $(subst $(OBJDIR)/,, $*.c) -o $*.o
#$(FAAC_OBJS):
# $(CC) -c `cat $(OBJDIR)/faac_flags` $(subst $(OBJDIR)/,, $*.c) -o $*.o
 
$(DVMMXOBJS):
$(CC) -c `cat $(OBJDIR)/c_flags` $(subst $(OBJDIR)/,, $*.S) -o $*.o
326,8 → 393,8
# $(CC) -c `cat $(OBJDIR)/c_flags` $(subst $(OBJDIR)/,, $*.S) -o $*.o
 
 
$(FFMPEG_OBJS) $(FFMPEGIA32_OBJS):
$(CC) `cat $(OBJDIR)/ffmpeg_flags` -c $(subst $(OBJDIR)/,, $*.c) -o $*.o
#$(FFMPEG_OBJS) $(FFMPEGIA32_OBJS):
# $(CC) `cat $(OBJDIR)/ffmpeg_flags` -c $(subst $(OBJDIR)/,, $*.c) -o $*.o
 
$(LAME_OBJS):
$(CC) `cat $(OBJDIR)/lame_flags` -c $(subst $(OBJDIR)/,, $*.c) -o $*.o
343,6 → 410,7
 
 
$(OBJDIR)/atom.o: atom.c
$(OBJDIR)/avcc.o: avcc.c
$(OBJDIR)/avi_hdrl.o: avi_hdrl.c
$(OBJDIR)/avi_ix.o: avi_ix.c
$(OBJDIR)/avi_idx1.o: avi_idx1.c
362,7 → 430,6
$(OBJDIR)/dinf.o: dinf.c
$(OBJDIR)/dref.o: dref.c
$(OBJDIR)/dump.o: dump.c
$(OBJDIR)/dv.o: dv.c
$(OBJDIR)/edts.o: edts.c
$(OBJDIR)/elst.o: elst.c
$(OBJDIR)/esds.o: esds.c
370,7 → 437,6
$(OBJDIR)/hdlr.o: hdlr.c
$(OBJDIR)/ima4.o: ima4.c
$(OBJDIR)/jpeg.o: jpeg.c
$(OBJDIR)/jpeg_old.o: jpeg_old.c
$(OBJDIR)/libdv.o: libdv.c
$(OBJDIR)/libmjpeg.o: libmjpeg.c
$(OBJDIR)/make_streamable.o: make_streamable.c
384,6 → 450,9
$(OBJDIR)/mp4a.o: mp4a.c
$(OBJDIR)/mvhd.o: mvhd.c
$(OBJDIR)/plugin.o: plugin.c
$(OBJDIR)/qtdv.o: qtdv.c
$(OBJDIR)/qtffmpeg.o: qtffmpeg.c
$(OBJDIR)/qth264.o: qth264.c
$(OBJDIR)/qtinfo.o: qtinfo.c
$(OBJDIR)/qtmp3.o: qtmp3.c
$(OBJDIR)/qtpng.o: qtpng.c
463,11 → 532,11
 
 
 
include depend.vorbis
include depend.ffmpeg
include depend.jpeg
#include depend.vorbis
#include depend.ffmpeg
#include depend.jpeg
include depend.lame
include depend.dv
#include depend.dv
include depend.encore50
include depend.faad
include depend.faac
#include depend.faad
#include depend.faac
/branches/automake-1_1_5/hvirtual/quicktime/mp4a.c
1,4 → 1,15
#include "faad2/include/faad.h"
#include <stdint.h>
 
#include "faac.h"
 
// The FAAD includes redefine the same symbols as if they're not intended to
// be used by the same program.
#undef MAIN
#undef SSR
#undef LTP
 
 
#include "faad.h"
#include "funcprotos.h"
#include "quicktime.h"
 
14,7 → 25,24
faacDecHandle decoder_handle;
faacDecFrameInfo frame_info;
faacDecConfigurationPtr decoder_config;
int initialized;
int decoder_initialized;
 
 
faacEncHandle encoder_handle;
faacEncConfigurationPtr encoder_params;
// Number of frames
int frame_size;
int max_frame_bytes;
// Interleaved samples
float *input_buffer;
// Number of frames
int input_size;
// Number of samples allocated
int input_allocated;
unsigned char *compressed_buffer;
int bitrate;
int quantizer_quality;
int encoder_initialized;
} quicktime_mp4a_codec_t;
 
 
26,11 → 54,19
{
quicktime_mp4a_codec_t *codec =
((quicktime_codec_t*)atrack->codec)->priv;
if(codec->initialized)
 
if(codec->decoder_initialized)
{
faacDecClose(codec->decoder_handle);
}
 
if(codec->encoder_initialized)
{
faacEncClose(codec->encoder_handle);
if(codec->compressed_buffer) free(codec->compressed_buffer);
if(codec->input_buffer) free(codec->input_buffer);
}
 
free(codec);
}
 
50,26 → 86,32
 
 
// Initialize decoder
if(!codec->initialized)
if(!codec->decoder_initialized)
{
unsigned long samplerate = trak->mdia.minf.stbl.stsd.table[0].sample_rate;
uint32_t samplerate = trak->mdia.minf.stbl.stsd.table[0].sample_rate;
// FAAD needs unsigned char here
unsigned char channels = track_map->channels;
quicktime_init_vbr(vbr, channels);
codec->decoder_handle = faacDecOpen();
codec->decoder_config = faacDecGetCurrentConfiguration(codec->decoder_handle);
codec->decoder_config->outputFormat = FAAD_FMT_FLOAT;
codec->decoder_config->defSampleRate =
trak->mdia.minf.stbl.stsd.table[0].sample_rate;
// codec->decoder_config->defSampleRate =
// trak->mdia.minf.stbl.stsd.table[0].sample_rate;
 
faacDecSetConfiguration(codec->decoder_handle, codec->decoder_config);
quicktime_align_vbr(track_map, samples);
quicktime_read_vbr(file, track_map);
if(faacDecInit(codec->decoder_handle,
0,
0,
quicktime_vbr_input(vbr),
quicktime_vbr_input_size(vbr),
&samplerate,
&channels) < 0)
{
return 1;
}
codec->initialized = 1;
//printf("decode %d %d\n", samplerate, channels);
codec->decoder_initialized = 1;
}
 
if(quicktime_align_vbr(track_map,
82,18 → 124,46
// Decode until buffer is full
while(quicktime_vbr_end(vbr) < end_position)
{
if(!quicktime_read_vbr(file, track_map))
{
faacDecFrameInfo frame_info;
float *sample_buffer = faacDecDecode(codec->decoder_handle,
&frame_info,
quicktime_vbr_input(vbr),
quicktime_vbr_input_size(vbr));
// Fill until min buffer size reached or EOF
/*
* while(quicktime_vbr_input_size(vbr) <
* FAAD_MIN_STREAMSIZE * track_map->channels)
* {
* if(quicktime_read_vbr(file, track_map)) break;
* }
*/
 
if(quicktime_read_vbr(file, track_map)) break;
 
bzero(&codec->frame_info, sizeof(faacDecFrameInfo));
float *sample_buffer = faacDecDecode(codec->decoder_handle,
&codec->frame_info,
quicktime_vbr_input(vbr),
quicktime_vbr_input_size(vbr));
 
if (codec->frame_info.error > 0)
{
// printf("decode mp4a: %s\n",
// faacDecGetErrorMessage(codec->frame_info.error));
}
 
/*
* printf("decode 1 %d %d %d\n",
* quicktime_vbr_input_size(vbr),
* codec->frame_info.bytesconsumed,
* codec->frame_info.samples);
*
* static FILE *test = 0;
* if(!test) test = fopen("/tmp/test.aac", "w");
* fwrite(quicktime_vbr_input(vbr), quicktime_vbr_input_size(vbr), 1, test);
*/
 
 
/*
* static FILE *test = 0;
* if(!test) test = fopen("/hmov/test.pcm", "w");
* int i;
* for(i = 0; i < frame_info.samples; i++)
* for(i = 0; i < codec->frame_info.samples; i++)
* {
* int16_t sample = (int)(sample_buffer[i] * 32767);
* fwrite(&sample, 2, 1, test);
101,16 → 171,14
* fflush(test);
*/
 
// quicktime_shift_vbr(track_map, codec->frame_info.bytesconsumed);
quicktime_shift_vbr(track_map, quicktime_vbr_input_size(vbr));
quicktime_store_vbr_float(track_map,
sample_buffer,
frame_info.samples / track_map->channels);
}
else
{
break;
}
codec->frame_info.samples / track_map->channels);
}
 
 
// Transfer from buffer to output
if(output_i)
quicktime_copy_vbr_int16(vbr,
130,8 → 198,207
}
 
 
static int encode(quicktime_t *file,
int16_t **input_i,
float **input_f,
int track,
long samples)
{
int result = 0;
quicktime_audio_map_t *track_map = &(file->atracks[track]);
quicktime_trak_t *trak = track_map->track;
quicktime_mp4a_codec_t *codec = ((quicktime_codec_t*)track_map->codec)->priv;
int channels = quicktime_track_channels(file, track);
int i, j, k;
 
if(!codec->encoder_initialized)
{
unsigned long input_samples;
unsigned long max_output_bytes;
int sample_rate = quicktime_sample_rate(file, track);
codec->encoder_initialized = 1;
codec->encoder_handle = faacEncOpen(quicktime_sample_rate(file, track),
channels,
&input_samples,
&max_output_bytes);
 
codec->frame_size = input_samples / channels;
codec->max_frame_bytes = max_output_bytes;
codec->compressed_buffer = calloc(1, max_output_bytes);
codec->encoder_params = faacEncGetCurrentConfiguration(codec->encoder_handle);
 
// Parameters from ffmpeg
codec->encoder_params->aacObjectType = LOW;
codec->encoder_params->mpegVersion = MPEG4;
codec->encoder_params->useTns = 0;
codec->encoder_params->allowMidside = 1;
codec->encoder_params->inputFormat = FAAC_INPUT_FLOAT;
codec->encoder_params->outputFormat = 0;
codec->encoder_params->bitRate = codec->bitrate / channels;
codec->encoder_params->quantqual = codec->quantizer_quality;
codec->encoder_params->bandWidth = sample_rate / 2;
 
if(!faacEncSetConfiguration(codec->encoder_handle, codec->encoder_params))
{
fprintf(stderr, "encode: unsupported MPEG-4 Audio configuration!@#!@#\n");
return 1;
}
 
 
 
// Create esds header
unsigned char *buffer;
unsigned long buffer_size;
faacEncGetDecoderSpecificInfo(codec->encoder_handle,
&buffer,
&buffer_size);
quicktime_set_mpeg4_header(&trak->mdia.minf.stbl.stsd.table[0],
buffer,
buffer_size);
trak->mdia.minf.stbl.stsd.table[0].version = 1;
// Quicktime player needs this.
trak->mdia.minf.stbl.stsd.table[0].compression_id = 0xfffe;
}
 
 
// Stack new audio at end of old audio
int new_allocation = codec->input_size + samples;
if(new_allocation > codec->input_allocated)
{
codec->input_buffer = realloc(codec->input_buffer,
new_allocation *
sizeof(float) *
channels);
codec->input_allocated = new_allocation;
}
 
float *output = (float*)codec->input_buffer + codec->input_size * channels;
if(input_f)
{
for(i = 0; i < samples; i++)
{
for(j = 0; j < channels; j++)
{
*output++ = input_f[j][i] * 32767;
}
}
}
else
if(input_i)
{
for(i = 0; i < samples; i++)
{
for(j = 0; j < channels; j++)
{
*output++ = (float)input_i[j][i];
}
}
}
 
codec->input_size += samples;
 
 
for(i = 0; i + codec->frame_size < codec->input_size; i += codec->frame_size)
{
int bytes = faacEncEncode(codec->encoder_handle,
(int32_t*)(codec->input_buffer + i * channels),
codec->frame_size * channels,
codec->compressed_buffer,
codec->max_frame_bytes);
/*
* printf("encode 1 %lld %d %d\n",
* track_map->current_position,
* codec->frame_size,
* bytes);
*/
// Write out the packet
if(bytes)
{
quicktime_write_vbr_frame(file,
track,
codec->compressed_buffer,
bytes,
codec->frame_size);
}
}
 
for(j = i * channels, k = 0; j < codec->input_size * channels; j++, k++)
{
codec->input_buffer[k] = codec->input_buffer[j];
}
codec->input_size -= i;
 
return result;
}
 
 
 
static void flush(quicktime_t *file, int track)
{
quicktime_audio_map_t *track_map = &(file->atracks[track]);
quicktime_trak_t *trak = track_map->track;
quicktime_mp4a_codec_t *codec = ((quicktime_codec_t*)track_map->codec)->priv;
int channels = quicktime_track_channels(file, track);
int i;
if(codec->encoder_initialized)
{
for(i = 0;
i < codec->input_size &&
i + codec->frame_size < codec->input_allocated;
i += codec->frame_size)
{
int bytes = faacEncEncode(codec->encoder_handle,
(int32_t*)(codec->input_buffer + i * channels),
codec->frame_size * channels,
codec->compressed_buffer,
codec->max_frame_bytes);
 
/*
* printf("flush 1 %d %d %d\n",
* codec->encoder_params->bitRate,
* bytes,
* codec->max_frame_bytes);
*/
// Write out the packet
if(bytes)
{
quicktime_write_vbr_frame(file,
track,
codec->compressed_buffer,
bytes,
codec->frame_size);
}
}
}
}
 
 
static int set_parameter(quicktime_t *file,
int track,
char *key,
void *value)
{
quicktime_audio_map_t *atrack = &(file->atracks[track]);
char *compressor = quicktime_compressor(atrack->track);
 
if(quicktime_match_32(compressor, QUICKTIME_MP4A))
{
quicktime_mp4a_codec_t *codec = ((quicktime_codec_t*)atrack->codec)->priv;
if(!strcasecmp(key, "mp4a_bitrate"))
{
codec->bitrate = *(int*)value;
}
else
if(!strcasecmp(key, "mp4a_quantqual"))
{
codec->quantizer_quality = *(int*)value;
}
}
return 0;
}
 
 
 
void quicktime_init_codec_mp4a(quicktime_audio_map_t *atrack)
{
quicktime_codec_t *codec_base = (quicktime_codec_t*)atrack->codec;
139,12 → 406,17
codec_base->priv = calloc(1, sizeof(quicktime_mp4a_codec_t));
codec_base->delete_acodec = delete_codec;
codec_base->decode_audio = decode;
codec_base->encode_audio = encode;
codec_base->set_parameter = set_parameter;
codec_base->flush = flush;
codec_base->fourcc = "mp4a";
codec_base->title = "Advanced Audio Codec";
codec_base->title = "MPEG4 audio";
codec_base->desc = "Audio section of MPEG4 standard";
 
codec = (quicktime_mp4a_codec_t*)codec_base->priv;
// Default encoding parameters here
codec->bitrate = 256000;
codec->quantizer_quality = 100;
}
 
 
/branches/automake-1_1_6/hvirtual/quicktime/stbl.c
98,7 → 98,14
{ quicktime_read_stss(file, &(stbl->stss)); }
else
if(quicktime_atom_is(&leaf_atom, "stsc"))
{ quicktime_read_stsc(file, &(stbl->stsc)); }
{
quicktime_read_stsc(file, &(stbl->stsc));
/*
* Minolta DimageZ3 pads stsc with zeroes
* so we need to jump to next atom explicitly
*/
quicktime_atom_skip(file, &leaf_atom);
}
else
if(quicktime_atom_is(&leaf_atom, "stsz"))
{ quicktime_read_stsz(file, &(stbl->stsz)); }
/branches/automake-1_1_6/hvirtual/quicktime/quicktime.c
483,7 → 483,8
if(track >= file->total_vtracks)
{
fprintf(stderr,
"quicktime_set_video_position: track %d >= file->total_vtracks %d\n",
"quicktime_set_video_position: frame=%lld track=%d >= file->total_vtracks %d\n",
frame,
track,
file->total_vtracks);
track = file->total_vtracks - 1;
498,8 → 499,6
offset = quicktime_sample_to_offset(file, trak, frame);
quicktime_set_position(file, offset);
}
else
fprintf(stderr, "quicktime_set_video_position: track >= file->total_vtracks\n");
return 0;
}
 
512,7 → 511,10
long quicktime_sample_rate(quicktime_t *file, int track)
{
if(file->total_atracks)
return file->atracks[track].track->mdia.minf.stbl.stsd.table[0].sample_rate;
{
quicktime_trak_t *trak = file->atracks[track].track;
return trak->mdia.minf.stbl.stsd.table[0].sample_rate;
}
return 0;
}
 
632,12 → 634,31
double quicktime_frame_rate(quicktime_t *file, int track)
{
if(file->total_vtracks > track)
return (float)file->vtracks[track].track->mdia.mdhd.time_scale /
file->vtracks[track].track->mdia.minf.stbl.stts.table[0].sample_duration;
{
quicktime_trak_t *trak = file->vtracks[track].track;
int time_scale = file->vtracks[track].track->mdia.mdhd.time_scale;
int sample_duration = quicktime_sample_duration(trak);
return (double)time_scale / sample_duration;
// return (float)file->vtracks[track].track->mdia.mdhd.time_scale /
// file->vtracks[track].track->mdia.minf.stbl.stts.table[0].sample_duration;
}
return 0;
}
 
int quicktime_frame_rate_n(quicktime_t *file, int track)
{
if(file->total_vtracks > track)
return file->vtracks[track].track->mdia.mdhd.time_scale;
return 0;
}
 
int quicktime_frame_rate_d(quicktime_t *file, int track)
{
if(file->total_vtracks > track)
return file->vtracks[track].track->mdia.minf.stbl.stts.table[0].sample_duration;
return 0;
}
 
char* quicktime_video_compressor(quicktime_t *file, int track)
{
return file->vtracks[track].track->mdia.minf.stbl.stsd.table[0].format;
795,7 → 816,7
return bytes;
}
 
long quicktime_get_keyframe_before(quicktime_t *file, long frame, int track)
int64_t quicktime_get_keyframe_before(quicktime_t *file, int64_t frame, int track)
{
quicktime_trak_t *trak = file->vtracks[track].track;
quicktime_stss_t *stss = &trak->mdia.minf.stbl.stss;
817,7 → 838,7
return 0;
}
 
long quicktime_get_keyframe_after(quicktime_t *file, long frame, int track)
int64_t quicktime_get_keyframe_after(quicktime_t *file, int64_t frame, int track)
{
quicktime_trak_t *trak = file->vtracks[track].track;
quicktime_stss_t *stss = &trak->mdia.minf.stbl.stss;
839,7 → 860,7
return 0;
}
 
void quicktime_insert_keyframe(quicktime_t *file, long frame, int track)
void quicktime_insert_keyframe(quicktime_t *file, int64_t frame, int track)
{
quicktime_trak_t *trak = file->vtracks[track].track;
quicktime_stss_t *stss = &trak->mdia.minf.stbl.stss;
/branches/automake-1_1_6/hvirtual/quicktime/libdv.h
13,9 → 13,6
#define DV_NTSC 0
#define DV_PAL 1
 
#ifndef u_int64_t
#define u_int64_t unsigned long long
#endif
 
#include "libdv/dv.h"
#include <pthread.h>
/branches/automake-1_1_6/hvirtual/quicktime/udta.c
2,6 → 2,11
#include "quicktime.h"
 
#define DEFAULT_INFO "Made with Quicktime for Linux"
static unsigned char cpy_tag[] = {0xa9, 'c', 'p', 'y'};
static unsigned char nam_tag[] = {0xa9, 'n', 'a', 'm'};
static unsigned char inf_tag[] = {0xa9, 'i', 'n', 'f'};
static unsigned char req_tag[] = {0xa9, 'r', 'e', 'q'};
static unsigned char enc_tag[] = {0xa9, 'e', 'n', 'c'};
 
int quicktime_udta_init(quicktime_udta_t *udta)
{
9,6 → 14,10
udta->copyright_len = 0;
udta->name = 0;
udta->name_len = 0;
udta->require = 0;
udta->require_len = 0;
udta->encoder = 0;
udta->encoder_len = 0;
 
udta->info = malloc(strlen(DEFAULT_INFO) + 1);
udta->info_len = strlen(DEFAULT_INFO);
30,6 → 39,14
{
free(udta->info);
}
if(udta->require_len)
{
free(udta->require);
}
if(udta->encoder_len)
{
free(udta->encoder);
}
// quicktime_udta_init(udta);
return 0;
}
40,6 → 57,8
if(udta->copyright_len) printf(" copyright -> %s\n", udta->copyright);
if(udta->name_len) printf(" name -> %s\n", udta->name);
if(udta->info_len) printf(" info -> %s\n", udta->info);
if(udta->require_len) printf(" require -> %s\n", udta->require);
if(udta->encoder_len) printf(" encoder -> %s\n", udta->encoder);
}
 
int quicktime_read_udta(quicktime_t *file, quicktime_udta_t *udta, quicktime_atom_t *udta_atom)
50,25 → 69,39
do
{
quicktime_atom_read_header(file, &leaf_atom);
if(quicktime_atom_is(&leaf_atom, "©cpy"))
 
 
if(quicktime_atom_is(&leaf_atom, cpy_tag))
{
result += quicktime_read_udta_string(file, &(udta->copyright), &(udta->copyright_len));
}
else
if(quicktime_atom_is(&leaf_atom, "©nam"))
if(quicktime_atom_is(&leaf_atom, nam_tag))
{
result += quicktime_read_udta_string(file, &(udta->name), &(udta->name_len));
}
else
if(quicktime_atom_is(&leaf_atom, "©inf"))
if(quicktime_atom_is(&leaf_atom, inf_tag))
{
result += quicktime_read_udta_string(file, &(udta->info), &(udta->info_len));
}
else
quicktime_atom_skip(file, &leaf_atom);
if(quicktime_atom_is(&leaf_atom, req_tag))
{
result += quicktime_read_udta_string(file, &(udta->require), &(udta->require_len));
}
else
if(quicktime_atom_is(&leaf_atom, enc_tag))
{
result += quicktime_read_udta_string(file, &(udta->encoder), &(udta->encoder_len));
}
else
{
quicktime_atom_skip(file, &leaf_atom);
}
}while(quicktime_position(file) < udta_atom->end);
 
 
return result;
}
 
79,25 → 112,39
 
if(udta->copyright_len)
{
quicktime_atom_write_header(file, &subatom, "©cpy");
quicktime_atom_write_header(file, &subatom, cpy_tag);
quicktime_write_udta_string(file, udta->copyright, udta->copyright_len);
quicktime_atom_write_footer(file, &subatom);
}
 
if(udta->name_len)
{
quicktime_atom_write_header(file, &subatom, "©nam");
quicktime_atom_write_header(file, &subatom, nam_tag);
quicktime_write_udta_string(file, udta->name, udta->name_len);
quicktime_atom_write_footer(file, &subatom);
}
 
if(udta->info_len)
{
quicktime_atom_write_header(file, &subatom, "©inf");
quicktime_atom_write_header(file, &subatom, inf_tag);
quicktime_write_udta_string(file, udta->info, udta->info_len);
quicktime_atom_write_footer(file, &subatom);
}
 
if(udta->require_len)
{
quicktime_atom_write_header(file, &subatom, req_tag);
quicktime_write_udta_string(file, udta->require, udta->require_len);
quicktime_atom_write_footer(file, &subatom);
}
 
if(udta->encoder_len)
{
quicktime_atom_write_header(file, &subatom, enc_tag);
quicktime_write_udta_string(file, udta->encoder, udta->encoder_len);
quicktime_atom_write_footer(file, &subatom);
}
 
quicktime_atom_write_footer(file, &atom);
}
 
/branches/automake-1_1_6/hvirtual/quicktime/stsdtable.c
32,14 → 32,14
unsigned char *data,
int size)
{
if(table->mpeg4_header)
if(table->esds.mpeg4_header)
{
free(table->mpeg4_header);
free(table->esds.mpeg4_header);
}
 
table->mpeg4_header = calloc(1, size);
memcpy(table->mpeg4_header, data, size);
table->mpeg4_header_size = size;
table->esds.mpeg4_header = calloc(1, size);
memcpy(table->esds.mpeg4_header, data, size);
table->esds.mpeg4_header_size = size;
}
 
static void read_wave(quicktime_t *file,
52,14 → 52,16
quicktime_atom_read_header(file, &leaf_atom);
if(quicktime_atom_is(&leaf_atom, "esds"))
{
quicktime_read_esds(file, &leaf_atom, table);
quicktime_read_esds(file, &leaf_atom, &table->esds);
}
else
quicktime_atom_skip(file, &leaf_atom);
}
}
 
void quicktime_read_stsd_audio(quicktime_t *file, quicktime_stsd_table_t *table, quicktime_atom_t *parent_atom)
void quicktime_read_stsd_audio(quicktime_t *file,
quicktime_stsd_table_t *table,
quicktime_atom_t *parent_atom)
{
quicktime_atom_t leaf_atom;
 
78,23 → 80,37
 
 
// Version 1 fields
if(table->version == 1)
if(table->version > 0)
{
table->samples_per_packet = quicktime_read_int32(file);
table->bytes_per_packet = quicktime_read_int32(file);
table->bytes_per_frame = quicktime_read_int32(file);
table->bytes_per_sample = quicktime_read_int32(file);
 
// Skip another 20 bytes
if(table->version == 2)
{
quicktime_set_position(file, quicktime_position(file) + 0x14);
}
 
while(quicktime_position(file) < parent_atom->end)
{
quicktime_atom_read_header(file, &leaf_atom);
 
if(quicktime_atom_is(&leaf_atom, "wave"))
{
read_wave(file, table, &leaf_atom);
}
else
{
quicktime_atom_skip(file, &leaf_atom);
}
}
}
 
// FFMPEG says the esds sometimes contains a sample rate that overrides
// the sample table.
quicktime_esds_samplerate(table, &table->esds);
}
 
void quicktime_write_stsd_audio(quicktime_t *file, quicktime_stsd_table_t *table)
104,9 → 120,36
quicktime_write_data(file, table->vendor, 4);
quicktime_write_int16(file, table->channels);
quicktime_write_int16(file, table->sample_size);
 
quicktime_write_int16(file, table->compression_id);
quicktime_write_int16(file, table->packet_size);
quicktime_write_fixed32(file, table->sample_rate);
 
// Write header for mp4v
if(table->esds.mpeg4_header_size && table->esds.mpeg4_header)
{
// Version 1 info
quicktime_write_int32(file, 0);
quicktime_write_int32(file, 0);
quicktime_write_int32(file, 0);
quicktime_write_int32(file, 0);
 
quicktime_atom_t wave_atom;
quicktime_atom_t frma_atom;
quicktime_atom_t mp4a_atom;
quicktime_atom_write_header(file, &wave_atom, "wave");
 
quicktime_atom_write_header(file, &frma_atom, "frma");
quicktime_write_data(file, "mp4a", 4);
quicktime_atom_write_footer(file, &frma_atom);
 
quicktime_atom_write_header(file, &mp4a_atom, "mp4a");
quicktime_write_int32(file, 0x0);
quicktime_atom_write_footer(file, &mp4a_atom);
 
quicktime_write_esds(file, &table->esds, 0, 1);
quicktime_atom_write_footer(file, &wave_atom);
}
}
 
void quicktime_read_stsd_video(quicktime_t *file,
135,14 → 178,23
while(quicktime_position(file) < parent_atom->end)
{
quicktime_atom_read_header(file, &leaf_atom);
//printf("quicktime_read_stsd_video 1 %llx %llx %llx\n", leaf_atom.start, leaf_atom.end, quicktime_position(file));
/*
* printf("quicktime_read_stsd_video 1 %llx %llx %llx %s\n",
* leaf_atom.start, leaf_atom.end, quicktime_position(file),
* leaf_atom.type);
*/
 
 
if(quicktime_atom_is(&leaf_atom, "esds"))
{
quicktime_read_esds(file, &leaf_atom, table);
quicktime_read_esds(file, &leaf_atom, &table->esds);
}
else
if(quicktime_atom_is(&leaf_atom, "avcC"))
{
quicktime_read_avcc(file, &leaf_atom, &table->avcc);
}
else
if(quicktime_atom_is(&leaf_atom, "ctab"))
{
quicktime_read_ctab(file, &(table->ctab));
207,10 → 259,19
}
 
// Write header for mp4v
if(table->mpeg4_header_size && table->mpeg4_header)
if(table->esds.mpeg4_header_size && table->esds.mpeg4_header)
{
quicktime_write_esds(file, table, 1, 0);
quicktime_write_esds(file, &table->esds, 1, 0);
}
 
if(table->avcc.data_size)
{
quicktime_write_avcc(file, &table->avcc);
}
 
// Write another 32 bits
if(table->version == 1)
quicktime_write_int32(file, 0x0);
}
 
void quicktime_read_stsd_table(quicktime_t *file, quicktime_minf_t *minf, quicktime_stsd_table_t *table)
271,9 → 332,6
table->compression_id = 0;
table->packet_size = 0;
table->sample_rate = 0;
 
table->mpeg4_header = 0;
table->mpeg4_header_size = 0;
}
 
void quicktime_stsd_table_delete(quicktime_stsd_table_t *table)
281,7 → 339,9
quicktime_ctab_delete(&(table->ctab));
quicktime_mjqt_delete(&(table->mjqt));
quicktime_mjht_delete(&(table->mjht));
if(table->mpeg4_header) free(table->mpeg4_header);
quicktime_delete_avcc(&(table->avcc));
quicktime_delete_esds(&(table->esds));
}
 
void quicktime_stsd_video_dump(quicktime_stsd_table_t *table)
309,6 → 369,8
if(!table->ctab_id) quicktime_ctab_dump(&(table->ctab));
quicktime_mjqt_dump(&(table->mjqt));
quicktime_mjht_dump(&(table->mjht));
quicktime_esds_dump(&table->esds);
quicktime_avcc_dump(&table->avcc);
}
 
void quicktime_stsd_audio_dump(quicktime_stsd_table_t *table)
321,13 → 383,15
printf(" compression_id %d\n", table->compression_id);
printf(" packet_size %d\n", table->packet_size);
printf(" sample_rate %f\n", table->sample_rate);
if(table->version == 1)
if(table->version > 0)
{
printf(" samples_per_packet %d\n", table->samples_per_packet);
printf(" bytes_per_packet %d\n", table->bytes_per_packet);
printf(" bytes_per_frame %d\n", table->bytes_per_frame);
printf(" bytes_per_sample %d\n", table->bytes_per_sample);
}
quicktime_esds_dump(&table->esds);
quicktime_avcc_dump(&table->avcc);
}
 
void quicktime_stsd_table_dump(void *minf_ptr, quicktime_stsd_table_t *table)
/branches/automake-1_1_6/hvirtual/quicktime/libmjpeg.c
652,7 → 652,6
pthread_mutex_unlock(&(mjpeg->decompress_init));
get_rows(mjpeg, engine);
 
//printf("decompress_field 3 %d\n", engine->jpeg_decompress.output_scanline);
 
while(engine->jpeg_decompress.output_scanline < engine->jpeg_decompress.output_height)
{
1087,7 → 1086,7
unsigned char *u_in = mjpeg->temp_rows[1][0];
unsigned char *v_in = mjpeg->temp_rows[2][0];
 
//printf("mjpeg_decompress %p\n", row_pointers);
//printf("mjpeg_decompress 7 %p\n", row_pointers);
cmodel_transfer(row_pointers,
0,
y_plane,
1109,6 → 1108,7
0,
mjpeg->coded_w,
mjpeg->rowspan ? mjpeg->rowspan : mjpeg->output_w);
//printf("mjpeg_decompress 8\n");
}
return 0;
}
/branches/automake-1_1_6/hvirtual/quicktime/libmjpeg.h
30,7 → 30,7
 
 
#include <stdio.h>
#include "jpeg/jpeglib.h"
#include "jpeglib.h"
#include <png.h> /* Need setjmp.h as included by png.h */
#include "pthread.h"
 
/branches/automake-1_1_6/hvirtual/quicktime/atom.c
12,6 → 12,7
type[1] = data[5];
type[2] = data[6];
type[3] = data[7];
type[4] = 0;
 
/*printf("%c%c%c%c ", type[0], type[1], type[2], type[3]); */
/* need this for quicktime_check_sig */
68,7 → 69,7
static int reset(quicktime_atom_t *atom)
{
atom->end = 0;
atom->type[0] = atom->type[1] = atom->type[2] = atom->type[3] = 0;
atom->type[0] = atom->type[1] = atom->type[2] = atom->type[3] = atom->type[4] = 0;
return 0;
}
 
86,6 → 87,7
atom->type[1] = header[1];
atom->type[2] = header[2];
atom->type[3] = header[3];
atom->type[4] = 0;
atom->size =
(((unsigned char)header[4]) ) |
(((unsigned char)header[5]) << 8 ) |
212,7 → 214,7
quicktime_set_position(file, atom->end);
}
 
int quicktime_atom_is(quicktime_atom_t *atom, char *type)
int quicktime_atom_is(quicktime_atom_t *atom, unsigned char *type)
{
if(atom->type[0] == type[0] &&
atom->type[1] == type[1] &&
/branches/automake-1_1_6/hvirtual/quicktime/qtmp3.c
357,7 → 357,8
static int write_frames(quicktime_t *file,
quicktime_audio_map_t *track_map,
quicktime_trak_t *trak,
quicktime_mp3_codec_t *codec)
quicktime_mp3_codec_t *codec,
int track)
{
int result = 0;
int i, j;
383,16 → 384,27
0,
0);
 
quicktime_write_chunk_header(file, trak, &chunk_atom);
result = !quicktime_write_data(file, header, frame_size);
// Knows not to save the chunksizes for audio
quicktime_write_chunk_footer(file,
trak,
track_map->current_chunk,
&chunk_atom,
 
quicktime_write_vbr_frame(file,
track,
header,
frame_size,
frame_samples);
 
track_map->current_chunk++;
 
 
// quicktime_write_chunk_header(file, trak, &chunk_atom);
// result = !quicktime_write_data(file, header, frame_size);
// // Knows not to save the chunksizes for audio
// quicktime_write_chunk_footer(file,
// trak,
// track_map->current_chunk,
// &chunk_atom,
// frame_samples);
track_map->current_chunk++;
 
 
 
i += frame_size;
frames_end = i;
}
513,7 → 525,8
result = write_frames(file,
track_map,
trak,
codec);
codec,
track);
 
return result;
}
553,7 → 566,8
result = write_frames(file,
track_map,
trak,
codec);
codec,
track);
}
}