comparison libtheoraenc.c @ 10444:f1ef8d3221c8 libavcodec

Get rid of some pointless '== NULL' / '!= 0' conditions in if statements.
author diego
date Mon, 19 Oct 2009 22:26:52 +0000
parents b4b55a3d65c9
children 86c7e3c6de00
comparison
equal deleted inserted replaced
10443:8cf141fae2f3 10444:f1ef8d3221c8
59 message = "ogg_packet is larger than 65535 bytes"; 59 message = "ogg_packet is larger than 65535 bytes";
60 } else if (newsize < avc_context->extradata_size) { 60 } else if (newsize < avc_context->extradata_size) {
61 message = "extradata_size would overflow"; 61 message = "extradata_size would overflow";
62 } else { 62 } else {
63 newdata = av_realloc(avc_context->extradata, newsize); 63 newdata = av_realloc(avc_context->extradata, newsize);
64 if (newdata == NULL) 64 if (!newdata)
65 message = "av_realloc failed"; 65 message = "av_realloc failed";
66 } 66 }
67 if (message != NULL) { 67 if (message) {
68 av_log(avc_context, AV_LOG_ERROR, "concatenate_packet failed: %s\n", message); 68 av_log(avc_context, AV_LOG_ERROR, "concatenate_packet failed: %s\n", message);
69 return -1; 69 return -1;
70 } 70 }
71 71
72 avc_context->extradata = newdata; 72 avc_context->extradata = newdata;
96 t_info.offset_y = avc_context->height & 0xf; 96 t_info.offset_y = avc_context->height & 0xf;
97 /* Swap numerator and denominator as time_base in AVCodecContext gives the 97 /* Swap numerator and denominator as time_base in AVCodecContext gives the
98 * time period between frames, but theora_info needs the framerate. */ 98 * time period between frames, but theora_info needs the framerate. */
99 t_info.fps_numerator = avc_context->time_base.den; 99 t_info.fps_numerator = avc_context->time_base.den;
100 t_info.fps_denominator = avc_context->time_base.num; 100 t_info.fps_denominator = avc_context->time_base.num;
101 if (avc_context->sample_aspect_ratio.num != 0) { 101 if (avc_context->sample_aspect_ratio.num) {
102 t_info.aspect_numerator = avc_context->sample_aspect_ratio.num; 102 t_info.aspect_numerator = avc_context->sample_aspect_ratio.num;
103 t_info.aspect_denominator = avc_context->sample_aspect_ratio.den; 103 t_info.aspect_denominator = avc_context->sample_aspect_ratio.den;
104 } else { 104 } else {
105 t_info.aspect_numerator = 1; 105 t_info.aspect_numerator = 1;
106 t_info.aspect_denominator = 1; 106 t_info.aspect_denominator = 1;
131 t_info.target_bitrate = avc_context->bit_rate; 131 t_info.target_bitrate = avc_context->bit_rate;
132 t_info.quality = 0; 132 t_info.quality = 0;
133 } 133 }
134 134
135 /* Now initialise libtheora */ 135 /* Now initialise libtheora */
136 if (theora_encode_init(&(h->t_state), &t_info) != 0) { 136 if (theora_encode_init(&(h->t_state), &t_info)) {
137 av_log(avc_context, AV_LOG_ERROR, "theora_encode_init failed\n"); 137 av_log(avc_context, AV_LOG_ERROR, "theora_encode_init failed\n");
138 return -1; 138 return -1;
139 } 139 }
140 140
141 /* Clear up theora_info struct */ 141 /* Clear up theora_info struct */
150 */ 150 */
151 offset = 0; 151 offset = 0;
152 152
153 /* Header */ 153 /* Header */
154 theora_encode_header(&(h->t_state), &o_packet); 154 theora_encode_header(&(h->t_state), &o_packet);
155 if (concatenate_packet(&offset, avc_context, &o_packet) != 0) 155 if (concatenate_packet(&offset, avc_context, &o_packet))
156 return -1; 156 return -1;
157 157
158 /* Comment */ 158 /* Comment */
159 theora_comment_init(&t_comment); 159 theora_comment_init(&t_comment);
160 theora_encode_comment(&t_comment, &o_packet); 160 theora_encode_comment(&t_comment, &o_packet);
161 if (concatenate_packet(&offset, avc_context, &o_packet) != 0) 161 if (concatenate_packet(&offset, avc_context, &o_packet))
162 return -1; 162 return -1;
163 /* Clear up theora_comment struct before we reset the packet */ 163 /* Clear up theora_comment struct before we reset the packet */
164 theora_comment_clear(&t_comment); 164 theora_comment_clear(&t_comment);
165 /* And despite documentation to the contrary, theora_comment_clear 165 /* And despite documentation to the contrary, theora_comment_clear
166 * does not release the packet */ 166 * does not release the packet */
167 ogg_packet_clear(&o_packet); 167 ogg_packet_clear(&o_packet);
168 168
169 /* Tables */ 169 /* Tables */
170 theora_encode_tables(&(h->t_state), &o_packet); 170 theora_encode_tables(&(h->t_state), &o_packet);
171 if (concatenate_packet(&offset, avc_context, &o_packet) != 0) 171 if (concatenate_packet(&offset, avc_context, &o_packet))
172 return -1; 172 return -1;
173 173
174 /* Set up the output AVFrame */ 174 /* Set up the output AVFrame */
175 avc_context->coded_frame= avcodec_alloc_frame(); 175 avc_context->coded_frame= avcodec_alloc_frame();
176 176
205 t_yuv_buffer.u = frame->data[1]; 205 t_yuv_buffer.u = frame->data[1];
206 t_yuv_buffer.v = frame->data[2]; 206 t_yuv_buffer.v = frame->data[2];
207 207
208 /* Now call into theora_encode_YUVin */ 208 /* Now call into theora_encode_YUVin */
209 result = theora_encode_YUVin(&(h->t_state), &t_yuv_buffer); 209 result = theora_encode_YUVin(&(h->t_state), &t_yuv_buffer);
210 if (result != 0) { 210 if (result) {
211 const char* message; 211 const char* message;
212 switch (result) { 212 switch (result) {
213 case -1: 213 case -1:
214 message = "differing frame sizes"; 214 message = "differing frame sizes";
215 break; 215 break;