예제 #1
0
파일: de265.c 프로젝트: tejainece/libde265
LIBDE265_API de265_error de265_decode(de265_decoder_context* de265ctx, int* more)
{
  decoder_context* ctx = (decoder_context*)de265ctx;

  // if the stream has ended, and no more NALs are to be decoded, flush all pictures

  if (ctx->NAL_queue_len == 0 && ctx->end_of_stream) {
    if (more) { *more=0; } // 0 if no more pictures in queue

    push_current_picture_to_output_queue(ctx);

    while (ctx->reorder_output_queue_length>0) {
      flush_next_picture_from_reorder_buffer(ctx);
      if (more) { *more=1; }
    }

    return DE265_OK;
  }


  // if NAL-queue is empty, we need more data
  // -> input stalled

  if (ctx->NAL_queue_len == 0) {
    if (more) { *more=1; }

    return DE265_ERROR_WAITING_FOR_INPUT_DATA;
  }


  // when there are no free image buffers in the DPB, pause decoding
  // -> output stalled

  if (!has_free_dpb_picture(ctx, false)) {
    if (more) *more = 1;
    return DE265_ERROR_IMAGE_BUFFER_FULL;
  }


  // decode one NAL from the queue

  NAL_unit* nal = pop_from_NAL_queue(ctx);
  assert(nal);
  de265_error err = de265_decode_NAL(de265ctx, nal);
  free_NAL_unit(ctx,nal);

  if (more) {
    // decoding error is assumed to be unrecoverable
    *more = (err==DE265_OK);
  }

  return err;
}
예제 #2
0
파일: de265.c 프로젝트: bzd2132/libde265
LIBDE265_API const struct de265_image* de265_peek_next_picture(de265_decoder_context* de265ctx)
{
  decoder_context* ctx = (decoder_context*)de265ctx;

  // check for empty queue -> return NULL

  if (ctx->image_output_queue_length==0) {
    de265_error err = de265_decode_pending_data(de265ctx);
    // TODO: what do we do with the error code ?

    if (ctx->end_of_stream && ctx->pending_input_data.size==0) {
      while (ctx->reorder_output_queue_length>0) {
        flush_next_picture_from_reorder_buffer(ctx);
      }
    }

    if (ctx->image_output_queue_length==0) {
      return NULL;
    }
  }

  return ctx->image_output_queue[0];
}