Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Daalaenc #143

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/encoder_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,11 @@ int fetch_and_process_video(av_input *avin, ogg_page *page,
/*Pull the packets from the previous frame, now that we know whether or not
we can read the current one.
This is used to set the e_o_s bit on the final packet.*/
while (daala_encode_packet_out(dd, last, &dp)) {
while (daala_encode_packet_out(dd, &dp)) {
ogg_packet op;

daala_to_ogg_packet(&op, &dp);
op.e_o_s = last;

ogg_stream_packetin(vo, &op);
}
Expand Down
10 changes: 3 additions & 7 deletions include/daala/daalaenc.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ typedef struct daala_enc_ctx daala_enc_ctx;
* The basic steps are:
* - Fill in a #daala_info structure with details on the format of the video
* you wish to encode.
* - Allocate a #daala_enc_ctx handle with daala_encode_alloc().
* - Allocate a #daala_enc_ctx handle with daala_encode_create().
* - Perform any additional encoder configuration required with
* daala_encode_ctl().
* - Repeatedly call daala_encode_flusheader() to retrieve all the header
* - Repeatedly call daala_encode_flush_header() to retrieve all the header
* packets.
* - For each uncompressed frame:
* - Submit the compressed frame via daala_encode_img_in().
Expand Down Expand Up @@ -121,9 +121,6 @@ int daala_encode_img_in(daala_enc_ctx *enc, od_img *img, int duration);
* manner.
* However, this may be changed in the future.
* \param enc A #daala_enc_ctx handle.
* \param last Set this flag to a non-zero value if no more uncompressed
* frames will be submitted.
* This ensures that a proper EOS flag is set on the last packet.
* \param dp A <tt>daala_packet</tt> structure to fill.
* All of the elements of this structure will be set, including a
* pointer to the video data.
Expand All @@ -133,8 +130,7 @@ int daala_encode_img_in(daala_enc_ctx *enc, od_img *img, int duration);
* \retval 0 No packet was produced, and no more encoded video data
* remains.
* \retval OD_EFAULT \a enc or \a op was <tt>NULL</tt>.*/
int daala_encode_packet_out(daala_enc_ctx *enc,
int last, daala_packet *dp);
int daala_encode_packet_out(daala_enc_ctx *enc, daala_packet *dp);
/**Frees an allocated encoder instance.
* \param enc A #daala_enc_ctx handle.*/
void daala_encode_free(daala_enc_ctx *enc);
Expand Down
10 changes: 4 additions & 6 deletions src/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2657,7 +2657,6 @@ int daala_encode_img_in(daala_enc_ctx *enc, od_img *img, int duration) {
od_mb_enc_ctx mbctx;
od_img *ref_img;
if (enc == NULL || img == NULL) return OD_EFAULT;
if (enc->packet_state == OD_PACKET_DONE) return OD_EINVAL;
/*Check the input image dimensions to make sure they're compatible with the
declared video size.*/
nplanes = enc->state.info.nplanes;
Expand Down Expand Up @@ -2862,22 +2861,21 @@ static void daala_encoder_check(daala_enc_ctx *ctx, od_img *img,
}
#endif

int daala_encode_packet_out(daala_enc_ctx *enc, int last, daala_packet *op) {
int daala_encode_packet_out(daala_enc_ctx *enc, daala_packet *op) {
uint32_t nbytes;
if (enc == NULL || op == NULL) return OD_EFAULT;
else if (enc->packet_state <= 0 || enc->packet_state == OD_PACKET_DONE) {
else if (enc->packet_state <= 0) {
return 0;
}
op->packet = od_ec_enc_done(&enc->ec, &nbytes);
op->bytes = nbytes;
OD_LOG((OD_LOG_ENCODER, OD_LOG_INFO, "Output Bytes: %ld (%ld Kbits)",
op->bytes, op->bytes*8/1024));
op->b_o_s = 0;
op->e_o_s = last;
op->e_o_s = 0;
op->packetno = 0;
op->granulepos = enc->state.cur_time;
if (last) enc->packet_state = OD_PACKET_DONE;
else enc->packet_state = OD_PACKET_EMPTY;
enc->packet_state = OD_PACKET_EMPTY;

#if defined(OD_ENCODER_CHECK)
/*Compare reconstructed frame against decoded frame.*/
Expand Down