本文整理汇总了C++中AVDMGenericVideoStream::getFrameNumberNoAlloc方法的典型用法代码示例。如果您正苦于以下问题:C++ AVDMGenericVideoStream::getFrameNumberNoAlloc方法的具体用法?C++ AVDMGenericVideoStream::getFrameNumberNoAlloc怎么用?C++ AVDMGenericVideoStream::getFrameNumberNoAlloc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AVDMGenericVideoStream
的用法示例。
在下文中一共展示了AVDMGenericVideoStream::getFrameNumberNoAlloc方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getFrameNumberNoAlloc
uint8_t ADMVideoFlipV::getFrameNumberNoAlloc(uint32_t frame,
uint32_t *len,
ADMImage *data,
uint32_t *flags)
{
if (frame>= _info.nb_frames)
return 0;
// read uncompressed frame
if (!_in->getFrameNumberNoAlloc(frame, len, _uncompressed, flags))
return 0;
uint8_t *in, *out;
uint32_t stride=_info.width;
uint32_t h=_info.height;
uint32_t page, qpage;
page=stride*h;
qpage=page>>2;
in=YPLANE(_uncompressed);
out=YPLANE(data)+(h-1)*stride;
// flip y
for (uint32_t y=h; y>0; y--)
{
memcpy(out,in,stride);
in+=stride;
out-=stride;
}
// Flip U & V
stride>>=1;
in=UPLANE(_uncompressed);
out=UPLANE(data)+qpage-stride;
// flip u
for (uint32_t y=h>>1; y>0; y--)
{
memcpy(out,in,stride);
in+=stride;
out-=stride;
}
in=VPLANE(_uncompressed);
out=VPLANE(data)+qpage-stride;
// flip u
for (uint32_t y=h>>1; y>0; y--)
{
memcpy(out,in,stride);
in+=stride;
out-=stride;
}
data->copyInfo(_uncompressed);
return 1;
}
示例2: getLastVideoFilter
//.........这里部分代码省略.........
switch(mpegtype)
{
case ADM_SVCD:
Mpeg2encSVCD *dec;
dec=new Mpeg2encSVCD(_w,_h);
dec->setMatrix(matrix);
// dec->init(q,bitrate,_fps1000,interlaced,widescreen);
dec->init(q,bitrate,_fps1000,interlaced,bff,widescreen); // WLA
_codec=dec;
encoding->setCodec("SVCD");
printf("Svcd max bitrate : %d\n",bitrate);
break;
case ADM_DVD:
{
Mpeg2encDVD *dec;
dec=new Mpeg2encDVD(_w,_h);
dec->setMatrix(matrix);
// dec->init(q,bitrate,_fps1000,interlaced,widescreen);
dec->init(q,bitrate,_fps1000,interlaced,bff,widescreen); // WLA
_codec=dec;
printf("DVD max bitrate : %d\n",bitrate);
encoding->setCodec("DVD");
}
break;
default:
assert(0);
break;
}
encoding->setPhasis("2nd Pass");
for(uint32_t i=0;i<_total;i++)
{
if(!incoming->getFrameNumberNoAlloc(i, &size,(uint8_t *) _buffer,&flags))
{
GUI_Alert("Encoding error !");
if(!_audio)
fclose(fd);
end();
return 0 ;
}
encoding->setFrame(i,_total);
if(i<MPEG_PREFILL)
{
_codec->encode(_buffer,_buffer_out , &len,&flags,&outquant);
continue;
}
encoding->feedFrame(len); // Set
/* prepare quantization for next gop */
//if(vbr_next_intra( &mpegvbr))
{
q=vbrGetQuant(&mpegvbr);
_codec->setQuantize(q);
}
_codec->encode(_buffer,_buffer_out , &len,&flags,&outquant);
encoding->setQuant(outquant);
if(flags & AVI_KEY_FRAME) intra=1;
else intra=0;
switch(flags)
{
case AVI_KEY_FRAME: type=1;
break;
case AVI_B_FRAME: type=3;
break;
示例3: save_regular
//.........这里部分代码省略.........
break;
case ADM_SVCD:
Mpeg2encSVCD *dec;
dec=new Mpeg2encSVCD(_w,_h);
dec->setMatrix(matrix);
// dec->init(qz,bitrate,_fps1000,interlaced,widescreen);
dec->init(qz,bitrate,_fps1000,interlaced,bff,widescreen);
// WLA
_codec=dec;
encoding->setCodec("SVCD.");
break;
case ADM_DVD:
{
Mpeg2encDVD *dec;
dec=new Mpeg2encDVD(_w,_h);
dec->setMatrix(matrix);
// dec->init(qz,bitrate,_fps1000,interlaced,widescreen);
dec->init(qz,bitrate,_fps1000,interlaced,bff,widescreen);
// WLA
_codec=dec;
encoding->setCodec("DVD.");
}
break;
default: assert(0);
}
printf("\n--encoding started--\n");
for(uint32_t i=0;i<_total;i++)
{
if(!incoming->getFrameNumberNoAlloc(i, &size,
(uint8_t *) _buffer,&flags))
{
delete encoding;
GUI_Alert("Encoding error !");
if(fd)
fclose(fd);
end();
return 0 ;
}
_codec->encode( _buffer,_buffer_out , &len,&flags,&outquant);
total_size+=len;
encoding->feedFrame(len);
encoding->setQuant(outquant);
encoding->setFrame(i,_total);
// Null frame are only possible
// when in prefill state for mpeg-X
if(!len) continue;
if(_audio)
{
uint32_t audiolen;
// write video
fwrite(_buffer_out,len,1,_videoFifo);
fflush(_videoFifo);
audiolen=_audioOneFrame;
audiolen = _audio->read (audiolen,_audioBuffer);
assert(audiolen<MAXAUDIO);
fwrite(_audioBuffer,audiolen,1,_audioFifo);
fflush(_audioFifo);
aprintf("Audio :%lu Video:%lu (%lu)\n",audiolen,len,
_audioOneFrame);
}else
{
示例4: memset
//****************************************************************
uint8_t
mpegWritter::dopass2 (const char *name, char *statname, uint32_t final_size, uint32_t bitrate, ADM_MPEGTYPE mpegtype, int matrix, uint8_t interlaced, uint8_t bff, // WLA
uint8_t widescreen)
{
int intra, q;
uint32_t size;
AVDMGenericVideoStream *incoming;
FILE *fd = NULL;
uint64_t total_size = 0;
uint32_t len, flags, type, outquant, audiolen;
uint32_t sample_target = 0;
double sample_time;
ADMBitstream bitstream;
memset (quantstat, 0, 32);
incoming = getLastVideoFilter (frameStart, frameEnd - frameStart);
if (!_audio)
{
if (!(fd = qfopen (name, "wb")))
return 0;
}
// if(!init(name,mpegtype,interlaced,widescreen))
if (!init (name, mpegtype, interlaced, bff, widescreen)) // WLA
{
printf ("Mpeg2 init failed\n");
return 0;
}
printf ("\n mpeg2enc init done \n");
ADM_assert (aImage);
ADM_assert (_buffer_out);
encoding->reset ();
encoding->setFrame (0, _total);
/*-------------------- Pass 1 over, go to pass 2 --------------------------------*/
ADM_assert (_ratecontrol->startPass2 (final_size, _total));
encoding->setPhasis ("2nd Pass");
q = 2;
//mpegvbr.maxAllowedBitrate=(bitrate*1000)>>3;//(bitrate*1000)>>3;
//mpegvbr.maxAllowedBitrate=(9000*1000)>>3; // enable stuff in xvid
//->
switch (mpegtype)
{
case ADM_SVCD:
Mpeg2encSVCD * dec;
dec = new Mpeg2encSVCD (_w, _h);
dec->setMatrix (matrix);
// dec->init(q,bitrate,_fps1000,interlaced,widescreen);
dec->init (q, bitrate, _fps1000, interlaced, bff, widescreen, 0); // WLA
_codec = dec;
encoding->setCodec ("SVCD");
printf ("Svcd max bitrate : %d\n", bitrate);
break;
case ADM_DVD:
{
Mpeg2encDVD *dec;
dec = new Mpeg2encDVD (_w, _h);
dec->setMatrix (matrix);
// dec->init(q,bitrate,_fps1000,interlaced,widescreen);
dec->init (q, bitrate, _fps1000, interlaced, bff, widescreen, 0); // WLA
_codec = dec;
printf ("DVD max bitrate : %d\n", bitrate);
encoding->setCodec ("DVD");
}
break;
default:
ADM_assert (0);
break;
}
encoding->setPhasis ("2nd Pass");
if (_muxer)
{
encoding->
setAudioCodec (getStrFromAudioCodec (_audio->getInfo ()->encoding));
sample_time = _total;
sample_time *= 1000;
sample_time /= _fps1000; // target_time in second
sample_time *= _audio->getInfo ()->frequency;
sample_target = (uint32_t) floor (sample_time);
}
bitstream.data = _buffer_out;
for (uint32_t i = 0; i < _total; i++)
{
if (!incoming->getFrameNumberNoAlloc (i, &size, aImage, &flags))
{
GUI_Error_HIG (_("Encoding error"), NULL);
if (!_audio)
qfclose (fd);
end ();
//.........这里部分代码省略.........
示例5: getLastVideoFilter
/*-------------------------------------------------------------------------------------------------------*/
uint8_t
mpegWritter::dopass1 (const char *name, char *statname, uint32_t final_size, uint32_t bitrate, ADM_MPEGTYPE mpegtype, int matrix, uint8_t interlaced, uint8_t bff, // WLA
uint8_t widescreen)
{
uint32_t size;
AVDMGenericVideoStream *incoming;
FILE *fd;
uint64_t total_size = 0;
//uint32_t len,flags,type,outquant;
float br;
uint32_t avg, flags;
int intra, q;
ADMBitstream bitstream;
incoming = getLastVideoFilter (frameStart, frameEnd - frameStart);
// if(!init(name,mpegtype,interlaced,widescreen)) return 0;
if (!init (name, mpegtype, interlaced, bff, widescreen))
return 0; // WLA
printf ("\n mpeg2enc init done \n");
ADM_assert (aImage);
ADM_assert (_buffer_out);
q = 2; // q=2
encoding->setPhasis ("1st Pass");
bitrate = 0; // we dont care in pass 1 ...
ADM_assert (_ratecontrol->startPass1 ());
switch (mpegtype)
{
case ADM_SVCD:
Mpeg2encSVCD * dec;
dec = new Mpeg2encSVCD (_w, _h);
dec->setMatrix (matrix);
#ifdef ADM_1PASS_CBR
dec->disablePadding ();
//dec->init(qz,bitrate,_fps1000,interlaced,widescreen);
// dec->init(0,avg*1000,_fps1000,interlaced,widescreen);
dec->init (0, avg * 1000, _fps1000, interlaced, bff, widescreen, 1); // WLA
#else
// dec->init(q,0,_fps1000,interlaced,widescreen);
dec->init (q, 0, _fps1000, interlaced, bff, widescreen, 1); // WLA
#endif
// 6 Megabits should be enough
//dec->init(0,avg,_fps1000); // 6 Megabits should be enough
_codec = dec;
encoding->setCodec ("SVCD");
break;
case ADM_DVD:
{
Mpeg2encDVD *dec;
dec = new Mpeg2encDVD (_w, _h);
dec->setMatrix (matrix);
#ifdef ADM_1PASS_CBR
dec->disablePadding ();
// dec->init(0,avg*1000,_fps1000,interlaced,widescreen);
dec->init (0, avg * 1000, _fps1000, interlaced, bff, widescreen, 1); // WLA
#else
// dec->init(q,0,_fps1000,interlaced,widescreen);
dec->init (q, 0, _fps1000, interlaced, bff, widescreen, 1); // WLA
#endif
_codec = dec;
encoding->setCodec ("DVD");;
}
break;
default:
ADM_assert (0);
break;
}
encoding->setFrame (0, _total);
bitstream.data = _buffer_out;
for (uint32_t i = 0; i < _total; i++)
{
if (!incoming->getFrameNumberNoAlloc (i, &size, aImage, &flags))
{
GUI_Error_HIG (_("Encoding error"), NULL);
end ();
return 0;
}
if (i < MPEG_PREFILL)
{
bitstream.cleanup (i);
bitstream.in_quantizer=q;
_codec->encode (aImage, &bitstream);
//_buffer_out , &len,&flags,&outquant);
continue;
}
//.........这里部分代码省略.........
示例6: GUI_PlayAvi
//static uint8_t Vbuffer[7.0*5.6*3];
//AVDMGenericVideoStream *getFirstVideoFilter( void)
//
//_____________________________________________________________
void GUI_PlayAvi(void)
{
uint32_t time_e, time_a = 0;
uint32_t err = 0, acc = 0;
uint32_t max;
uint32_t framelen,flags;
AVDMGenericVideoStream *filter;
ADMImage *buffer=NULL;
vids = 0, auds = 0, dauds = 0;
// check we got everything...
if (!avifileinfo)
return;
if((curframe+1)>= avifileinfo->nb_frames-1)
{
printf("No frame left\n");
return;
}
if (avifileinfo->fps1000 == 0)
return;
if (playing)
{
stop_req = 1;
return;
}
uint32_t played_frame=0;
uint32_t remaining=avifileinfo->nb_frames-curframe;
if(guiOutputDisplay)
{
filter=getLastVideoFilter(curframe,remaining);
if(mode_preview)
{
editorKillPreview ();
UI_setPreviewToggleStatus( 0 );
mode_preview=0;
}
}
else
{
filter=getFirstVideoFilter(curframe,remaining );
}
max=filter->getInfo()->nb_frames;
// compute how much a frame lasts in ms
one_frame = (uint32_t) floor(1000.*1000.*10. / filter->getInfo()->fps1000);
err = one_frame % 10;
one_frame /= 10; // Duration of a frame in ms, err =leftover in 1/10 ms
buffer=new ADMImage(filter->getInfo()->width,filter->getInfo()->height);
// go to RealTime...
printf(" One frame : %lu, err=%lu ms\n", one_frame, err);
// read frame in chunk
if(!filter->getFrameNumberNoAlloc(1,&framelen,buffer,&flags))
{
printf("\n cannot read frame!\n");
goto abort_play;
}
curframe++;
played_frame++;
// prepare 1st frame
stop_req = 0;
playing = 1;
#ifdef HAVE_AUDIO
ComputePreload();
#endif
renderResize(filter->getInfo()->width,filter->getInfo()->height,currentZoom);
renderStartPlaying();
// reset timer reference
resetTime();
do
{
vids++;
renderUpdateImage(buffer->data);
if(mode_preview&&!guiOutputDisplay)
{
editorUpdatePreview(played_frame);
}
update_status_bar(buffer);
if (time_a == 0)
time_a = getTime(0);
// mark !
//printf("\n Rendering %lu frame\n",curframe);
// read frame in chunk
if((played_frame)>=(max-1))
{
printf("\n End met (%lu / %lu )\n",played_frame,max);
goto abort_play;
}
if(!filter->getFrameNumberNoAlloc(played_frame+1,&framelen,buffer,&flags))
{
printf("\n cannot read frame!\n");
//.........这里部分代码省略.........