Skip to content

Commit 00c9323

Browse files
committed
daalaenc: Remove the last parameter from daala_encode_packet_out()
It is very rare that applications know when the last frame is being processed, and this information is exclusively used for OGG muxing. Move the necessary OGG parameter outside the library to the example code, and simplify checking encoder state a bit.
1 parent 5773936 commit 00c9323

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

examples/encoder_example.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,11 @@ int fetch_and_process_video(av_input *avin, ogg_page *page,
493493
/*Pull the packets from the previous frame, now that we know whether or not
494494
we can read the current one.
495495
This is used to set the e_o_s bit on the final packet.*/
496-
while (daala_encode_packet_out(dd, last, &dp)) {
496+
while (daala_encode_packet_out(dd, &dp)) {
497497
ogg_packet op;
498498

499499
daala_to_ogg_packet(&op, &dp);
500+
op->e_o_s = last;
500501

501502
ogg_stream_packetin(vo, &op);
502503
}

include/daala/daalaenc.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,6 @@ int daala_encode_img_in(daala_enc_ctx *enc, od_img *img, int duration);
121121
* manner.
122122
* However, this may be changed in the future.
123123
* \param enc A #daala_enc_ctx handle.
124-
* \param last Set this flag to a non-zero value if no more uncompressed
125-
* frames will be submitted.
126-
* This ensures that a proper EOS flag is set on the last packet.
127124
* \param dp A <tt>daala_packet</tt> structure to fill.
128125
* All of the elements of this structure will be set, including a
129126
* pointer to the video data.
@@ -133,8 +130,7 @@ int daala_encode_img_in(daala_enc_ctx *enc, od_img *img, int duration);
133130
* \retval 0 No packet was produced, and no more encoded video data
134131
* remains.
135132
* \retval OD_EFAULT \a enc or \a op was <tt>NULL</tt>.*/
136-
int daala_encode_packet_out(daala_enc_ctx *enc,
137-
int last, daala_packet *dp);
133+
int daala_encode_packet_out(daala_enc_ctx *enc, daala_packet *dp);
138134
/**Frees an allocated encoder instance.
139135
* \param enc A #daala_enc_ctx handle.*/
140136
void daala_encode_free(daala_enc_ctx *enc);

src/encode.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2657,7 +2657,6 @@ int daala_encode_img_in(daala_enc_ctx *enc, od_img *img, int duration) {
26572657
od_mb_enc_ctx mbctx;
26582658
od_img *ref_img;
26592659
if (enc == NULL || img == NULL) return OD_EFAULT;
2660-
if (enc->packet_state == OD_PACKET_DONE) return OD_EINVAL;
26612660
/*Check the input image dimensions to make sure they're compatible with the
26622661
declared video size.*/
26632662
nplanes = enc->state.info.nplanes;
@@ -2862,22 +2861,21 @@ static void daala_encoder_check(daala_enc_ctx *ctx, od_img *img,
28622861
}
28632862
#endif
28642863

2865-
int daala_encode_packet_out(daala_enc_ctx *enc, int last, daala_packet *op) {
2864+
int daala_encode_packet_out(daala_enc_ctx *enc, daala_packet *op) {
28662865
uint32_t nbytes;
28672866
if (enc == NULL || op == NULL) return OD_EFAULT;
2868-
else if (enc->packet_state <= 0 || enc->packet_state == OD_PACKET_DONE) {
2867+
else if (enc->packet_state <= 0) {
28692868
return 0;
28702869
}
28712870
op->packet = od_ec_enc_done(&enc->ec, &nbytes);
28722871
op->bytes = nbytes;
28732872
OD_LOG((OD_LOG_ENCODER, OD_LOG_INFO, "Output Bytes: %ld (%ld Kbits)",
28742873
op->bytes, op->bytes*8/1024));
28752874
op->b_o_s = 0;
2876-
op->e_o_s = last;
2875+
op->e_o_s = 0;
28772876
op->packetno = 0;
28782877
op->granulepos = enc->state.cur_time;
2879-
if (last) enc->packet_state = OD_PACKET_DONE;
2880-
else enc->packet_state = OD_PACKET_EMPTY;
2878+
enc->packet_state = OD_PACKET_EMPTY;
28812879

28822880
#if defined(OD_ENCODER_CHECK)
28832881
/*Compare reconstructed frame against decoded frame.*/

0 commit comments

Comments
 (0)