Update of /cvsroot/dirac/compress/libdirac_encoder
In directory
sc8-pr-cvs12.sourceforge.net:/tmp/cvs-serv30513/libdirac_enc
oder
Modified Files:
dirac_encoder.cpp seq_compress.cpp seq_compress.h
Log Message:
Return the Sequence header as a separate packet and not
preprended to an
encoded frame.
Index: seq_compress.h
============================================================
=======
RCS file:
/cvsroot/dirac/compress/libdirac_encoder/seq_compress.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** seq_compress.h 29 Apr 2008 14:09:35 -0000 1.22
--- seq_compress.h 21 May 2008 03:56:43 -0000 1.23
***************
*** 121,127 ****
method.
! return reference to the next
locally decoded picture available for display
*/
! Picture &CompressNextPicture();
//! Return a pointer to the most recent picture
encoded
--- 121,127 ----
method.
! return pointer to the next locally
decoded picture available for display
*/
! const Picture *CompressNextPicture();
//! Return a pointer to the most recent picture
encoded
***************
*** 231,234 ****
--- 231,237 ----
bool m_eos_signalled;
+ //! Picture number where previous GOP started
+ int m_prev_gop_start;
+
private:
//! Copy constructor is private and body-less
Index: dirac_encoder.cpp
============================================================
=======
RCS file:
/cvsroot/dirac/compress/libdirac_encoder/dirac_encoder.cpp,v
retrieving revision 1.47
retrieving revision 1.48
diff -C2 -d -r1.47 -r1.48
*** dirac_encoder.cpp 9 May 2008 05:00:34 -0000 1.47
--- dirac_encoder.cpp 21 May 2008 03:56:43 -0000 1.48
***************
*** 339,343 ****
dirac_instr_t old_instr = *instr;
! if (!m_return_instr_data)
return;
--- 339,343 ----
dirac_instr_t old_instr = *instr;
! if (!m_return_instr_data || m_enc_picture == NULL)
return;
***************
*** 505,509 ****
std::ostringstream errstr;
! errstr << "Picture coding mode "
<<
enc_ctx->enc_params.picture_coding_mode
<< " out of supported range
[0-1]";
--- 505,509 ----
std::ostringstream errstr;
! errstr << "Picture coding mode "
<<
enc_ctx->enc_params.picture_coding_mode
<< " out of supported range
[0-1]";
***************
*** 596,633 ****
return 0;
! Picture &mypicture =
m_seqcomp->CompressNextPicture();
!
! m_enc_picture = m_seqcomp->GetPictureEncoded();
! m_enc_medata = m_seqcomp->GetMEData();
! m_decpnum = -1;
! if (m_return_decoded_pictures &&
! mypicture.GetPparams().PictureNum() !=
m_show_pnum)
{
! int ret_val;
! m_show_pnum =
mypicture.GetPparams().PictureNum();
! TEST (! (m_return_decoded_pictures &&
!m_dec_buf) );
! if (m_return_decoded_pictures &&
m_dec_buf)
! {
! // write locally decoded picture to decode
buffer
! m_out_ptr->SetMembufReference(m_dec_buf,
m_dec_bufsize);
! ret_val =
m_out_ptr->GetStream()->WriteToNextFrame(mypicture);
! if (ret_val)
{
! m_decpnum = m_show_pnum;
! m_decpsort =
mypicture.GetPparams().PicSort();
}
}
}
if(!m_dirac_byte_stream.IsUnitAvailable())
return 0;
!
! m_num_coded_pictures++;
! TESTM (m_enc_picture != 0, "Encoder picture
available");
!
! return 1;
}
--- 596,642 ----
return 0;
! const Picture *mypicture =
m_seqcomp->CompressNextPicture();
! m_decpnum = -1;
! if (mypicture)
{
! m_enc_picture =
m_seqcomp->GetPictureEncoded();
! m_enc_medata = m_seqcomp->GetMEData();
! if (m_return_decoded_pictures &&
! mypicture->GetPparams().PictureNum() !=
m_show_pnum)
! {
! int ret_val;
! m_show_pnum =
mypicture->GetPparams().PictureNum();
! TEST (! (m_return_decoded_pictures &&
!m_dec_buf) );
! if (m_return_decoded_pictures &&
m_dec_buf)
{
! // write locally decoded picture to decode
buffer
!
m_out_ptr->SetMembufReference(m_dec_buf, m_dec_bufsize);
! ret_val =
m_out_ptr->GetStream()->WriteToNextFrame(*mypicture);
!
! if (ret_val)
! {
! m_decpnum = m_show_pnum;
! m_decpsort =
mypicture->GetPparams().PicSort();
! }
}
}
}
+ else
+ {
+ m_enc_picture = NULL;
+ m_enc_medata = NULL;
+ }
if(!m_dirac_byte_stream.IsUnitAvailable())
return 0;
! if (mypicture)
! {
! m_num_coded_pictures++;
! TESTM (m_enc_picture != 0, "Encoder
picture available");
! }
! return 1;
}
***************
*** 682,711 ****
}
memmove (encdata->buffer, output.c_str(),
output.size());
! encoder->enc_pparams.pnum =
m_enc_picture->GetPparams().PictureNum();
! encoder->enc_pparams.ptype =
m_enc_picture->GetPparams().PicSort().IsIntra() ?
INTRA_PICTURE : INTER_PICTURE;
! encoder->enc_pparams.rtype =
m_enc_picture->GetPparams().PicSort().IsRef() ?
REFERENCE_PICTURE : NON_REFERENCE_PICTURE;
!
! // Get frame statistics
! GetPictureStats (encoder);
! if(m_encparams.Verbose() &&
encoder->enc_ctx.enc_params.picture_coding_mode==1)
{
! if (encoder->enc_pparams.pnum%2 == 0)
! m_field1_stats = encoder->enc_pstats;
! else
{
!
std::cout<<std::endl<<std::endl
! <<"Frame
"<<encoder->enc_pparams.pnum/2;
! std::cout<< " stats";
! std::cout<<std::endl<<
"Number of MV bits=";
! std::cout<< m_field1_stats.mv_bits +
encoder->enc_pstats.mv_bits;
! std::cout<< std::endl <<
"Number of bits for Y=";
! std::cout<<
m_field1_stats.ycomp_bits +
encoder->enc_pstats.ycomp_bits;
! std::cout<< std::endl <<
"Number of bits for U=";
! std::cout<<
m_field1_stats.ucomp_bits +
encoder->enc_pstats.ucomp_bits;
! std::cout<< std::endl <<
"Number of bits for V=";
! std::cout<<
m_field1_stats.vcomp_bits +
encoder->enc_pstats.vcomp_bits;
! std::cout << std::endl <<
"Total frame bits=";
! std::cout<< m_field1_stats.pic_bits
+ encoder->enc_pstats.pic_bits;
}
}
encdata->size = size;
--- 691,729 ----
}
memmove (encdata->buffer, output.c_str(),
output.size());
! if (m_enc_picture)
{
! // picture data
! encoder->enc_pparams.pnum =
m_enc_picture->GetPparams().PictureNum();
! encoder->enc_pparams.ptype =
m_enc_picture->GetPparams().PicSort().IsIntra() ?
INTRA_PICTURE : INTER_PICTURE;
! encoder->enc_pparams.rtype =
m_enc_picture->GetPparams().PicSort().IsRef() ?
REFERENCE_PICTURE : NON_REFERENCE_PICTURE;
!
! // Get frame statistics
! GetPictureStats (encoder);
! if(m_encparams.Verbose() &&
encoder->enc_ctx.enc_params.picture_coding_mode==1)
{
! if (encoder->enc_pparams.pnum%2 == 0)
! m_field1_stats =
encoder->enc_pstats;
! else
! {
!
std::cout<<std::endl<<std::endl
! <<"Frame
"<<encoder->enc_pparams.pnum/2;
! std::cout<< " stats";
! std::cout<<std::endl<<
"Number of MV bits=";
! std::cout<<
m_field1_stats.mv_bits + encoder->enc_pstats.mv_bits;
! std::cout<< std::endl <<
"Number of bits for Y=";
! std::cout<<
m_field1_stats.ycomp_bits +
encoder->enc_pstats.ycomp_bits;
! std::cout<< std::endl <<
"Number of bits for U=";
! std::cout<<
m_field1_stats.ucomp_bits +
encoder->enc_pstats.ucomp_bits;
! std::cout<< std::endl <<
"Number of bits for V=";
! std::cout<<
m_field1_stats.vcomp_bits +
encoder->enc_pstats.vcomp_bits;
! std::cout << std::endl <<
"Total frame bits=";
! std::cout<<
m_field1_stats.pic_bits + encoder->enc_pstats.pic_bits;
! }
}
+ }
+ else
+ {
+ // Not picture data
+ encoder->enc_pparams.pnum = -1;
}
encdata->size = size;
***************
*** 719,722 ****
--- 737,742 ----
}
+ if (m_enc_picture)
+ {
//Rate Control - work out bit rate to date and for
current GOP
// and keep track of frame numbers
***************
*** 740,744 ****
m_picture_count++;
! if ( (m_gop_count==0 && m_picture_count ==
GOP_pic_length-offset) ||
(m_gop_count>0 && m_picture_count ==
GOP_pic_length))
{
--- 760,764 ----
m_picture_count++;
! if ( (m_gop_count==0 && m_picture_count ==
GOP_pic_length-offset) ||
(m_gop_count>0 && m_picture_count ==
GOP_pic_length))
{
***************
*** 762,765 ****
--- 782,786 ----
}
//End of Rate Control
+ }
m_dirac_byte_stream.Clear();
***************
*** 1050,1054 ****
try
{
! // Get the next compressed picture
if (compressor->CompressNextPicture() != 0)
{
--- 1071,1075 ----
try
{
! // Get the next compressed picture
if (compressor->CompressNextPicture() != 0)
{
Index: seq_compress.cpp
============================================================
=======
RCS file:
/cvsroot/dirac/compress/libdirac_encoder/seq_compress.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -C2 -d -r1.57 -r1.58
*** seq_compress.cpp 1 May 2008 09:51:53 -0000 1.57
--- seq_compress.cpp 21 May 2008 03:56:43 -0000 1.58
***************
*** 60,64 ****
m_pcoder( m_encparams ),
m_dirac_byte_stream(dirac_byte_stream),
! m_eos_signalled(false)
{
// Set up the compression of the sequence
--- 60,65 ----
m_pcoder( m_encparams ),
m_dirac_byte_stream(dirac_byte_stream),
! m_eos_signalled(false),
! m_prev_gop_start(-1)
{
// Set up the compression of the sequence
***************
*** 73,77 ****
m_encparams.SetXNumMB(
xl_chroma/m_encparams.ChromaBParams(0).Xbsep() );
m_encparams.SetYNumMB(
yl_chroma/m_encparams.ChromaBParams(0).Ybsep() );
!
if ( m_encparams.XNumMB() *
m_encparams.ChromaBParams(0).Xbsep() < xl_chroma )
m_encparams.SetXNumMB( m_encparams.XNumMB() + 1
);
--- 74,78 ----
m_encparams.SetXNumMB(
xl_chroma/m_encparams.ChromaBParams(0).Xbsep() );
m_encparams.SetYNumMB(
yl_chroma/m_encparams.ChromaBParams(0).Ybsep() );
!
if ( m_encparams.XNumMB() *
m_encparams.ChromaBParams(0).Xbsep() < xl_chroma )
m_encparams.SetXNumMB( m_encparams.XNumMB() + 1
);
***************
*** 180,184 ****
}
! Picture& SequenceCompressor::CompressNextPicture()
{
--- 181,185 ----
}
! const Picture* SequenceCompressor::CompressNextPicture()
{
***************
*** 219,222 ****
--- 220,226 ----
m_dirac_byte_stream.AddAccessUnit(p_accessunit_byteio);
+ m_prev_gop_start = m_current_display_pnum;
+
+ return NULL;
}
***************
*** 244,248 ****
PictureParams& pparams =
my_picture.GetPparams();
!
if (pparams.PicSort().IsRef())
m_fbuffer->SetRetiredPictureNum(
m_show_pnum, m_current_display_pnum );
--- 248,252 ----
PictureParams& pparams =
my_picture.GetPparams();
!
if (pparams.PicSort().IsRef())
m_fbuffer->SetRetiredPictureNum(
m_show_pnum, m_current_display_pnum );
***************
*** 323,327 ****
m_show_pnum << " in display
order";
}
! return m_fbuffer->GetPicture(m_show_pnum );
}
--- 327,331 ----
m_show_pnum << " in display
order";
}
! return &m_fbuffer->GetPicture(m_show_pnum );
}
***************
*** 395,400 ****
if ( m_encparams.Prefilter()==CWM )
! CWMFilter(m_fbuffer->GetPicture(
m_last_picture_read+1 ) ,
!
m_encparams.PrefilterStrength() );
m_last_picture_read++;
--- 399,404 ----
if ( m_encparams.Prefilter()==CWM )
! CWMFilter(m_fbuffer->GetPicture(
m_last_picture_read+1 ) ,
!
m_encparams.PrefilterStrength() );
m_last_picture_read++;
***************
*** 429,433 ****
bool FrameSequenceCompressor::IsNewAccessUnit()
{
! return (m_current_display_pnum %
m_encparams.GOPLength()==0);
}
--- 433,437 ----
bool FrameSequenceCompressor::IsNewAccessUnit()
{
! return (m_current_display_pnum > m_prev_gop_start
&& m_current_display_pnum %
m_encparams.GOPLength()==0);
}
***************
*** 492,499 ****
if ( m_encparams.Prefilter()==CWM )
{
! CWMFilter(m_fbuffer->GetPicture(
m_last_picture_read ),
!
m_encparams.PrefilterStrength() );
! CWMFilter(m_fbuffer->GetPicture(
m_last_picture_read+1 ) ,
!
m_encparams.PrefilterStrength() );
}
m_mebuffer->PushPicture( m_fbuffer->GetPicture(
m_last_picture_read ) );
--- 496,503 ----
if ( m_encparams.Prefilter()==CWM )
{
! CWMFilter(m_fbuffer->GetPicture(
m_last_picture_read ),
!
m_encparams.PrefilterStrength() );
! CWMFilter(m_fbuffer->GetPicture(
m_last_picture_read+1 ) ,
!
m_encparams.PrefilterStrength() );
}
m_mebuffer->PushPicture( m_fbuffer->GetPicture(
m_last_picture_read ) );
***************
*** 594,598 ****
bool FieldSequenceCompressor::IsNewAccessUnit( )
{
! return ((m_current_display_pnum) %
(m_encparams.GOPLength()<<1)==0);
}
--- 598,602 ----
bool FieldSequenceCompressor::IsNewAccessUnit( )
{
! return ((m_current_display_pnum > m_prev_gop_start)
&& ((m_current_display_pnum) %
(m_encparams.GOPLength()<<1))==0);
}
------------------------------------------------------------
-------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
a>
_______________________________________________
Dirac-commits mailing list
Dirac-commits lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dirac-com
mits
|