File: sync_decoder.h

package info (click to toggle)
pytorch-vision 0.21.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,228 kB
  • sloc: python: 65,904; cpp: 11,406; ansic: 2,459; java: 550; sh: 265; xml: 79; objc: 56; makefile: 33
file content (48 lines) | stat: -rw-r--r-- 1,216 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once

#include <list>
#include "decoder.h"

namespace ffmpeg {

/**
 * Class uses FFMPEG library to decode media streams.
 * Media bytes can be explicitly provided through read-callback
 * or fetched internally by FFMPEG library
 */
class SyncDecoder : public Decoder {
 public:
  // Allocation of memory must be done with a proper alignment.
  class AVByteStorage : public ByteStorage {
   public:
    explicit AVByteStorage(size_t n);
    ~AVByteStorage() override;
    void ensure(size_t n) override;
    uint8_t* writableTail() override;
    void append(size_t n) override;
    void trim(size_t n) override;
    const uint8_t* data() const override;
    size_t length() const override;
    size_t tail() const override;
    void clear() override;

   private:
    size_t offset_{0};
    size_t length_{0};
    size_t capacity_{0};
    uint8_t* buffer_{nullptr};
  };

 public:
  int decode(DecoderOutputMessage* out, uint64_t timeoutMs) override;

 private:
  void push(DecoderOutputMessage&& buffer) override;
  void onInit() override;
  std::unique_ptr<ByteStorage> createByteStorage(size_t n) override;

 private:
  std::list<DecoderOutputMessage> queue_;
  bool eof_{false};
};
} // namespace ffmpeg