@@ -148,7 +148,28 @@ bool canSwsScaleHandleUnalignedData();
148148using AVIOReadFunction = int (*)(void *, uint8_t *, int );
149149using AVIOSeekFunction = int64_t (*)(void *, int64_t , int );
150150
151- // TODO: explain purpose of context holder
151+ // The AVIOContextHolder serves several purposes:
152+ //
153+ // 1. It is a smart pointer for the AVIOContext. It has the logic to create
154+ // a new AVIOContext and will appropriately free the AVIOContext when it
155+ // goes out of scope. Note that this requires more than just the having a
156+ // UniqueAVIOContext, as the AVIOContext points to a buffer which must be
157+ // freed.
158+ // 2. It is a base class for AVIOContext specializations. When specializing a
159+ // AVIOContext, we need to provide four things:
160+ // 1. A read callback function.
161+ // 2. A seek callback function.
162+ // 3. A write callback function. (Not supported yet; it's for encoding.)
163+ // 4. A pointer to some context object that has the same lifetime as the
164+ // AVIOContext itself. This context object holds the custom state that
165+ // tracks the custom behavior of reading, seeking and writing. It is
166+ // provided upon AVIOContext creation and to the read, seek and
167+ // write callback functions.
168+ // While it's not required, it is natural for the derived classes to make
169+ // all of the above members. Base classes need to call
170+ // createAVIOContext(), ideally in there constructor.
171+ // 3. A generic handle for those that just need to manage having access to an
172+ // AVIOContext, but aren't necessarily concerned with how it was customized.
152173class AVIOContextHolder {
153174 public:
154175 virtual ~AVIOContextHolder ();
@@ -165,7 +186,7 @@ class AVIOContextHolder {
165186 UniqueAVIOContext avioContext_;
166187
167188 // Defaults to 64 KB
168- static const int defaultBufferSize = 64 * 1014 ;
189+ static const int defaultBufferSize = 64 * 1024 ;
169190};
170191
171192} // namespace facebook::torchcodec
0 commit comments