comparison h263.c @ 766:8d36b35a7e6e libavcodec

slice encoding cleanup
author michaelni
date Fri, 25 Oct 2002 00:08:32 +0000
parents 7f4cc2f6d642
children d1770a34e4f6
comparison
equal deleted inserted replaced
765:7f0d502a42c5 766:8d36b35a7e6e
220 s->y_dc_scale_table= 220 s->y_dc_scale_table=
221 s->c_dc_scale_table= ff_mpeg1_dc_scale_table; 221 s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
222 } 222 }
223 } 223 }
224 224
225 /**
226 * Encodes a group of blocks header.
227 */
225 int h263_encode_gob_header(MpegEncContext * s, int mb_line) 228 int h263_encode_gob_header(MpegEncContext * s, int mb_line)
226 { 229 {
227 int pdif=0;
228
229 /* Check to see if we need to put a new GBSC */
230 /* for RTP packetization */
231 if (s->rtp_mode) {
232 pdif = pbBufPtr(&s->pb) - s->ptr_lastgob;
233 if (pdif >= s->rtp_payload_size) {
234 /* Bad luck, packet must be cut before */
235 align_put_bits(&s->pb);
236 flush_put_bits(&s->pb);
237 /* Call the RTP callback to send the last GOB */
238 if (s->rtp_callback) {
239 pdif = pbBufPtr(&s->pb) - s->ptr_lastgob;
240 s->rtp_callback(s->ptr_lastgob, pdif, s->gob_number);
241 }
242 s->ptr_lastgob = pbBufPtr(&s->pb);
243 put_bits(&s->pb, 17, 1); /* GBSC */
244 s->gob_number = mb_line / s->gob_index;
245 put_bits(&s->pb, 5, s->gob_number); /* GN */
246 put_bits(&s->pb, 2, s->pict_type == I_TYPE); /* GFID */
247 put_bits(&s->pb, 5, s->qscale); /* GQUANT */
248 //fprintf(stderr,"\nGOB: %2d size: %d", s->gob_number - 1, pdif);
249 return pdif;
250 } else if (pdif + s->mb_line_avgsize >= s->rtp_payload_size) {
251 /* Cut the packet before we can't */
252 align_put_bits(&s->pb); 230 align_put_bits(&s->pb);
253 flush_put_bits(&s->pb); 231 flush_put_bits(&s->pb);
254 /* Call the RTP callback to send the last GOB */ 232 /* Call the RTP callback to send the last GOB */
255 if (s->rtp_callback) { 233 if (s->rtp_callback) {
256 pdif = pbBufPtr(&s->pb) - s->ptr_lastgob; 234 int pdif = pbBufPtr(&s->pb) - s->ptr_lastgob;
257 s->rtp_callback(s->ptr_lastgob, pdif, s->gob_number); 235 s->rtp_callback(s->ptr_lastgob, pdif, s->gob_number);
258 } 236 }
259 s->ptr_lastgob = pbBufPtr(&s->pb);
260 put_bits(&s->pb, 17, 1); /* GBSC */ 237 put_bits(&s->pb, 17, 1); /* GBSC */
261 s->gob_number = mb_line / s->gob_index; 238 s->gob_number = mb_line / s->gob_index;
262 put_bits(&s->pb, 5, s->gob_number); /* GN */ 239 put_bits(&s->pb, 5, s->gob_number); /* GN */
263 put_bits(&s->pb, 2, s->pict_type == I_TYPE); /* GFID */ 240 put_bits(&s->pb, 2, s->pict_type == I_TYPE); /* GFID */
264 put_bits(&s->pb, 5, s->qscale); /* GQUANT */ 241 put_bits(&s->pb, 5, s->qscale); /* GQUANT */
265 //fprintf(stderr,"\nGOB: %2d size: %d", s->gob_number - 1, pdif); 242 //fprintf(stderr,"\nGOB: %2d size: %d", s->gob_number - 1, pdif);
266 return pdif; 243 return 0;
267 }
268 }
269 return 0;
270 } 244 }
271 245
272 static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], int dir[6]) 246 static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], int dir[6])
273 { 247 {
274 int score0=0, score1=0; 248 int score0=0, score1=0;