286 */ |
304 */ |
287 #define GST_CALL_PARENT_WITH_DEFAULT(parent_class_cast, name, args, def_return)\ |
305 #define GST_CALL_PARENT_WITH_DEFAULT(parent_class_cast, name, args, def_return)\ |
288 ((parent_class_cast(parent_class)->name != NULL) ? \ |
306 ((parent_class_cast(parent_class)->name != NULL) ? \ |
289 parent_class_cast(parent_class)->name args : def_return) |
307 parent_class_cast(parent_class)->name args : def_return) |
290 |
308 |
291 /* Define possibly unaligned memory access method whether the type of |
309 /* Define PUT and GET functions for unaligned memory */ |
292 * architecture. */ |
310 #define _GST_GET(__data, __idx, __size, __shift) \ |
293 #if GST_HAVE_UNALIGNED_ACCESS |
311 (((guint##__size) (((guint8 *) (__data))[__idx])) << (__shift)) |
294 |
312 |
295 #define _GST_GET(__data, __size, __end) \ |
313 #define _GST_PUT(__data, __idx, __size, __shift, __num) \ |
296 (GUINT##__size##_FROM_##__end (* ((guint##__size *) (__data)))) |
314 (((guint8 *) (__data))[__idx] = (((guint##__size) (__num)) >> (__shift)) & 0xff) |
297 |
315 |
298 /** |
316 /** |
299 * GST_READ_UINT64_BE: |
317 * GST_READ_UINT64_BE: |
300 * @data: memory location |
318 * @data: memory location |
301 * |
319 * |
302 * Read a 64 bit unsigned integer value in big endian format from the memory buffer. |
320 * Read a 64 bit unsigned integer value in big endian format from the memory buffer. |
303 */ |
321 */ |
304 #define GST_READ_UINT64_BE(data) _GST_GET (data, 64, BE) |
|
305 /** |
|
306 * GST_READ_UINT64_LE: |
|
307 * @data: memory location |
|
308 * |
|
309 * Read a 64 bit unsigned integer value in little endian format from the memory buffer. |
|
310 */ |
|
311 #define GST_READ_UINT64_LE(data) _GST_GET (data, 64, LE) |
|
312 /** |
|
313 * GST_READ_UINT32_BE: |
|
314 * @data: memory location |
|
315 * |
|
316 * Read a 32 bit unsigned integer value in big endian format from the memory buffer. |
|
317 */ |
|
318 #define GST_READ_UINT32_BE(data) _GST_GET (data, 32, BE) |
|
319 /** |
|
320 * GST_READ_UINT32_LE: |
|
321 * @data: memory location |
|
322 * |
|
323 * Read a 32 bit unsigned integer value in little endian format from the memory buffer. |
|
324 */ |
|
325 #define GST_READ_UINT32_LE(data) _GST_GET (data, 32, LE) |
|
326 /** |
|
327 * GST_READ_UINT16_BE: |
|
328 * @data: memory location |
|
329 * |
|
330 * Read a 16 bit unsigned integer value in big endian format from the memory buffer. |
|
331 */ |
|
332 #define GST_READ_UINT16_BE(data) _GST_GET (data, 16, BE) |
|
333 /** |
|
334 * GST_READ_UINT16_LE: |
|
335 * @data: memory location |
|
336 * |
|
337 * Read a 16 bit unsigned integer value in little endian format from the memory buffer. |
|
338 */ |
|
339 #define GST_READ_UINT16_LE(data) _GST_GET (data, 16, LE) |
|
340 /** |
|
341 * GST_READ_UINT8: |
|
342 * @data: memory location |
|
343 * |
|
344 * Read an 8 bit unsigned integer value from the memory buffer. |
|
345 */ |
|
346 #define GST_READ_UINT8(data) (* ((guint8 *) (data))) |
|
347 |
|
348 #define _GST_PUT(__data, __size, __end, __num) \ |
|
349 ((* (guint##__size *) (__data)) = GUINT##__size##_TO_##__end (__num)) |
|
350 |
|
351 /** |
|
352 * GST_WRITE_UINT64_BE: |
|
353 * @data: memory location |
|
354 * @num: value to store |
|
355 * |
|
356 * Store a 64 bit unsigned integer value in big endian format into the memory buffer. |
|
357 */ |
|
358 #define GST_WRITE_UINT64_BE(data, num) _GST_PUT(data, 64, BE, num) |
|
359 /** |
|
360 * GST_WRITE_UINT64_LE: |
|
361 * @data: memory location |
|
362 * @num: value to store |
|
363 * |
|
364 * Store a 64 bit unsigned integer value in little endian format into the memory buffer. |
|
365 */ |
|
366 #define GST_WRITE_UINT64_LE(data, num) _GST_PUT(data, 64, LE, num) |
|
367 /** |
|
368 * GST_WRITE_UINT32_BE: |
|
369 * @data: memory location |
|
370 * @num: value to store |
|
371 * |
|
372 * Store a 32 bit unsigned integer value in big endian format into the memory buffer. |
|
373 */ |
|
374 #define GST_WRITE_UINT32_BE(data, num) _GST_PUT(data, 32, BE, num) |
|
375 /** |
|
376 * GST_WRITE_UINT32_LE: |
|
377 * @data: memory location |
|
378 * @num: value to store |
|
379 * |
|
380 * Store a 32 bit unsigned integer value in little endian format into the memory buffer. |
|
381 */ |
|
382 #define GST_WRITE_UINT32_LE(data, num) _GST_PUT(data, 32, LE, num) |
|
383 /** |
|
384 * GST_WRITE_UINT16_BE: |
|
385 * @data: memory location |
|
386 * @num: value to store |
|
387 * |
|
388 * Store a 16 bit unsigned integer value in big endian format into the memory buffer. |
|
389 */ |
|
390 #define GST_WRITE_UINT16_BE(data, num) _GST_PUT(data, 16, BE, num) |
|
391 /** |
|
392 * GST_WRITE_UINT16_LE: |
|
393 * @data: memory location |
|
394 * @num: value to store |
|
395 * |
|
396 * Store a 16 bit unsigned integer value in little endian format into the memory buffer. |
|
397 */ |
|
398 #define GST_WRITE_UINT16_LE(data, num) _GST_PUT(data, 16, LE, num) |
|
399 /** |
|
400 * GST_WRITE_UINT8: |
|
401 * @data: memory location |
|
402 * @num: value to store |
|
403 * |
|
404 * Store an 8 bit unsigned integer value into the memory buffer. |
|
405 */ |
|
406 #define GST_WRITE_UINT8(data, num) ((* (guint8 *) (data)) = (num)) |
|
407 |
|
408 #else /* GST_HAVE_UNALIGNED_ACCESS */ |
|
409 |
|
410 #define _GST_GET(__data, __idx, __size, __shift) \ |
|
411 (((guint##__size) (((guint8 *) (__data))[__idx])) << __shift) |
|
412 |
|
413 #define GST_READ_UINT64_BE(data) (_GST_GET (data, 0, 64, 56) | \ |
322 #define GST_READ_UINT64_BE(data) (_GST_GET (data, 0, 64, 56) | \ |
414 _GST_GET (data, 1, 64, 48) | \ |
323 _GST_GET (data, 1, 64, 48) | \ |
415 _GST_GET (data, 2, 64, 40) | \ |
324 _GST_GET (data, 2, 64, 40) | \ |
416 _GST_GET (data, 3, 64, 32) | \ |
325 _GST_GET (data, 3, 64, 32) | \ |
417 _GST_GET (data, 4, 64, 24) | \ |
326 _GST_GET (data, 4, 64, 24) | \ |
418 _GST_GET (data, 5, 64, 16) | \ |
327 _GST_GET (data, 5, 64, 16) | \ |
419 _GST_GET (data, 6, 64, 8) | \ |
328 _GST_GET (data, 6, 64, 8) | \ |
420 _GST_GET (data, 7, 64, 0)) |
329 _GST_GET (data, 7, 64, 0)) |
421 |
330 |
|
331 /** |
|
332 * GST_READ_UINT64_LE: |
|
333 * @data: memory location |
|
334 * |
|
335 * Read a 64 bit unsigned integer value in little endian format from the memory buffer. |
|
336 */ |
422 #define GST_READ_UINT64_LE(data) (_GST_GET (data, 7, 64, 56) | \ |
337 #define GST_READ_UINT64_LE(data) (_GST_GET (data, 7, 64, 56) | \ |
423 _GST_GET (data, 6, 64, 48) | \ |
338 _GST_GET (data, 6, 64, 48) | \ |
424 _GST_GET (data, 5, 64, 40) | \ |
339 _GST_GET (data, 5, 64, 40) | \ |
425 _GST_GET (data, 4, 64, 32) | \ |
340 _GST_GET (data, 4, 64, 32) | \ |
426 _GST_GET (data, 3, 64, 24) | \ |
341 _GST_GET (data, 3, 64, 24) | \ |
427 _GST_GET (data, 2, 64, 16) | \ |
342 _GST_GET (data, 2, 64, 16) | \ |
428 _GST_GET (data, 1, 64, 8) | \ |
343 _GST_GET (data, 1, 64, 8) | \ |
429 _GST_GET (data, 0, 64, 0)) |
344 _GST_GET (data, 0, 64, 0)) |
430 |
345 |
|
346 /** |
|
347 * GST_READ_UINT32_BE: |
|
348 * @data: memory location |
|
349 * |
|
350 * Read a 32 bit unsigned integer value in big endian format from the memory buffer. |
|
351 */ |
431 #define GST_READ_UINT32_BE(data) (_GST_GET (data, 0, 32, 24) | \ |
352 #define GST_READ_UINT32_BE(data) (_GST_GET (data, 0, 32, 24) | \ |
432 _GST_GET (data, 1, 32, 16) | \ |
353 _GST_GET (data, 1, 32, 16) | \ |
433 _GST_GET (data, 2, 32, 8) | \ |
354 _GST_GET (data, 2, 32, 8) | \ |
434 _GST_GET (data, 3, 32, 0)) |
355 _GST_GET (data, 3, 32, 0)) |
435 |
356 |
|
357 /** |
|
358 * GST_READ_UINT32_LE: |
|
359 * @data: memory location |
|
360 * |
|
361 * Read a 32 bit unsigned integer value in little endian format from the memory buffer. |
|
362 */ |
436 #define GST_READ_UINT32_LE(data) (_GST_GET (data, 3, 32, 24) | \ |
363 #define GST_READ_UINT32_LE(data) (_GST_GET (data, 3, 32, 24) | \ |
437 _GST_GET (data, 2, 32, 16) | \ |
364 _GST_GET (data, 2, 32, 16) | \ |
438 _GST_GET (data, 1, 32, 8) | \ |
365 _GST_GET (data, 1, 32, 8) | \ |
439 _GST_GET (data, 0, 32, 0)) |
366 _GST_GET (data, 0, 32, 0)) |
440 |
367 |
|
368 /** |
|
369 * GST_READ_UINT24_BE: |
|
370 * @data: memory location |
|
371 * |
|
372 * Read a 24 bit unsigned integer value in big endian format from the memory buffer. |
|
373 * |
|
374 * Since: 0.10.22 |
|
375 */ |
|
376 #define GST_READ_UINT24_BE(data) (_GST_GET (data, 0, 32, 16) | \ |
|
377 _GST_GET (data, 1, 32, 8) | \ |
|
378 _GST_GET (data, 2, 32, 0)) |
|
379 |
|
380 /** |
|
381 * GST_READ_UINT24_LE: |
|
382 * @data: memory location |
|
383 * |
|
384 * Read a 24 bit unsigned integer value in little endian format from the memory buffer. |
|
385 * |
|
386 * Since: 0.10.22 |
|
387 */ |
|
388 #define GST_READ_UINT24_LE(data) (_GST_GET (data, 2, 32, 16) | \ |
|
389 _GST_GET (data, 1, 32, 8) | \ |
|
390 _GST_GET (data, 0, 32, 0)) |
|
391 |
|
392 /** |
|
393 * GST_READ_UINT16_BE: |
|
394 * @data: memory location |
|
395 * |
|
396 * Read a 16 bit unsigned integer value in big endian format from the memory buffer. |
|
397 */ |
441 #define GST_READ_UINT16_BE(data) (_GST_GET (data, 0, 16, 8) | \ |
398 #define GST_READ_UINT16_BE(data) (_GST_GET (data, 0, 16, 8) | \ |
442 _GST_GET (data, 1, 16, 0)) |
399 _GST_GET (data, 1, 16, 0)) |
443 |
400 |
|
401 /** |
|
402 * GST_READ_UINT16_LE: |
|
403 * @data: memory location |
|
404 * |
|
405 * Read a 16 bit unsigned integer value in little endian format from the memory buffer. |
|
406 */ |
444 #define GST_READ_UINT16_LE(data) (_GST_GET (data, 1, 16, 8) | \ |
407 #define GST_READ_UINT16_LE(data) (_GST_GET (data, 1, 16, 8) | \ |
445 _GST_GET (data, 0, 16, 0)) |
408 _GST_GET (data, 0, 16, 0)) |
446 |
409 |
|
410 /** |
|
411 * GST_READ_UINT8: |
|
412 * @data: memory location |
|
413 * |
|
414 * Read an 8 bit unsigned integer value from the memory buffer. |
|
415 */ |
447 #define GST_READ_UINT8(data) (_GST_GET (data, 0, 8, 0)) |
416 #define GST_READ_UINT8(data) (_GST_GET (data, 0, 8, 0)) |
448 |
417 |
449 #define _GST_PUT(__data, __idx, __size, __shift, __num) \ |
418 /** |
450 (((guint8 *) (__data))[__idx] = (((guint##__size) __num) >> __shift) & 0xff) |
419 * GST_WRITE_UINT64_BE: |
451 |
420 * @data: memory location |
|
421 * @num: value to store |
|
422 * |
|
423 * Store a 64 bit unsigned integer value in big endian format into the memory buffer. |
|
424 */ |
452 #define GST_WRITE_UINT64_BE(data, num) do { \ |
425 #define GST_WRITE_UINT64_BE(data, num) do { \ |
453 _GST_PUT (data, 0, 64, 56, num); \ |
426 _GST_PUT (data, 0, 64, 56, num); \ |
454 _GST_PUT (data, 1, 64, 48, num); \ |
427 _GST_PUT (data, 1, 64, 48, num); \ |
455 _GST_PUT (data, 2, 64, 40, num); \ |
428 _GST_PUT (data, 2, 64, 40, num); \ |
456 _GST_PUT (data, 3, 64, 32, num); \ |
429 _GST_PUT (data, 3, 64, 32, num); \ |
469 _GST_PUT (data, 5, 64, 40, num); \ |
449 _GST_PUT (data, 5, 64, 40, num); \ |
470 _GST_PUT (data, 6, 64, 48, num); \ |
450 _GST_PUT (data, 6, 64, 48, num); \ |
471 _GST_PUT (data, 7, 64, 56, num); \ |
451 _GST_PUT (data, 7, 64, 56, num); \ |
472 } while (0) |
452 } while (0) |
473 |
453 |
|
454 /** |
|
455 * GST_WRITE_UINT32_BE: |
|
456 * @data: memory location |
|
457 * @num: value to store |
|
458 * |
|
459 * Store a 32 bit unsigned integer value in big endian format into the memory buffer. |
|
460 */ |
474 #define GST_WRITE_UINT32_BE(data, num) do { \ |
461 #define GST_WRITE_UINT32_BE(data, num) do { \ |
475 _GST_PUT (data, 0, 32, 24, num); \ |
462 _GST_PUT (data, 0, 32, 24, num); \ |
476 _GST_PUT (data, 1, 32, 16, num); \ |
463 _GST_PUT (data, 1, 32, 16, num); \ |
477 _GST_PUT (data, 2, 32, 8, num); \ |
464 _GST_PUT (data, 2, 32, 8, num); \ |
478 _GST_PUT (data, 3, 32, 0, num); \ |
465 _GST_PUT (data, 3, 32, 0, num); \ |
479 } while (0) |
466 } while (0) |
480 |
467 |
|
468 /** |
|
469 * GST_WRITE_UINT32_LE: |
|
470 * @data: memory location |
|
471 * @num: value to store |
|
472 * |
|
473 * Store a 32 bit unsigned integer value in little endian format into the memory buffer. |
|
474 */ |
481 #define GST_WRITE_UINT32_LE(data, num) do { \ |
475 #define GST_WRITE_UINT32_LE(data, num) do { \ |
482 _GST_PUT (data, 0, 32, 0, num); \ |
476 _GST_PUT (data, 0, 32, 0, num); \ |
483 _GST_PUT (data, 1, 32, 8, num); \ |
477 _GST_PUT (data, 1, 32, 8, num); \ |
484 _GST_PUT (data, 2, 32, 16, num); \ |
478 _GST_PUT (data, 2, 32, 16, num); \ |
485 _GST_PUT (data, 3, 32, 24, num); \ |
479 _GST_PUT (data, 3, 32, 24, num); \ |
486 } while (0) |
480 } while (0) |
487 |
481 |
|
482 /** |
|
483 * GST_WRITE_UINT24_BE: |
|
484 * @data: memory location |
|
485 * @num: value to store |
|
486 * |
|
487 * Store a 24 bit unsigned integer value in big endian format into the memory buffer. |
|
488 * |
|
489 * Since: 0.10.22 |
|
490 */ |
|
491 #define GST_WRITE_UINT24_BE(data, num) do { \ |
|
492 _GST_PUT (data, 0, 32, 16, num); \ |
|
493 _GST_PUT (data, 1, 32, 8, num); \ |
|
494 _GST_PUT (data, 2, 32, 0, num); \ |
|
495 } while (0) |
|
496 |
|
497 /** |
|
498 * GST_WRITE_UINT24_LE: |
|
499 * @data: memory location |
|
500 * @num: value to store |
|
501 * |
|
502 * Store a 24 bit unsigned integer value in little endian format into the memory buffer. |
|
503 * |
|
504 * Since: 0.10.22 |
|
505 */ |
|
506 #define GST_WRITE_UINT24_LE(data, num) do { \ |
|
507 _GST_PUT (data, 0, 32, 0, num); \ |
|
508 _GST_PUT (data, 1, 32, 8, num); \ |
|
509 _GST_PUT (data, 2, 32, 16, num); \ |
|
510 } while (0) |
|
511 |
|
512 /** |
|
513 * GST_WRITE_UINT16_BE: |
|
514 * @data: memory location |
|
515 * @num: value to store |
|
516 * |
|
517 * Store a 16 bit unsigned integer value in big endian format into the memory buffer. |
|
518 */ |
488 #define GST_WRITE_UINT16_BE(data, num) do { \ |
519 #define GST_WRITE_UINT16_BE(data, num) do { \ |
489 _GST_PUT (data, 0, 16, 8, num); \ |
520 _GST_PUT (data, 0, 16, 8, num); \ |
490 _GST_PUT (data, 1, 16, 0, num); \ |
521 _GST_PUT (data, 1, 16, 0, num); \ |
491 } while (0) |
522 } while (0) |
492 |
523 |
|
524 /** |
|
525 * GST_WRITE_UINT16_LE: |
|
526 * @data: memory location |
|
527 * @num: value to store |
|
528 * |
|
529 * Store a 16 bit unsigned integer value in little endian format into the memory buffer. |
|
530 */ |
493 #define GST_WRITE_UINT16_LE(data, num) do { \ |
531 #define GST_WRITE_UINT16_LE(data, num) do { \ |
494 _GST_PUT (data, 0, 16, 0, num); \ |
532 _GST_PUT (data, 0, 16, 0, num); \ |
495 _GST_PUT (data, 1, 16, 8, num); \ |
533 _GST_PUT (data, 1, 16, 8, num); \ |
496 } while (0) |
534 } while (0) |
497 |
535 |
|
536 /** |
|
537 * GST_WRITE_UINT8: |
|
538 * @data: memory location |
|
539 * @num: value to store |
|
540 * |
|
541 * Store an 8 bit unsigned integer value into the memory buffer. |
|
542 */ |
498 #define GST_WRITE_UINT8(data, num) do { \ |
543 #define GST_WRITE_UINT8(data, num) do { \ |
499 _GST_PUT (data, 0, 8, 0, num); \ |
544 _GST_PUT (data, 0, 8, 0, num); \ |
500 } while (0) |
545 } while (0) |
501 |
546 |
502 #endif /* GST_HAVE_UNALIGNED_ACCESS */ |
547 /* Float endianess conversion macros */ |
503 |
548 |
|
549 /* FIXME: Remove this once we depend on a GLib version with this */ |
|
550 #ifndef GFLOAT_FROM_LE |
|
551 /** |
|
552 * GFLOAT_SWAP_LE_BE: |
|
553 * @in: input value |
|
554 * |
|
555 * Swap byte order of a 32-bit floating point value (float). |
|
556 * |
|
557 * Returns: @in byte-swapped. |
|
558 * |
|
559 * Since: 0.10.22 |
|
560 * |
|
561 */ |
|
562 #ifdef _FOOL_GTK_DOC_ |
|
563 G_INLINE_FUNC gfloat GFLOAT_SWAP_LE_BE (gfloat in); |
|
564 #endif |
|
565 |
|
566 inline static gfloat |
|
567 GFLOAT_SWAP_LE_BE(gfloat in) |
|
568 { |
|
569 union |
|
570 { |
|
571 guint32 i; |
|
572 gfloat f; |
|
573 } u; |
|
574 |
|
575 u.f = in; |
|
576 u.i = GUINT32_SWAP_LE_BE (u.i); |
|
577 return u.f; |
|
578 } |
|
579 |
|
580 /** |
|
581 * GDOUBLE_SWAP_LE_BE: |
|
582 * @in: input value |
|
583 * |
|
584 * Swap byte order of a 64-bit floating point value (double). |
|
585 * |
|
586 * Returns: @in byte-swapped. |
|
587 * |
|
588 * Since: 0.10.22 |
|
589 * |
|
590 */ |
|
591 #ifdef _FOOL_GTK_DOC_ |
|
592 G_INLINE_FUNC gdouble GDOUBLE_SWAP_LE_BE (gdouble in); |
|
593 #endif |
|
594 |
|
595 inline static gdouble |
|
596 GDOUBLE_SWAP_LE_BE(gdouble in) |
|
597 { |
|
598 union |
|
599 { |
|
600 guint64 i; |
|
601 gdouble d; |
|
602 } u; |
|
603 |
|
604 u.d = in; |
|
605 u.i = GUINT64_SWAP_LE_BE (u.i); |
|
606 return u.d; |
|
607 } |
|
608 |
|
609 /** |
|
610 * GDOUBLE_TO_LE: |
|
611 * @val: value |
|
612 * |
|
613 * Convert 64-bit floating point value (double) from native byte order into |
|
614 * little endian byte order. |
|
615 * |
|
616 * Since: 0.10.22 |
|
617 * |
|
618 */ |
|
619 /** |
|
620 * GDOUBLE_TO_BE: |
|
621 * @val: value |
|
622 * |
|
623 * Convert 64-bit floating point value (double) from native byte order into |
|
624 * big endian byte order. |
|
625 * |
|
626 * Since: 0.10.22 |
|
627 * |
|
628 */ |
|
629 /** |
|
630 * GDOUBLE_FROM_LE: |
|
631 * @val: value |
|
632 * |
|
633 * Convert 64-bit floating point value (double) from little endian byte order |
|
634 * into native byte order. |
|
635 * |
|
636 * Since: 0.10.22 |
|
637 * |
|
638 */ |
|
639 /** |
|
640 * GDOUBLE_FROM_BE: |
|
641 * @val: value |
|
642 * |
|
643 * Convert 64-bit floating point value (double) from big endian byte order |
|
644 * into native byte order. |
|
645 * |
|
646 * Since: 0.10.22 |
|
647 * |
|
648 */ |
|
649 |
|
650 /** |
|
651 * GFLOAT_TO_LE: |
|
652 * @val: value |
|
653 * |
|
654 * Convert 32-bit floating point value (float) from native byte order into |
|
655 * little endian byte order. |
|
656 * |
|
657 * Since: 0.10.22 |
|
658 * |
|
659 */ |
|
660 /** |
|
661 * GFLOAT_TO_BE: |
|
662 * @val: value |
|
663 * |
|
664 * Convert 32-bit floating point value (float) from native byte order into |
|
665 * big endian byte order. |
|
666 * |
|
667 * Since: 0.10.22 |
|
668 * |
|
669 */ |
|
670 /** |
|
671 * GFLOAT_FROM_LE: |
|
672 * @val: value |
|
673 * |
|
674 * Convert 32-bit floating point value (float) from little endian byte order |
|
675 * into native byte order. |
|
676 * |
|
677 * Since: 0.10.22 |
|
678 * |
|
679 */ |
|
680 /** |
|
681 * GFLOAT_FROM_BE: |
|
682 * @val: value |
|
683 * |
|
684 * Convert 32-bit floating point value (float) from big endian byte order |
|
685 * into native byte order. |
|
686 * |
|
687 * Since: 0.10.22 |
|
688 * |
|
689 */ |
|
690 |
|
691 #if G_BYTE_ORDER == G_LITTLE_ENDIAN |
|
692 #define GFLOAT_TO_LE(val) ((gfloat) (val)) |
|
693 #define GFLOAT_TO_BE(val) (GFLOAT_SWAP_LE_BE (val)) |
|
694 #define GDOUBLE_TO_LE(val) ((gdouble) (val)) |
|
695 #define GDOUBLE_TO_BE(val) (GDOUBLE_SWAP_LE_BE (val)) |
|
696 |
|
697 #elif G_BYTE_ORDER == G_BIG_ENDIAN |
|
698 #define GFLOAT_TO_LE(val) (GFLOAT_SWAP_LE_BE (val)) |
|
699 #define GFLOAT_TO_BE(val) ((gfloat) (val)) |
|
700 #define GDOUBLE_TO_LE(val) (GDOUBLE_SWAP_LE_BE (val)) |
|
701 #define GDOUBLE_TO_BE(val) ((gdouble) (val)) |
|
702 |
|
703 #else /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */ |
|
704 #error unknown ENDIAN type |
|
705 #endif /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */ |
|
706 |
|
707 #define GFLOAT_FROM_LE(val) (GFLOAT_TO_LE (val)) |
|
708 #define GFLOAT_FROM_BE(val) (GFLOAT_TO_BE (val)) |
|
709 #define GDOUBLE_FROM_LE(val) (GDOUBLE_TO_LE (val)) |
|
710 #define GDOUBLE_FROM_BE(val) (GDOUBLE_TO_BE (val)) |
|
711 |
|
712 #endif /* !defined(GFLOAT_FROM_LE) */ |
|
713 |
|
714 /** |
|
715 * GST_READ_FLOAT_LE: |
|
716 * @data: memory location |
|
717 * |
|
718 * Read a 32 bit float value in little endian format from the memory buffer. |
|
719 * |
|
720 * Returns: The floating point value read from @data |
|
721 * |
|
722 * Since: 0.10.22 |
|
723 * |
|
724 */ |
|
725 #ifdef _FOOL_GTK_DOC_ |
|
726 G_INLINE_FUNC gfloat GST_READ_FLOAT_LE (const guint8 *data); |
|
727 #endif |
|
728 |
|
729 inline static gfloat |
|
730 GST_READ_FLOAT_LE(const guint8 *data) |
|
731 { |
|
732 union |
|
733 { |
|
734 guint32 i; |
|
735 gfloat f; |
|
736 } u; |
|
737 |
|
738 u.i = GST_READ_UINT32_LE (data); |
|
739 return u.f; |
|
740 } |
|
741 |
|
742 /** |
|
743 * GST_READ_FLOAT_BE: |
|
744 * @data: memory location |
|
745 * |
|
746 * Read a 32 bit float value in big endian format from the memory buffer. |
|
747 * |
|
748 * Returns: The floating point value read from @data |
|
749 * |
|
750 * Since: 0.10.22 |
|
751 * |
|
752 */ |
|
753 #ifdef _FOOL_GTK_DOC_ |
|
754 G_INLINE_FUNC gfloat GST_READ_FLOAT_BE (const guint8 *data); |
|
755 #endif |
|
756 |
|
757 inline static gfloat |
|
758 GST_READ_FLOAT_BE(const guint8 *data) |
|
759 { |
|
760 union |
|
761 { |
|
762 guint32 i; |
|
763 gfloat f; |
|
764 } u; |
|
765 |
|
766 u.i = GST_READ_UINT32_BE (data); |
|
767 return u.f; |
|
768 } |
|
769 |
|
770 /** |
|
771 * GST_READ_DOUBLE_LE: |
|
772 * @data: memory location |
|
773 * |
|
774 * Read a 64 bit double value in little endian format from the memory buffer. |
|
775 * |
|
776 * Returns: The double-precision floating point value read from @data |
|
777 * |
|
778 * Since: 0.10.22 |
|
779 * |
|
780 */ |
|
781 #ifdef _FOOL_GTK_DOC_ |
|
782 G_INLINE_FUNC gdouble GST_READ_DOUBLE_LE (const guint8 *data); |
|
783 #endif |
|
784 |
|
785 inline static gdouble |
|
786 GST_READ_DOUBLE_LE(const guint8 *data) |
|
787 { |
|
788 union |
|
789 { |
|
790 guint64 i; |
|
791 gdouble d; |
|
792 } u; |
|
793 |
|
794 u.i = GST_READ_UINT64_LE (data); |
|
795 return u.d; |
|
796 } |
|
797 |
|
798 /** |
|
799 * GST_READ_DOUBLE_BE: |
|
800 * @data: memory location |
|
801 * |
|
802 * Read a 64 bit double value in big endian format from the memory buffer. |
|
803 * |
|
804 * Returns: The double-precision floating point value read from @data |
|
805 * |
|
806 * Since: 0.10.22 |
|
807 * |
|
808 */ |
|
809 #ifdef _FOOL_GTK_DOC_ |
|
810 G_INLINE_FUNC gdouble GST_READ_DOUBLE_BE (const guint8 *data); |
|
811 #endif |
|
812 |
|
813 inline static gdouble |
|
814 GST_READ_DOUBLE_BE(const guint8 *data) |
|
815 { |
|
816 union |
|
817 { |
|
818 guint64 i; |
|
819 gdouble d; |
|
820 } u; |
|
821 |
|
822 u.i = GST_READ_UINT64_BE (data); |
|
823 return u.d; |
|
824 } |
|
825 |
|
826 /** |
|
827 * GST_WRITE_FLOAT_LE: |
|
828 * @data: memory location |
|
829 * @num: value to store |
|
830 * |
|
831 * Store a 32 bit float value in little endian format into the memory buffer. |
|
832 * |
|
833 * Since: 0.10.22 |
|
834 * |
|
835 */ |
|
836 #ifdef _FOOL_GTK_DOC_ |
|
837 G_INLINE_FUNC void GST_WRITE_FLOAT_LE (guint8 *data, gfloat num); |
|
838 #endif |
|
839 |
|
840 inline static void |
|
841 GST_WRITE_FLOAT_LE(guint8 *data, gfloat num) |
|
842 { |
|
843 union |
|
844 { |
|
845 guint32 i; |
|
846 gfloat f; |
|
847 } u; |
|
848 |
|
849 u.f = num; |
|
850 GST_WRITE_UINT32_LE (data, u.i); |
|
851 } |
|
852 |
|
853 /** |
|
854 * GST_WRITE_FLOAT_BE: |
|
855 * @data: memory location |
|
856 * @num: value to store |
|
857 * |
|
858 * Store a 32 bit float value in big endian format into the memory buffer. |
|
859 * |
|
860 * Since: 0.10.22 |
|
861 * |
|
862 */ |
|
863 #ifdef _FOOL_GTK_DOC_ |
|
864 G_INLINE_FUNC void GST_WRITE_FLOAT_BE (guint8 *data, gfloat num); |
|
865 #endif |
|
866 |
|
867 inline static void |
|
868 GST_WRITE_FLOAT_BE(guint8 *data, gfloat num) |
|
869 { |
|
870 union |
|
871 { |
|
872 guint32 i; |
|
873 gfloat f; |
|
874 } u; |
|
875 |
|
876 u.f = num; |
|
877 GST_WRITE_UINT32_BE (data, u.i); |
|
878 } |
|
879 |
|
880 /** |
|
881 * GST_WRITE_DOUBLE_LE: |
|
882 * @data: memory location |
|
883 * @num: value to store |
|
884 * |
|
885 * Store a 64 bit double value in little endian format into the memory buffer. |
|
886 * |
|
887 * Since: 0.10.22 |
|
888 * |
|
889 */ |
|
890 #ifdef _FOOL_GTK_DOC_ |
|
891 G_INLINE_FUNC void GST_WRITE_DOUBLE_LE (guint8 *data, gdouble num); |
|
892 #endif |
|
893 |
|
894 inline static void |
|
895 GST_WRITE_DOUBLE_LE(guint8 *data, gdouble num) |
|
896 { |
|
897 union |
|
898 { |
|
899 guint64 i; |
|
900 gdouble d; |
|
901 } u; |
|
902 |
|
903 u.d = num; |
|
904 GST_WRITE_UINT64_LE (data, u.i); |
|
905 } |
|
906 |
|
907 /** |
|
908 * GST_WRITE_DOUBLE_BE: |
|
909 * @data: memory location |
|
910 * @num: value to store |
|
911 * |
|
912 * Store a 64 bit double value in big endian format into the memory buffer. |
|
913 * |
|
914 * Since: 0.10.22 |
|
915 * |
|
916 */ |
|
917 #ifdef _FOOL_GTK_DOC_ |
|
918 G_INLINE_FUNC void GST_WRITE_DOUBLE_BE (guint8 *data, gdouble num); |
|
919 #endif |
|
920 |
|
921 inline static void |
|
922 GST_WRITE_DOUBLE_BE(guint8 *data, gdouble num) |
|
923 { |
|
924 union |
|
925 { |
|
926 guint64 i; |
|
927 gdouble d; |
|
928 } u; |
|
929 |
|
930 u.d = num; |
|
931 GST_WRITE_UINT64_BE (data, u.i); |
|
932 } |
504 |
933 |
505 /* Miscellaneous utility macros */ |
934 /* Miscellaneous utility macros */ |
506 |
935 |
507 /** |
936 /** |
508 * GST_ROUND_UP_2: |
937 * GST_ROUND_UP_2: |