示例#1
0
LIBDE265_API de265_error de265_flush_data(de265_decoder_context* de265ctx)
{
  decoder_context* ctx = (decoder_context*)de265ctx;

  if (ctx->pending_input_NAL) {
    NAL_unit* nal = ctx->pending_input_NAL;
    uint8_t null[2] = { 0,0 };

    // append bytes that are implied by the push state

    if (ctx->input_push_state==6) { rbsp_buffer_append(&nal->nal_data,null,1); }
    if (ctx->input_push_state==7) { rbsp_buffer_append(&nal->nal_data,null,2); }


    // only push the NAL if it contains at least the NAL header

    if (ctx->input_push_state>=5) {
      push_to_NAL_queue(ctx, nal);
      ctx->pending_input_NAL = NULL;
    }

    ctx->input_push_state = 0;
  }

  ctx->end_of_stream = true;

  return DE265_OK;
}
示例#2
0
文件: de265.c 项目: bzd2132/libde265
LIBDE265_API de265_error de265_decode_data(de265_decoder_context* de265ctx, const void* data, int len)
{
  decoder_context* ctx = (decoder_context*)de265ctx;


  if (len==0) {
    ctx->end_of_stream = true;
  }


  // process the data that is still pending for input

  if (ctx->pending_input_data.size > 0) {

    de265_error err = de265_decode_pending_data(de265ctx);

    // if something went wrong, or more data is pending
    // -> append new input data to pending-input buffer
    if (err != DE265_OK || ctx->pending_input_data.size!=0) {
      if (len>0) {
        rbsp_buffer_append(&ctx->pending_input_data, (const uint8_t*)data,len);
      }

      return err;
    }
  }


  de265_error err = DE265_OK;
  int nBytesProcessed = 0;

  if (has_free_dpb_picture(ctx)) {
    err = process_data(ctx,(const uint8_t*)data,len, &nBytesProcessed);
  }

  if (nBytesProcessed != len) {
    //printf("%d %d\n",nBytesProcessed,len);

    // save remaining bytes

    assert(ctx->pending_input_data.size==0); // assume pending-input buffer is empty
    rbsp_buffer_append(&ctx->pending_input_data, (const uint8_t*)data+nBytesProcessed, len-nBytesProcessed);
  }

  return err;
}