int bs2(int *arr,int first,int last,int target){
	if(first>last) return -1;
	int mid=(first+last)/2;
	if(arr[mid]==target) return mid;
	else if(arr[mid]>target) return bs2(arr,first,mid-1,target);
	else return bs2(arr,mid+1,last,target);
}
//*******************************
int copyVideoSlave( muxerMT *context )
{
DIA_encoding *work=(DIA_encoding *)context->opaque;
ADMBitstream *bitstream=context->bitstream;

  printf("[CopyVideoThread] Starting\n");
  uint32_t position;
  for(uint32_t i=0;i<context->nbVideoFrame;i++)
  {

    bitstream->cleanup(i);
    if(context->videoAbort)
    {
      context->videoDone=1;
      context->muxer->audioEof();
      return 1;
    }
    if(!context->videoEncoder->encode( i,bitstream))
    {
      accessMutex.lock();
      context->videoDone=2;
      context->muxer->audioEof();
      accessMutex.unlock();
      printf("[CopyVideoThread] Exiting on error\n");
      return 1;
    }
    if(!bitstream->len)
      continue;
    
    if(lookupSeqEnd(bitstream,&position))
    {
        ADMBitstream bs2(bitstream->bufferSize); // Mostly correct
                if(position) 
                {
                  bs2.data=context->bitstream->data;
                  bs2.len=position;
                  context->muxer->writeVideoPacket(&bs2);
                }
                bs2.data=bitstream->data+position+4;
                bs2.len=bitstream->len-position-4;
                if(bs2.len) context->muxer->writeVideoPacket(&bs2);
    } 
    else 
      context->muxer->writeVideoPacket(bitstream); 
  

    accessMutex.lock();
    context->currentVideoFrame=i;
    context->feedVideo+=bitstream->len;
    work->setFrame(i,bitstream->len,bitstream->out_quantizer,frameEnd-frameStart);
    accessMutex.unlock();
  }        
  accessMutex.lock();
  context->videoDone=1;
  context->muxer->audioEof();
  accessMutex.unlock();

  printf("[CopyVideoThread] Exiting\n");
  return 1;
}
示例#3
0
TEST(BitSet, Basics)
{
	BitSet32 bs;
	BitSet64 bs2(1);
	BitSet64 bs3(2);
	EXPECT_EQ(true, !!bs2);
	EXPECT_EQ(false, !!bs);
	EXPECT_EQ(bs2, bs2);
	EXPECT_NE(bs2, bs3);
	EXPECT_EQ(BitSet32(0xfff), BitSet32::AllTrue(12));
	EXPECT_EQ(BitSet64(0xffffffffffffffff), BitSet64::AllTrue(64));
}
示例#4
0
	static void run(In& _in, Out& _out) {
		T1 bs1;
		bs1.getRootNode() % _in;
		bs1.close();

		//std::cout<<"json:"<<std::endl;
		//std::cout<<(char*)bs1.getData().data()<<std::endl;
		//std::cout<<":json"<<std::endl;
		//std::cout << "yaml:\n" << bs1.getDataAsStr() << std::endl;


		T2 bs2 (bs1.getData());

		bs2.getRootNode() % _out;
		bs2.close();
	}
示例#5
0
void ModelTest()
{
	int array[4][4]={1};
	int i,j;
	try
	{
		BaseShape bs1(1);
		if (bs1.get_color()==0)
			throw int(2);
		BaseShape bs2(2);
		if (bs2.get_color()!=2)
			throw int(2);

		BaseShape bs3(bs1);
		if (ShapeEqual(bs1,bs3))
			throw int(2);
		if (!ShapeEqual(bs2,bs3))
			throw int(2);
		if (ShapeEqual(bs3,BaseShape(bs1)))
			throw int(2);
		if (!ShapeEqual(bs3,BaseShape(bs2)))
			throw int(2);
		
		BaseShape bs4=bs1;
		if (ShapeEqual(bs1,bs4))
			throw int(2);
		if (!ShapeEqual(bs2,bs4))
			throw int(2);
		BaseShape bs5=BaseShape(bs2);
		if (ShapeEqual(bs2,bs5))
			throw int(2);
		if (!ShapeEqual(bs1,bs5))
			throw int(2);

		BaseShape s(0);

		s.set_x(1);
		if (s.get_x()!=1)
			throw int(2);
		s.set_x(2);
		if (s.get_x()==1)
			throw int(2);
		
		s.set_y(1);
		if (s.get_y()!=1)
			throw int(2);
		s.set_y(2);
		if (s.get_y()==1)
			throw int(2);

		s.set_color(1);
		if (s.get_color()!=1)
			throw int(2);
		s.set_color(2);
		if (s.get_color()==1)
			throw int(2);

		s.move_left();
		if (s.get_x()!=1)
			throw int(2);

		s.move_right();
		s.move_right();
		if (s.get_x()!=3)
			throw int(2);

		s.move_down();
		if (s.get_color()!=1)
			throw int(2);

		for(i=0 ;i<4 ;i++)
		for(j=0 ;j<4 ;j++)
			if (s.get_matrix(i,j))
				throw int(2);

		s.Rotate();
		if (s.get_dir()!=1)
			throw int(2);

	}
	catch(...)
	{
		printf("shape exception!");
	}

	try
	{
		Map m1;
		for(i=0 ;i<4 ;i++)
		for(j=0 ;j<4 ;j++)
			if(m1.get_exist(i,j)||m1.get_color(i,j))
				throw int(3);
		Map m2(m1);
		for(i=0 ;i<4 ;i++)
		for(j=0 ;j<4 ;j++)
			if(m2.get_exist(i,j)||m2.get_color(i,j))
				throw int(3);

		if(Map(m1).get_exist(0,0))
				throw int(3);

		Map m3=m1;
		for(i=0 ;i<4 ;i++)
		for(j=0 ;j<4 ;j++)
			if(m3.get_exist(i,j)||m3.get_color(i,j))
				throw int(3);
		Map m4=Map(m1);
		for(i=0 ;i<4 ;i++)
		for(j=0 ;j<4 ;j++)
			if(m4.get_exist(i,j)||m4.get_color(i,j))
				throw int(3);


	}
	catch(...)
	{
		printf("map exception!");
	}

	try
	{
		Board b1;
		if (b1.get_points()!=0)
			throw int(4);
		Board b2(b1);
		if (b2.get_points()!=0)
			throw int(4);
		if (b1.add_points(10) != 10)
			throw int(4);

		if (Board(b2).get_points()!=0)
			throw int(4);	
		Board b4=b2;
		if (b4.get_points()!=0)
			throw int(4);
		Board b5=Board(b2);
		if (b5.get_points()!=0)
			throw int(4);
	}
	catch(...)
	{
		printf("board exception!");
	}
}
示例#6
0
void fullTest() {
	{
		A in, out;
		in.x = 0x12345678;

		TestF<S, D>::run(in, out);
		EXPECT_EQ(in.x, out.x);

	}

	{
		B in, out;
		in.a.x = 0x12345678;
		out.ptr = nullptr;

		TestF<S, D>::run(in, out);
		EXPECT_EQ(&in.a, in.ptr);
		EXPECT_EQ(&out.a, out.ptr);

	}
	{
		AD in, out;
		in.aPtr = &in.a;
		in.xPtr = &in.a.x;

		TestF<S, D>::run(in, out);
		EXPECT_EQ(in.aPtr, &in.a);
		EXPECT_EQ(in.xPtr, &in.a.x);

		EXPECT_EQ(out.aPtr, &out.a);
		EXPECT_EQ(out.xPtr, &out.a.x);

	}

	{
		Loop_0 in;
		Loop_0 out;
		in.a.ptr = &in.b;
		in.b.ptr = &in.a;

		EXPECT_EQ(in.a.ptr, &in.b);
		EXPECT_EQ(in.b.ptr, &in.a);

		S bs1;
		bs1.getRootNode() % in;
		bs1.close();

//		std::cout<<(char*)bs1.getData().data()<<std::endl;

		D bs2 (bs1.getData());

		bs2.getRootNode() % out;
		bs2.close();

		EXPECT_EQ(in.a.ptr, &in.b);
		EXPECT_EQ(in.b.ptr, &in.a);

		EXPECT_EQ(out.a.ptr, &out.b);
		EXPECT_EQ(out.b.ptr, &out.a);
	}
	{
		Loop_1 in;
		Loop_1 out;
		in.a.ptr = &in.b;
		in.b.ptr = &in.a;

		EXPECT_EQ(in.a.ptr, &in.b);
		EXPECT_EQ(in.b.ptr, &in.a);

		S bs1;
		bs1.getRootNode() % in;
		bs1.close();

//		std::cout<<(char*)bs1.getData().data()<<std::endl;

		D bs2 (bs1.getData());

		bs2.getRootNode() % out;
		bs2.close();

		EXPECT_EQ(in.a.ptr, &in.b);
		EXPECT_EQ(in.b.ptr, &in.a);

		EXPECT_EQ(out.a.ptr, &out.b);
		EXPECT_EQ(out.b.ptr, &out.a);
	}

	{
		Loop_2 in;
		Loop_2 out;
		in.a.ptr = &in.b;
		in.b.ptr = &in.a;

		EXPECT_EQ(in.a.ptr, &in.b);
		EXPECT_EQ(in.b.ptr, &in.a);

		S bs1;
		bs1.getRootNode() % in;
		bs1.close();

//		std::cout<<(char*)bs1.getData().data()<<std::endl;

		D bs2 (bs1.getData());

		bs2.getRootNode() % out;
		bs2.close();

		EXPECT_EQ(in.a.ptr, &in.b);
		EXPECT_EQ(in.b.ptr, &in.a);

		EXPECT_EQ(out.a.ptr, &out.b);
		EXPECT_EQ(out.b.ptr, &out.a);
	}

}
示例#7
0
文件: main.cpp 项目: CCJY/coliru
int main() {
    Inkr inkr;
    bs1(inkr);
    bs2(inkr);
}