comparison libtheoraenc.c @ 10679:c1328f04458a libavcodec

libtheoraenc.c: mark keyframes
author conrad
date Sat, 12 Dec 2009 20:18:46 +0000
parents aacf5f712ba7
children d569841bd1b7
comparison
equal deleted inserted replaced
10678:fe3cdc16514b 10679:c1328f04458a
44 uint8_t *stats; 44 uint8_t *stats;
45 int stats_size; 45 int stats_size;
46 int stats_offset; 46 int stats_offset;
47 int uv_hshift; 47 int uv_hshift;
48 int uv_vshift; 48 int uv_vshift;
49 int keyframe_mask;
49 } TheoraContext; 50 } TheoraContext;
50 51
51 /*! 52 /*!
52 Concatenates an ogg_packet into the extradata. 53 Concatenates an ogg_packet into the extradata.
53 */ 54 */
216 if (!h->t_state) { 217 if (!h->t_state) {
217 av_log(avc_context, AV_LOG_ERROR, "theora_encode_init failed\n"); 218 av_log(avc_context, AV_LOG_ERROR, "theora_encode_init failed\n");
218 return -1; 219 return -1;
219 } 220 }
220 221
222 h->keyframe_mask = (1 << t_info.keyframe_granule_shift) - 1;
221 /* Clear up theora_info struct */ 223 /* Clear up theora_info struct */
222 th_info_clear(&t_info); 224 th_info_clear(&t_info);
223 225
224 if (th_encode_ctl(h->t_state, TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE, 226 if (th_encode_ctl(h->t_state, TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE,
225 &gop_size, sizeof(gop_size))) { 227 &gop_size, sizeof(gop_size))) {
334 } 336 }
335 memcpy(outbuf, o_packet.packet, o_packet.bytes); 337 memcpy(outbuf, o_packet.packet, o_packet.bytes);
336 338
337 // HACK: does not take codec delay into account (neither does the decoder though) 339 // HACK: does not take codec delay into account (neither does the decoder though)
338 avc_context->coded_frame->pts = frame->pts; 340 avc_context->coded_frame->pts = frame->pts;
341 avc_context->coded_frame->key_frame = !(o_packet.granulepos & h->keyframe_mask);
339 342
340 return o_packet.bytes; 343 return o_packet.bytes;
341 } 344 }
342 345
343 static av_cold int encode_close(AVCodecContext* avc_context) 346 static av_cold int encode_close(AVCodecContext* avc_context)