1 #include <VLIB/video_controller.h>
2 #include <VLIB/video_packetizer.h>
4 #include "p264_codec.h"
5 #include "p264_layers.h"
6 #include <VP_Os/vp_os_print.h>
8 C_RESULT p264_write_picture_layer( video_controller_t* controller, video_stream_t* stream )
10 uint32_t format = 0, resolution = 0, width, height;
12 p264_codec_t* p264_codec = (p264_codec_t*) controller->video_codec;
13 p264_picture_layer_t* picture_layer = &p264_codec->picture_layer;
15 width = controller->width;
16 height = controller->height;
20 if( width == QQCIF_WIDTH )
21 format = UVLC_FORMAT_CIF;
23 if( width == QQVGA_WIDTH )
24 format = UVLC_FORMAT_VGA;
32 picture_layer->format = format;
33 picture_layer->resolution = resolution;
35 video_write_data( stream, picture_layer->format, 2 );
36 video_write_data( stream, picture_layer->resolution, 3 );
37 video_write_data( stream, picture_layer->picture_type, 3 );
38 video_write_data( stream, picture_layer->quant, 6 );
39 video_write_data( stream, controller->num_frames, 32 );
44 C_RESULT p264_read_picture_layer( video_controller_t* controller, video_stream_t* stream )
46 uint32_t width, height;
48 p264_codec_t* p264_codec = (p264_codec_t*) controller->video_codec;
49 p264_picture_layer_t* picture_layer = &p264_codec->picture_layer;
51 picture_layer->format = 0;
52 picture_layer->resolution = 0;
53 picture_layer->picture_type = 0;
54 picture_layer->quant = 0;
56 video_read_data( stream, &picture_layer->format, 2 );
57 video_read_data( stream, &picture_layer->resolution, 3 );
58 video_read_data( stream, &picture_layer->picture_type, 3 );
59 video_read_data( stream, &picture_layer->quant, 6 );
60 video_read_data( stream, &controller->num_frames, 32 );
62 switch( picture_layer->format )
65 width = QQCIF_WIDTH << (picture_layer->resolution-1);
66 height = QQCIF_HEIGHT << (picture_layer->resolution-1);
70 width = QQVGA_WIDTH << (picture_layer->resolution-1);
71 height = QQVGA_HEIGHT << (picture_layer->resolution-1);
80 video_controller_set_format( controller, width, height );