Cleanup of the muxer API, func parameters muxer & muxer_f eliminated.

patch by Andriy N. Gritsenko <andrej@lucky.net>


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@9015 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
arpi 2003-01-19 01:48:52 +00:00
parent a52ed04fcb
commit 489b07338c
9 changed files with 21 additions and 37 deletions

View File

@ -149,7 +149,7 @@ int pos=0;
int frames=0;
FILE *f=fopen("paulvandykforanangel.viv","rb");
FILE *f2=fopen("GB1.avi","wb");
muxer_t* avi=muxer_new_muxer(MUXER_TYPE_AVI);
muxer_t* avi=muxer_new_muxer(MUXER_TYPE_AVI,f2);
muxer_stream_t* mux=muxer_new_stream(avi,MUXER_TYPE_VIDEO);
//unsigned char* buffer=malloc(0x200000);
int i,len;
@ -169,7 +169,7 @@ mux->bih->biSize=sizeof(BITMAPINFOHEADER);
mux->bih->biPlanes=1;
mux->bih->biBitCount=24;
mux->bih->biCompression=0x6f766976;// 7669766f;
muxer_write_header(avi,f2);
muxer_write_header(avi);
/*
c=fgetc(f); if(c) printf("error! not vivo file?\n");
@ -222,7 +222,7 @@ while((c=fgetc(f))>=0){
// end of frame:
printf("Frame size: %d\n",mux->buffer_len);
h263_decode_picture_header(mux->buffer);
muxer_write_chunk(avi,mux,f2,mux->buffer_len,0x10);
muxer_write_chunk(mux,mux->buffer_len,0x10);
mux->buffer_len=0;
if((v_id&0xF0)==0x10) fprintf(stderr,"hmm. last video packet %02X\n",v_id);
@ -258,8 +258,8 @@ mux->bih->biWidth=width;
mux->bih->biHeight=height;
mux->bih->biSizeImage=3*width*height;
muxer_write_index(avi,f2);
muxer_write_index(avi);
fseek(f2,0,SEEK_SET);
muxer_write_header(avi,f2);
muxer_write_header(avi);
}

View File

@ -44,7 +44,6 @@
static int pass;
extern char* passtmpfile;
extern void mencoder_write_chunk(muxer_stream_t *s,int len,unsigned int flags);
#include <encore2.h>
@ -273,7 +272,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
enc_result.quantizer);
}
}
mencoder_write_chunk(mux_v,vf->priv->enc_frame.length,enc_result.is_key_frame?0x10:0);
muxer_write_chunk(mux_v,vf->priv->enc_frame.length,enc_result.is_key_frame?0x10:0);
return 1;
}

View File

@ -27,7 +27,6 @@
#include "vf.h"
extern char* passtmpfile;
extern void mencoder_write_chunk(muxer_stream_t *s,int len,unsigned int flags);
//===========================================================================//
@ -486,7 +485,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
out_size = avcodec_encode_video(lavc_venc_context, mux_v->buffer, mux_v->buffer_size,
pic);
mencoder_write_chunk(mux_v,out_size,lavc_venc_context->coded_frame->key_frame?0x10:0);
muxer_write_chunk(mux_v,out_size,lavc_venc_context->coded_frame->key_frame?0x10:0);
#if LIBAVCODEC_BUILD >= 4643
/* store psnr / pict size / type / qscale */

View File

@ -23,8 +23,6 @@
#include <libdv/dv.h>
extern void mencoder_write_chunk(muxer_stream_t *s,int len,unsigned int flags);
#ifndef DV_WIDTH
#define DV_WIDTH 720
#define DV_PAL_HEIGHT 576
@ -78,7 +76,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
(mpi->flags&MP_IMGFLAG_YUV) ? e_dv_color_yuv : e_dv_color_rgb,
mux_v->buffer);
mencoder_write_chunk(mux_v, 480 * (vf->priv->enc->isPAL ? 300 : 250) , 0x10);
muxer_write_chunk(mux_v, 480 * (vf->priv->enc->isPAL ? 300 : 250) , 0x10);
return 1;
}

View File

@ -90,8 +90,6 @@ static long (*CountComponents)(ComponentDescription* desc);
static OSErr (*GetComponentInfo)(Component prev,ComponentDescription* desc,Handle h1,Handle h2,Handle h3);
extern void mencoder_write_chunk(muxer_stream_t *s,int len,unsigned int flags);
//static int format=mmioFOURCC('S','V','Q','1');
static int format=mmioFOURCC('S','V','Q','3');
@ -260,7 +258,7 @@ if(!codec_inited){
printf("Size %i->%i \n",stride*height,compressedsize);
printf("Ratio: %i:1\n",(stride*height)/compressedsize);
#endif
mencoder_write_chunk(mux_v, compressedsize , similarity?0:0x10);
muxer_write_chunk(mux_v, compressedsize , similarity?0:0x10);
if(((*desc)->idSize)>MAX_IDSIZE){
printf("FATAL! idSize=%d too big, increase MAX_IDSIZE in ve_qtvideo.c!\n",((*desc)->idSize));

View File

@ -16,8 +16,6 @@
#include "mp_image.h"
#include "vf.h"
extern void mencoder_write_chunk(muxer_stream_t *s,int len,unsigned int flags);
//===========================================================================//
struct vf_priv_s {
@ -48,7 +46,7 @@ static int query_format(struct vf_instance_s* vf, unsigned int fmt){
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
mux_v->buffer=mpi->planes[0];
mencoder_write_chunk(mux_v, mpi->width*mpi->height*3, 0x10);
muxer_write_chunk(mux_v, mpi->width*mpi->height*3, 0x10);
return 1;
}

View File

@ -25,8 +25,6 @@
#include "muxer.h"
extern void mencoder_write_chunk(muxer_stream_t *s,int len,unsigned int flags);
//===========================================================================//
static char *vfw_param_codec = NULL;
@ -244,7 +242,7 @@ static int put_image(struct vf_instance_s* vf, mp_image_t *mpi){
int ret;
// flip_upside_down(vo_image_ptr,vo_image_ptr,3*vo_w,vo_h); // dirty hack
ret=vfw_encode_frame(mux_v->bih, mux_v->buffer, vfw_bih, mpi->planes[0], &flags, 10000);
mencoder_write_chunk(mux_v,mux_v->bih->biSizeImage,flags);
muxer_write_chunk(mux_v,mux_v->bih->biSizeImage,flags);
return 1;
}

View File

@ -65,7 +65,6 @@ static int const motion_presets[7] = {
};
extern char* passtmpfile;
extern void mencoder_write_chunk(muxer_stream_t *s,int len,unsigned int flags);
static int xvidenc_pass = 0;
static int xvidenc_quality = 4;
@ -454,7 +453,7 @@ put_image(struct vf_instance_s* vf, mp_image_t *mpi)
}
// write output
mencoder_write_chunk(fp->mux, fp->enc_frame.length, fp->enc_frame.intra==1 ? 0x10 : 0);
muxer_write_chunk(fp->mux, fp->enc_frame.length, fp->enc_frame.intra==1 ? 0x10 : 0);
// update the VBR engine
vbrUpdate(&fp->vbr_state, enc_stats.quant, fp->enc_frame.intra,

View File

@ -306,11 +306,6 @@ static void exit_sighandler(int x){
static muxer_t* muxer=NULL;
static FILE* muxer_f=NULL;
// callback for ve_*.c:
void mencoder_write_chunk(muxer_stream_t *s,int len,unsigned int flags){
muxer_write_chunk(muxer,s,muxer_f,len,flags);
}
extern void print_wave_header(WAVEFORMATEX *h);
int main(int argc,char* argv[]){
@ -606,7 +601,7 @@ if(!muxer_f) {
mencoder_exit(1,NULL);
}
muxer=muxer_new_muxer(out_file_format);
muxer=muxer_new_muxer(out_file_format,muxer_f);
// ============= VIDEO ===============
@ -815,7 +810,7 @@ if(audio_delay!=0.0){
} // if(sh_audio)
printf(MSGTR_WritingAVIHeader);
muxer_write_header(muxer,muxer_f);
muxer_write_header(muxer);
decoded_frameno=0;
@ -1001,7 +996,7 @@ if(sh_audio){
}
}
if(len<=0) break; // EOF?
muxer_write_chunk(muxer,mux_a,muxer_f,len,0x10);
muxer_write_chunk(mux_a,len,0x10);
if(!mux_a->h.dwSampleSize && mux_a->timer>0)
mux_a->wf->nAvgBytesPerSec=0.5f+(double)mux_a->size/mux_a->timer; // avg bps (VBR)
if(mux_a->buffer_len>=len){
@ -1081,11 +1076,11 @@ ptimer_start = GetTimerMS();
switch(mux_v->codec){
case VCODEC_COPY:
mux_v->buffer=start;
if(skip_flag<=0) muxer_write_chunk(muxer,mux_v,muxer_f,in_size,(sh_video->ds->flags&1)?0x10:0);
if(skip_flag<=0) muxer_write_chunk(mux_v,in_size,(sh_video->ds->flags&1)?0x10:0);
break;
case VCODEC_FRAMENO:
mux_v->buffer=(unsigned char *)&decoded_frameno; // tricky
if(skip_flag<=0) muxer_write_chunk(muxer,mux_v,muxer_f,sizeof(int),0x10);
if(skip_flag<=0) muxer_write_chunk(mux_v,sizeof(int),0x10);
break;
default:
// decode_video will callback down to ve_*.c encoders, through the video filters
@ -1096,7 +1091,7 @@ default:
// unwanted skipping of a frame, what to do?
if(skip_limit==0){
// skipping not allowed -> write empty frame:
muxer_write_chunk(muxer,mux_v,muxer_f,0,0);
muxer_write_chunk(mux_v,0,0);
} else {
// skipping allowed -> skip it and distriubute timer error:
v_timer_corr-=(float)mux_v->h.dwScale/mux_v->h.dwRate;
@ -1113,7 +1108,7 @@ if(skip_flag<0){
if(!tv_param_on && !verbose) printf(MSGTR_DuplicateFrames,-skip_flag);
while(skip_flag<0){
duplicatedframes++;
muxer_write_chunk(muxer,mux_v,muxer_f,0,0);
muxer_write_chunk(mux_v,0,0);
++skip_flag;
}
} else
@ -1272,11 +1267,11 @@ if(sh_audio && mux_a->codec==ACODEC_VBRMP3 && !lame_param_vbr){
#endif
printf(MSGTR_WritingAVIIndex);
muxer_write_index(muxer,muxer_f);
muxer_write_index(muxer);
muxer_f_size=ftello(muxer_f);
printf(MSGTR_FixupAVIHeader);
fseek(muxer_f,0,SEEK_SET);
muxer_write_header(muxer,muxer_f); // update header
muxer_write_header(muxer); // update header
if(ferror(muxer_f) || fclose(muxer_f) != 0) {
mp_msg(MSGT_MENCODER,MSGL_FATAL,MSGTR_ErrorWritingFile, out_filename);
mencoder_exit(1, NULL);