comparison rmenc.c @ 4097:f8a743bd2df8 libavformat

Split RMContext into RMDemux/MuxContext and make them private in rmdec/enc.c. Reason for this is that there are no shared entries in the demuxer/muxer context, making it a mystery as to why it was shared between the two. See "[PATCH] clean rmdemux/muxcontext" patch on mailinglist.
author rbultje
date Sat, 13 Dec 2008 21:40:20 +0000
parents 8b4be8aa2324
children 77e0c7511d41
comparison
equal deleted inserted replaced
4096:233ba738a68e 4097:f8a743bd2df8
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */ 20 */
21 #include "avformat.h" 21 #include "avformat.h"
22 #include "rm.h" 22 #include "rm.h"
23 23
24 typedef struct {
25 int nb_packets;
26 int packet_total_size;
27 int packet_max_size;
28 /* codec related output */
29 int bit_rate;
30 float frame_rate;
31 int nb_frames; /* current frame number */
32 int total_frames; /* total number of frames */
33 int num;
34 AVCodecContext *enc;
35 } StreamInfo;
36
37 typedef struct {
38 StreamInfo streams[2];
39 StreamInfo *audio_stream, *video_stream;
40 int data_pos; /* position of the data after the header */
41 } RMMuxContext;
42
24 /* in ms */ 43 /* in ms */
25 #define BUFFER_DURATION 0 44 #define BUFFER_DURATION 0
26 45
27 46
28 static void put_str(ByteIOContext *s, const char *tag) 47 static void put_str(ByteIOContext *s, const char *tag)
42 } 61 }
43 62
44 static void rv10_write_header(AVFormatContext *ctx, 63 static void rv10_write_header(AVFormatContext *ctx,
45 int data_size, int index_pos) 64 int data_size, int index_pos)
46 { 65 {
47 RMContext *rm = ctx->priv_data; 66 RMMuxContext *rm = ctx->priv_data;
48 ByteIOContext *s = ctx->pb; 67 ByteIOContext *s = ctx->pb;
49 StreamInfo *stream; 68 StreamInfo *stream;
50 unsigned char *data_offset_ptr, *start_ptr; 69 unsigned char *data_offset_ptr, *start_ptr;
51 const char *desc, *mimetype; 70 const char *desc, *mimetype;
52 int nb_packets, packet_total_size, packet_max_size, size, packet_avg_size, i; 71 int nb_packets, packet_total_size, packet_max_size, size, packet_avg_size, i;
269 put_byte(s, key_frame ? 2 : 0); /* flags */ 288 put_byte(s, key_frame ? 2 : 0); /* flags */
270 } 289 }
271 290
272 static int rm_write_header(AVFormatContext *s) 291 static int rm_write_header(AVFormatContext *s)
273 { 292 {
274 RMContext *rm = s->priv_data; 293 RMMuxContext *rm = s->priv_data;
275 StreamInfo *stream; 294 StreamInfo *stream;
276 int n; 295 int n;
277 AVCodecContext *codec; 296 AVCodecContext *codec;
278 297
279 for(n=0;n<s->nb_streams;n++) { 298 for(n=0;n<s->nb_streams;n++) {
313 } 332 }
314 333
315 static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int flags) 334 static int rm_write_audio(AVFormatContext *s, const uint8_t *buf, int size, int flags)
316 { 335 {
317 uint8_t *buf1; 336 uint8_t *buf1;
318 RMContext *rm = s->priv_data; 337 RMMuxContext *rm = s->priv_data;
319 ByteIOContext *pb = s->pb; 338 ByteIOContext *pb = s->pb;
320 StreamInfo *stream = rm->audio_stream; 339 StreamInfo *stream = rm->audio_stream;
321 int i; 340 int i;
322 341
323 /* XXX: suppress this malloc */ 342 /* XXX: suppress this malloc */
337 return 0; 356 return 0;
338 } 357 }
339 358
340 static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size, int flags) 359 static int rm_write_video(AVFormatContext *s, const uint8_t *buf, int size, int flags)
341 { 360 {
342 RMContext *rm = s->priv_data; 361 RMMuxContext *rm = s->priv_data;
343 ByteIOContext *pb = s->pb; 362 ByteIOContext *pb = s->pb;
344 StreamInfo *stream = rm->video_stream; 363 StreamInfo *stream = rm->video_stream;
345 int key_frame = !!(flags & PKT_FLAG_KEY); 364 int key_frame = !!(flags & PKT_FLAG_KEY);
346 365
347 /* XXX: this is incorrect: should be a parameter */ 366 /* XXX: this is incorrect: should be a parameter */
391 return rm_write_video(s, pkt->data, pkt->size, pkt->flags); 410 return rm_write_video(s, pkt->data, pkt->size, pkt->flags);
392 } 411 }
393 412
394 static int rm_write_trailer(AVFormatContext *s) 413 static int rm_write_trailer(AVFormatContext *s)
395 { 414 {
396 RMContext *rm = s->priv_data; 415 RMMuxContext *rm = s->priv_data;
397 int data_size, index_pos, i; 416 int data_size, index_pos, i;
398 ByteIOContext *pb = s->pb; 417 ByteIOContext *pb = s->pb;
399 418
400 if (!url_is_streamed(s->pb)) { 419 if (!url_is_streamed(s->pb)) {
401 /* end of file: finish to write header */ 420 /* end of file: finish to write header */
433 AVOutputFormat rm_muxer = { 452 AVOutputFormat rm_muxer = {
434 "rm", 453 "rm",
435 NULL_IF_CONFIG_SMALL("RM format"), 454 NULL_IF_CONFIG_SMALL("RM format"),
436 "application/vnd.rn-realmedia", 455 "application/vnd.rn-realmedia",
437 "rm,ra", 456 "rm,ra",
438 sizeof(RMContext), 457 sizeof(RMMuxContext),
439 CODEC_ID_AC3, 458 CODEC_ID_AC3,
440 CODEC_ID_RV10, 459 CODEC_ID_RV10,
441 rm_write_header, 460 rm_write_header,
442 rm_write_packet, 461 rm_write_packet,
443 rm_write_trailer, 462 rm_write_trailer,