1 /*
2 libfame - Fast Assembly MPEG Encoder Library
3 Copyright (C) 2000-2001 Vivien Chappelier
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with this library; if not, write to the Free
17 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include <string.h>
23
24 #include "fame.h"
25 #include "fame_profile.h"
26 #include "fame_profile_mpeg4_shape.h"
27 #include "fame_encoder.h"
28 #include "fame_decoder.h"
29 #include "fame_motion.h"
30 #include "fame_syntax.h"
31 #include "fame_shape.h"
32
33 static void profile_mpeg4_shape_init(fame_profile_t *profile,
34 fame_context_t *context,
35 fame_parameters_t *params,
36 unsigned char *buffer,
37 unsigned int size);
38
FAME_CONSTRUCTOR(fame_profile_mpeg4_shape_t)39 FAME_CONSTRUCTOR(fame_profile_mpeg4_shape_t)
40 {
41 fame_profile_mpeg_t_constructor(FAME_PROFILE_MPEG(this));
42 FAME_OBJECT(this)->name = "MPEG-4 shape profile";
43 this->FAME_OVERLOADED(init) = FAME_PROFILE(this)->init;
44 FAME_PROFILE(this)->init = profile_mpeg4_shape_init;
45 return(this);
46 }
47
48 /* profile_mpeg4_shape_init */
49 /* */
50 /* Description: */
51 /* Initialize the profile. */
52 /* */
53 /* Arguments: */
54 /* fame_profile_t *profile: the profile to initialize */
55 /* fame_parameters_t *params: the parameters for initialization */
56 /* unsigned char *buffer: the buffer to output data */
57 /* unsigned int size: the size of the output buffer */
58 /* */
59 /* Return value: */
60 /* None. */
61
profile_mpeg4_shape_init(fame_profile_t * profile,fame_context_t * context,fame_parameters_t * params,unsigned char * buffer,unsigned int size)62 static void profile_mpeg4_shape_init(fame_profile_t *profile,
63 fame_context_t *context,
64 fame_parameters_t *params,
65 unsigned char *buffer,
66 unsigned int size)
67 {
68 fame_profile_mpeg_t *profile_mpeg = FAME_PROFILE_MPEG(profile);
69
70 fame_register(context, "encoder", fame_get_object(context, "encoder/mpeg"));
71 fame_register(context, "decoder", fame_get_object(context, "decoder/mpeg"));
72 fame_register(context, "motion", fame_get_object(context, "motion"));
73 fame_register(context, "syntax", fame_get_object(context, "syntax/mpeg4"));
74 fame_register(context, "shape", fame_get_object(context, "shape"));
75 FAME_PROFILE_MPEG(profile)->motion_flags =
76 FAME_MOTION_SUBPEL_SEARCH |
77 FAME_MOTION_UNRESTRICTED_SEARCH |
78 FAME_MOTION_BLOCK_SEARCH |
79 FAME_MOTION_FLIP_ROUNDING;
80
81 FAME_PROFILE_MPEG(profile)->shape_flags =
82 (params->shape_quality == 100) ? FAME_SHAPE_LOSSLESS : 0;
83 FAME_PROFILE_MPEG(profile)->syntax_flags =
84 FAME_SYNTAX_ARBITRARY_SHAPE |
85 ((params->shape_quality == 100) ? FAME_SYNTAX_LOSSLESS_SHAPE : 0);
86
87 FAME_PROFILE_MPEG4_SHAPE(profile)->FAME_OVERLOADED(init)(profile, context, params, buffer, size);
88
89 if(profile_mpeg->decoder == NULL)
90 FAME_ERROR("Could not find decoder object");
91 if(profile_mpeg->encoder == NULL)
92 FAME_ERROR("Could not find encoder object");
93 if(profile_mpeg->motion == NULL)
94 FAME_ERROR("Could not find motion object");
95 if(profile_mpeg->syntax == NULL)
96 FAME_ERROR("Could not find syntax object");
97 if(profile_mpeg->shape == NULL)
98 FAME_ERROR("Could not find shape object");
99 }
100