ffmpeg_utils.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef FFTOOLS_FFMPEG_UTILS_H
  19. #define FFTOOLS_FFMPEG_UTILS_H
  20. #include <stdint.h>
  21. #include "libavutil/common.h"
  22. #include "libavutil/frame.h"
  23. #include "libavutil/rational.h"
  24. #include "libavcodec/packet.h"
  25. typedef struct Timestamp {
  26. int64_t ts;
  27. AVRational tb;
  28. } Timestamp;
  29. /**
  30. * Merge two return codes - return one of the error codes if at least one of
  31. * them was negative, 0 otherwise.
  32. * Currently just picks the first one, eventually we might want to do something
  33. * more sophisticated, like sorting them by priority.
  34. */
  35. static inline int err_merge(int err0, int err1)
  36. {
  37. return (err0 < 0) ? err0 : FFMIN(err1, 0);
  38. }
  39. static inline void pkt_move(void *dst, void *src)
  40. {
  41. av_packet_move_ref(dst, src);
  42. }
  43. static inline void frame_move(void *dst, void *src)
  44. {
  45. av_frame_move_ref(dst, src);
  46. }
  47. #endif // FFTOOLS_FFMPEG_UTILS_H