Beispiel #1
0
int get_av1config_from_obu(const uint8_t *buffer, size_t length, int is_annexb,
                           Av1Config *config) {
  if (!buffer || length == 0 || !config) {
    return -1;
  }

  ObuHeader obu_header;
  memset(&obu_header, 0, sizeof(obu_header));

  size_t sequence_header_length = 0;
  size_t obu_header_length = 0;
  if (aom_read_obu_header_and_size(buffer, length, is_annexb, &obu_header,
                                   &sequence_header_length,
                                   &obu_header_length) != AOM_CODEC_OK ||
      obu_header.type != OBU_SEQUENCE_HEADER ||
      sequence_header_length + obu_header_length > length) {
    return -1;
  }

  memset(config, 0, sizeof(*config));
  config->marker = 1;
  config->version = 1;
  return parse_sequence_header(buffer + obu_header_length,
                               sequence_header_length, config);
}
void METH(frame)
		(t_bit_buffer	*p_bitstream,	/**< Input buffer */
		void 		*sei, 		/**< TimeStamp */
	  t_uint32 nTimeStampH, t_uint32 nTimeStampL, /**< TimeStamp */
		t_uint32 	nFlags)	/**< Openmax flags */
{
	  t_vc1_picture_type 	picture_type;
		t_hamac_param *param_in;
    ts_bitstream_buffer  decoder_bitstream;


	if( p_bitstream )
	{
     	OstTraceFiltInst1(TRACE_API,  "VC1Dec: arm_nmf: decoder: frame(): size = %d\\n", p_bitstream->end - p_bitstream->addr);
#if VERBOSE_STANDARD == 1
		NMF_LOG("NMF-ARM decoder: call to frame(), size = %d\n",p_bitstream->end - p_bitstream->addr);
#endif

	}


	if(p_bitstream == NULL)
	{
		if( nFlags & OSI_OMX_BUFFERFLAG_EOS )
		{
			// Case of end of stream.
			// all frame data have already been received - last buffer is empty and only used to send EOS flag

            OstTraceFiltInst0(TRACE_FLOW,  "Handle end of stream (empty buffer)\n");
#if VERBOSE_STANDARD == 1
      			NMF_LOG("Handle end of stream (empty buffer)\n");
#endif
      			// we post a void frame (fake frame to go through the pipe)
			// The void frame will be recognized in the output stage
			// this will indicate that all received frames have been decoded (we can bump last frame)

    			hamac_pipe_reset_frame();

    			//commented for ER 370888
			//hamac_pipe_set_void_frame_info(VOID_FRAME_EOS_WITH_FLUSH);

			// BumpFrame will choose oldest ref, so let's mark most recent ref as oldest ref
      			if(dec_static.buf.oldest_ref == 0)
         			dec_static.buf.oldest_ref = 1;
      			else
         			dec_static.buf.oldest_ref = 0;
      			// Here call it with Pic type != B in order to make it bump the oldest ref
      			BumpFrame(PICTURE_TYPE_I,&dec_static.buf);

				//+change for ER 370888
      			if (hamac_pipe_mark_eos_frame())   // this will set OMX EOS flag in last buffer, needed by proxy
      			{
					OstTraceFiltInst0(TRACE_FLOW,  "VC1Dec: arm_nmf: decoder: TRUE for hamac_pipe_mark_eos_frame()");
					hamac_pipe_set_void_frame_info(VOID_FRAME_EOS_WITH_FLUSH);
				}
				else
				{
					OstTraceFiltInst0(TRACE_FLOW,  "VC1Dec: arm_nmf: decoder: FALSE for hamac_pipe_mark_eos_frame()");
					hamac_pipe_set_void_frame_info(VOID_FRAME_EOS_WO_FLUSH);
				}
				//- change for ER 370888

			if (dec_static.sva_bypass == 1) {
				endCodec(STATUS_JOB_COMPLETE, VDC_VOID, 0);
			}
			else {
				iStartCodec.voidFrame();
			}
		}

		return;
	}

	/* wrap bitstream structure into VC1 bitstream structure */
    	decoder_bitstream.data = p_bitstream->addr;
    	decoder_bitstream.size_in_bits = 8 * (p_bitstream->end - p_bitstream->addr);
    	decoder_bitstream.pt_current_byte = p_bitstream->addr;
    	decoder_bitstream.index_current_bit = 0;

	if(seq_param_received == FALSE)
	{
		// first buffer : contains sequence parameters (no frame data)
		OMX_ERRORTYPE error = parse_sequence_header(&decoder_bitstream,&seq_params); // For ER 344032
        /* + For ER 344032 */
		if (error == OMX_ErrorFormatNotDetected)
        {
            OstTraceInt0(TRACE_ERROR,  "VC1Dec: arm_nmf: decoder: frame():Error OMX_ErrorFormatNotDetected ");
            proxy.eventHandler(OMX_EventError,error,0);
        }
		/* For ER 344032 */
        seq_param_received = TRUE;
		// We will now estimate the level from the number of MBs per frame
    		seq_params.level = find_level_from_image_size(seq_params.profile,
                                                        	picture_width,
                                                        	picture_height);

		// init input parameters
		init_codec();

		// release bitstream and request a new input buffer
		p_bitstream->next = 0;  // don't use linked lists
    		p_bitstream->inuse = 0;  // tell to input control that this buffer is not in use
    		input_control_acknowledge(p_bitstream, XON);
	}
	else
	{
		// following buffers : contain frames data

    //MeasureEventStart0(TRACE_EVENT_BUFFER_START,"decoder buffer processing");

	  // Init DPB with a dummy reference (grey pixels)
	  // -> used to decode P or B-frames after seek
	  // -> used for error concealment
	  if( !ref_frame_initialized )
	    {
	      InsertDummyRefIntoDpb(&dec_static.buf,
				    picture_width,
				    picture_height);
	      ref_frame_initialized = TRUE;
	    }

	  	// exit pause state when receive a new frame
	  	if( low_power_state == TRUE )
	  	{
	  		low_power_state = FALSE;
	  		iStartCodec.preventSleep();
	  	}

    		// We read the frame type
   	 	btpar_parse_picture_type(&decoder_bitstream,&seq_params,&picture_type);

    		// Get the position in the DPB corresponding to current frame
    		t_sint16 index = InsertFrame(picture_type,&dec_static.buf, 0, &dec_static.sva_buffers);
    		dec_static.buf.curr_info = &dec_static.buf.pics_buf[index];
    		dec_static.sva_buffers.curr_frame = dec_static.buf.curr_info->ptr[0];
    		dec_static.sva_buffers.curr_bitstream = p_bitstream;

    		// store timestamp associated to current picture into the frames table
    		// this info is not used by the decoder itself, it is just carried from input to output buffers
    		dec_static.buf.frames[dec_static.buf.curr_info->frame_pos].frameinfo.common_frameinfo.nTimeStampH = nTimeStampH;
    		dec_static.buf.frames[dec_static.buf.curr_info->frame_pos].frameinfo.common_frameinfo.nTimeStampL = nTimeStampL;

    		// store Openmax flags (end of stream, ...)
    		dec_static.buf.frames[dec_static.buf.curr_info->frame_pos].nFlags = nFlags;

		// Get the pointer on a Param_in structure , from the fifo use in front of HW decoder
    		hamac_pipe_reset_frame();
		param_in = hamac_pipe_get_write_param_in();
		HamacFillParamIn(vfm_memory_ctxt,&dec_static,0,param_in);
    		hamac_pipe_set_frame_pos(dec_static.buf.curr_info->frame_pos);

    		hamac_pipe_set_bit_buffer_addr(p_bitstream); // store bitstream addr to be able to release it after decoding
    		p_bitstream->next = 0;  // don't use linked lists
    		p_bitstream->inuse = VCL_UNDER_PROCESSING;  // tell to input control that this buffer is in use
    		input_control_acknowledge(p_bitstream, XON);      // this will make p_bitstream as pending for release
                                                 	// and will request a new input buffer if the pipe is not full

    		// Determine which picture will be output after current frame's decoding
    		BumpFrame(picture_type,&dec_static.buf);

    		// Case of end of stream. In all cases, need to output most recent ref
    		if( nFlags & OSI_OMX_BUFFERFLAG_EOS )
    		{
        OstTraceFiltInst1(TRACE_FLOW, "VC1Dec: arm_nmf: decoder: frame(): Handle end of stream - Flow line %d\n", __LINE__);
#if VERBOSE_STANDARD == 1
      			NMF_LOG("Handle end of stream\n");
#endif
      			// BumpFrame will choose oldest ref, so let's mark most recent ref as oldest ref
      			if(dec_static.buf.oldest_ref == 0)
         			dec_static.buf.oldest_ref = 1;
      			else
         			dec_static.buf.oldest_ref = 0;
      			// Here call it with Pic type != B in order to make it bump the oldest ref
      			BumpFrame(PICTURE_TYPE_I,&dec_static.buf);

      			hamac_pipe_mark_eos_frame();   // this will set OMX EOS flag in last buffer, needed by proxy
    		}

	if (dec_static.sva_bypass == 1)
  {
     // bypass DSP processing, only used for ARM load evaluation
     hamac_pipe_set_void_frame_info(VOID_FRAME_ALGO_BYPASS);
	   endCodec(STATUS_JOB_COMPLETE, VDC_VOID, 0);
  }
  else
  {

#ifdef _CACHE_OPT_
    	// Force cache clean to be sure that bitstream has been written in SDRAM
	    t_uint8 *fl_end_addr,*fl_start_addr;
	    fl_start_addr= (t_uint8*) p_bitstream->addr;
	    fl_end_addr=(t_uint8*) p_bitstream->end;
	    VFM_CacheClean(vfm_memory_ctxt, fl_start_addr,fl_end_addr-fl_start_addr+1);
	    OMX_U32 tempAddr;
	    OMX_U8 *tempPtr;

	    tempAddr = Endianess(param_in->addr_out_frame_buffer->addr_dest_buffer);
	    tempPtr = VFM_GetLogical(vfm_memory_ctxt, (t_uint8 *)tempAddr);
		VFM_CacheInvalidate(vfm_memory_ctxt, tempPtr,(picture_height*picture_width*1.5));

#endif

   		HamacToPhysicalAddresses(vfm_memory_ctxt,param_in, 0);

#if VERBOSE_STANDARD == 1
   		NMF_LOG("NMF-ARM decoder: call to startCodec\n");
#endif
   		iStartCodec.startCodec((t_uint32)param_in->addr_in_frame_buffer ,
				                  (t_uint32)param_in->addr_out_frame_buffer,
				                  (t_uint32)param_in->addr_internal_buffer,
				                  (t_uint32)param_in->addr_in_bitstream_buffer,
				                  (t_uint32)param_in->addr_out_bitstream_buffer,
				                  (t_uint32)param_in->addr_in_parameters,
				                  (t_uint32)param_in->addr_out_parameters,
                  				(t_uint32)param_in->addr_in_frame_parameters,
                  				(t_uint32)param_in->addr_out_frame_parameters);
   } // no SVA bypass

    //MeasureEventStop(TRACE_EVENT_BUFFER_STOP,"decoder buffer processing");
	}
}