From: Erik W. <om...@te...> - 2001-10-29 08:57:33
|
Here's an attempt at a piece of user code for a basic mpeg2 player, using the lowest-level API. This is gonna look like a gstreamer plugin, and really really rough....: int more_data(bitstream_t *bs, unsigned char **buf, int *len) { mpeg2element *element = bitstream_get_private(bs); GstBuffer *buffer = gst_pad_pull(element->dec); *buf = GST_BUFFER_DATA(buffer); *len = GST_BUFFER_SIZE(buffer); // store buffer somewhere for future unref } // would probably need a callback to unref the buffer dec = mpeg2_init(); bs = bitstream_init(); bitstream_set_callback(bs,more_data); bitstream_set_private(bs,element); mpeg2_set_bitstream(dec,bs); mpeg2_parse_sequence(dec,seq); while(1) { mpeg2_parse_picture(dec,&pic); while (mpeg2_parse_slice(dec,&slice)) { while (mpeg2_parse_macroblock(dec,&mb)) { mpeg2_idct(dec,&mb); mpeg2_motion_comp(dec,&mb); mpeg2_place(dec,&mb,&image); } } } A mainloop for something with hardware motion comp would look like: while(1) { mpeg2_parse_picture(dec,&pic); while (mpeg2_parse_slice(dec,&slice)) { while (mpeg2_parse_macroblock(dec,&mb)) { send_mb_data_to_hardware(&slice,&mb); } } } An alternate use for the low-level API is when recoding to something else, say MPEG-4. You'd want to extract the motion-vectors and keep track of them as hints for motion-search in the mpeg-4 code, or even just steal them <g>. For something like mp3, there are things you can do with the subband data that will save you time, like applying basic equalization. Given a low-level API for that (parse, process, synthesize), you can do whatever funky processing you need to. Totally impossible without a low-level API, unless you spend a lot more time later doing the processing the hard way (i.e. doing full motion-search, or applying an expensive EQ). Erik Walthinsen <om...@te...> - System Administrator __ / \ GStreamer - The only way to stream! | | M E G A ***** http://gstreamer.net/ ***** _\ /_ |